This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@zhengxs/ernie-wechat-bot
TypeScript icon, indicating that this package has built-in type declarations

1.7.1 • Public • Published


👍
微信 · 文心一言 · 机器人



TypeScriptcode style: prettiernpm packagenpm downloadsnpm downloadsLicense

快速开始搭建属于自己的智能聊天机器人




可以调用文心大模型的能力,包含文本创作、通用对话 和 AI作图,并根据内容自动调用不同的插件以丰富消息内容。

安装

# With NPM
$ npm i -S @zhengxs/ernie-wechat-bot

# With Yarn
$ yarn add @zhengxs/ernie-wechat-bot

# With PNPM
$ pnpm add @zhengxs/ernie-wechat-bot

快速开始

自带 wechat4u,你也可以换成其他的。

import { ernieBot } from '@zhengxs/ernie-wechat-bot'

const bot = ernieBot({
  // 默认从 ERNIE_BOT_COOKIE 或 EB_COOKIE 环境变量中读取
  cookie: 'BDUSS=xxxxxxx;',
})

bot.listen({
  name: 'ernie',
  puppet: 'wechaty-puppet-wechat4u',
  puppetOptions: { uos: true },
})

命令行启动

不再支持 cookie 名文传递,请使用 ERNIE_BOT_COOKIE 环境变量。

# 启动微信机器人
$ erniebot

自定义处理逻辑

import ERNIEBot, { ListenType } from '@zhengxs/ernie-wechat-bot'

const bot = new ERNIEBot({
  cookie: 'BDUSS=xxxxxxx;',
})

// 自定义消息处理器
bot.on(ListenType.ImIndividualMessage, function ({ detail: message }) {
  // 你的逻辑
})

// 内置个人消息处理器注册
bot.on(ListenType.ImIndividualMessage, bot.events.individual.listener())

// 内置房间消息处理器注册
bot.on(ListenType.ImRoomMentionMessage, bot.events.room.mention.listener())

bot.on(ListenType.Login, function (event) {
  log.info(`🤖 ${event.detail} 上线`)
})

bot.on(ListenType.Logout, function (event) {
  log.info(`🤖 ${event.detail} 离线`)
})

bot.on(ListenType.Error, function (event) {
  log.error(`🤖 错误:${event.detail.message}`)
})

bot.listen({
  name: 'ernie',
  puppet: 'wechaty-puppet-wechat4u',
  puppetOptions: { uos: true },
})

待办

  • [ ] 内置插件支持
    • [x] 支持商业信息查询
    • [x] 支持说图解画插件 (仅私聊)
    • [x] 支持览卷文档 (仅私聊)
    • [x] 支持 TreeMind 树图
    • [ ] 支持 E 言易图
  • [ ] 允许聊天中动态切换插件

关联项目

感谢

以上排名不分先后.

License

MIT

Package Sidebar

Install

npm i @zhengxs/ernie-wechat-bot

Weekly Downloads

7

Version

1.7.1

License

MIT

Unpacked Size

124 kB

Total Files

44

Last publish

Collaborators

  • zhengxs