0.0.32 • Published 10 months ago

wechaty-puppet-mini v0.0.32

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

PUPPET-MINI

NPM Version npm (tag) NPM

Powered by Wechaty TypeScript

运行方法

安装依赖

npm install @juzi/wechaty
npm install wechaty-puppet-mini

编写代码

import { WechatyBuilder } from '@juzi/wechaty'

WechatyBuilder.build()  // get a Wechaty instance
  .on('message',       message => console.log(`Message: ${message}`))
  .start()

Learn more for building your first Wechaty bot at https://github.com/wechaty/, https://github.com/wechaty/getting-started

消息种类支持

消息类型从属(根据接口返回)api接收发送
文本textmessage.text
图片imagemessage.toImage()
视频videomessage.toFilebox()
文件othermessage.toFilebox()

使用示例

1. 可配置参数

  • tokenchatbotIdmqNamemqPassword可以通过环境变量或者此处传入。
  • port可以指定 koa 服务监听的端口和路由前缀,默认是8077。
new PuppetMini({
  token: 'mini_1325g3v4vs4xvu7snst',
  chatbotId: 'juzi_1qaz@WSX',
  mqName: 'kbl',
  mqPassword: '1qaz@WSX',
})

2. 创建实例

const bot = WechatyBuilder.build({
  puppet: new PuppetMini({
    token: 'mini_1325g3v4vs4xvu7snst',
    chatbotId: 'juzi_1qaz@WSX',
    mqName: 'kbl',
    mqPassword: '1qaz@WSX',
  }),
})  // get a Wechaty instance
  .on('login', (user: any) => log.info(`User ${user} logged in`))
  .on('message', async (message: Message) => {
    log.info(`Message: ${message}`)
  })

await bot.start()

const contact = await bot.Contact.find({ id: 'xxxxxxxxxxx' })

3. 文本消息

await contact.say('This is a simple text message.')

4. 图片消息

contact.say(FileBox.fromFile('C:\\Users\\Desktop\\1.png'))

Wechaty

Wechaty 是一个开源聊天机器人框架SDK,具有高度封装、高可用的特性,支持NodeJs, Python, Go 和Java 等多语言版本。在过去的5年中,服务了数万名开发者,收获了 Github 的 9600 Star。同时配置了完整的DevOps体系并持续按照Apache 的方式管理技术社区。

项目技术栈

  1. TypeScript programming language
  2. Git
  3. REST Api

相关链接

0.0.30

10 months ago

0.0.31

10 months ago

0.0.32

10 months ago

0.0.20

12 months ago

0.0.21

12 months ago

0.0.23

12 months ago

0.0.24

12 months ago

0.0.25

12 months ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

12 months ago

0.0.19

12 months ago

0.0.26

11 months ago

0.0.27

10 months ago

0.0.28

10 months ago

0.0.29

10 months ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago