Coder Social home page Coder Social logo

abot's Introduction

自用小型插件式QQ机器人框架

node engine discord

多号并行,无依赖,使用 JavaScript/TypeScript 编写插件。


无任何界面和控制台,完全使用QQ消息来控制框架。
框架只实现了以下最基本的功能,其他所有功能都必须用插件的形式来实现。

  • 登录和上下线广播
  • 为每个机器人实例绑定不同插件(多对多),以及热重载插件

配置文件 config.json 的参数:

eins 用于启动框架的第一个机器人账号
masters 拥有管理权限的用户组账号
prefix 系统指令触发前缀
platform 每次创建新机器人实例时的默认登录协议(1:手机、4:PC、5:平板)
log_level 每次创建新机器人实例时的默认日志等级

开始运行:

> npm i
> ./run

启动后通过给 eins 发消息来启用/卸载插件,以及登录新的账号


插件为标准npm-package的形式,可放在 pluginsnode_modules 目录下
插件若需要存储数据,推荐新建目录 ./data/plugins/{package_name}
插件需要export下面三个方法:

  • activate(bot) 当一个机器人实例启用插件时触发
  • deactivate(bot) 当一个机器人实例禁用插件时触发
  • destructor() 重载或卸载插件时触发,用于释放资源(可选)

插件开发样例

注意事项:

  • 插件目前也在主线程中运行,若出现未捕获的错误可能会导致程序崩溃
  • 程序启动/重启时,只会登录第一个账号(eins),其它账号需要通过给eins发消息来登录(不会自动登录)
    • 不自动登录的原因是防止多号情况下瞬间登录过多账号导致出现被封号的风险
  • 插件之间不支持直接依赖对方,但是可以并推荐通过事件来传递数据,以达到通信效果
    • 比如插件A触发事件 bot.emit("plugin.A.eventname", someparams)
    • 插件B监听此事件 bot.on("plugin.A.eventname", listenerfn)

abot's People

Contributors

takayama-lily avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

abot's Issues

一个bug

命令执行成功了也会返回这个 Error
ece4383953ead06e483dad403616adc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.