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

wechaty-room-invite

v0.0.1

Published

Invite user to rooms by keyword

Downloads

4

Readme

wechaty-room-invite

Wechaty Plugin Contrib Powered by Wechaty

Invite user to rooms by keyword

通过关键字邀请用户进入房间

开始

简介

你可以向机器人发送某些关键字,机器人会通过这些关键字邀请你进入对应的房间,当然,可以是多个房间

安装

npm install wechaty-room-invite

or

yarn add wechaty-room-invite

使用

const WechatyRoomInvite = require("wechaty-room-invite")

bot.use(WechatyRoomInvite(options))

如上所示

使用插件只要按需传入配置对象 options 即可

| Options 参数属性 | 类型 | 简介 | | ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | keyword | String|Array | 触发邀请该用户的关键字,只有一个可以使用字符串类型,多个关键字使用数组类型 | | roomList | Array | 机器人管理的群聊列表,该项为必填项,数组对象中具体配置请看下面示例 | | reply | String | roomList 数组长度大于 1 时,视为管理多个群聊,那么 keyword 触发后会回复用户当前管理的群聊列表数据供用户选择进入某一个群,这个群聊数据列表为一段由 roomList 配置生成的话,roomList 数组长度等于 1 时,keyword 触发将会直接拉起群邀请,那么此字段也无用,reply 字段不是必选项,管理多个群聊时,建议直接使用默认文字,默认流程可看最后示例图片 |

我们来看 roomList 数组的配置示例

roomList: [
  {
    // 群聊名字,管理多个群聊时用户可通过群聊名字选择某个群聊
    name: "微信机器人",
    // 群聊id
    roomId: "22275855499@chatroom",
    // 群聊别名,建议简短,管理多个群聊时用户可通过别名选择某个群聊,叫它[编号]可能更好
    alias: "A05",
    // 标签,用于在管理多个群聊时给各个群聊做一个简单的标识,方便用户选择
    label: "新群",
    // 是否关闭进入,如果为true,则触发该群时,会提示该群不可进入
    close: true,
  },
  ...
]

示例

const { Wechaty } = require("wechaty")
const { PuppetPadplus } = require("wechaty-puppet-padplus")
const Qrterminal = require("qrcode-terminal")
// 插件 WechatyRoomInvite
const WechatyRoomInvite = require("wechaty-room-invite")

// 初始化 bot
const bot = new Wechaty({
  puppet: new PuppetPadplus({
    // 机器人padplus协议token
    token: PUPPET_PADPLUS_TOKEN,
  }),
  // 机器人名字
  name: ROBOT_NAME,
})

// 插件参数配置
const options = {
  keyword: ["加群", "入群", "群"],
  roomList: [
    {
      name: "Web圈0x01",
      roomId: "10614174865@chatroom",
      alias: "A01",
      label: "推荐",
    },
    {
      name: "Web圈0x02",
      roomId: "22825376327@chatroom",
      alias: "A02",
      label: "新群",
    },
    {
      name: "微信机器人",
      roomId: "24661539197@chatroom",
      alias: "A04",
      label: "推荐",
    },
    {
      name: "男神开门群",
      roomId: "22275855499@chatroom",
      alias: "A05",
      label: "测试",
      close: true,
    },
  ],
  reply: "",
}

// 使用插件
bot.use(WechatyRoomInvite(options))

bot
  .on("scan", (qrcode, status) => {
    Qrterminal.generate(qrcode, { small: true })
  })
  .start()

最后

扫描二维码,加圈子微信,可进交流群哦,效果如下图,赶快来试试吧

下图为多个群聊管理,只有 roomList 数组长度为 1 时,不会显示 reply ,将会直接拉起群邀请