npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yochat

v1.0.7

Published

基于 Nodejs 的 微信机器人、微信命令行工具. 扩展性高的微信机器人

Downloads

23

Readme

yochat

yochat 是一个微信机器人的Node.js版本的实现,集成了Web版微信的所有接口,功能,简单的几行命令就可以定义一个微信小机器人,当然,你也可以基于该代码自己扩展丰富的功能.

入门

定义简单的机器人:

const Wechat = require('yochat')

// 全局配置
Wechat.config({
    autoLogin: true, // 是否保存cookie 以便自动登录
    openBrowser: false, // 是否在浏览器中打开二维码链接 (默认在terminal中显示)
    cookie: 'cookie string' // 自定义设置cookie字符串
})

// 初始化程序
Wechat.run(async () => {
    // 获取联系人列表
    let memberList = await Wechat.getContact()
    // 获取账户信息
    let ownerInfo = await Wechat.getOwnerInfo()
    // 给指定用户发送消息(这里测试自己给自己发)
    var ownUserName = ownerInfo.User.UserName;
    let sendStatus = await Wechat.sendMsg(ownUserName, ownUserName, `hello word! 现在的时间是:${new Date()}`)
    if (sendStatus) {
        console.log('消息发送成功!')
    } 

    // 自动回复消息
    Wechat.listener.on('message', async data => {
        // 群聊消息
        if (data.type === 'Group') {

            var groupName = data.fromUser.NickName;
            var masterUserName = data.toUser.NickName;

            if (data.msg.indexOf('exit') > -1) {
                console.log('发送 "exit" 退出群聊')
                Wechat.deleteMemberFromChatroom(data.fromUser.UserName, data.toUser.UserName)
            }

            if (data.msg.indexOf('rename') > -1) {
                console.log('发送 "rename" 修改群聊名称')
                Wechat.renameChatroom(data.fromUser.UserName, new Date().getTime())
            }
            console.log(`收到群聊消息: ${masterUserName}(${groupName}): ${data.msg}`)
        } 
        // 普通消息
        else {
            console.log(`收到来自: ${data.fromUser.NickName} 的消息: ${data.msg}`)
        }

        // 自动回复
        let sendStatus = await Wechat.sendMsg(ownUserName, data.fromUser.UserName, `自动回复: ${data.msg}`)
        if (sendStatus) {
            console.log('消息发送成功!')
        }
    })
})

全局配置:

Wechat.config({
    autoLogin: true, // 是否保存cookie 以便自动登录
    openBrowser: false, // 是否在浏览器中打开二维码链接 (默认在terminal中显示)
})

效果演示:

image