Skip to content

wwkk-y/dhm-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

本项目是一个基于LLOneBot的QQ机器人

  • node版本: 22.2.0

  • LLOneBot 版本: 3.26.4

使用pnpm进行管理, 安装方法

npm i -g pnpm
pnpm i

在 /config/LLOneBotConfig.js 里面修改配置

export default {
    mode: "http", // 模式 http(http发送请求 + 事件上报), 未来支持WebSocket
    httpServer: {
        url: "http://127.0.0.1", // Http服务地址
        port: 3110 // 端口
    },
    httpSubmit: { // http上报端口
        port: 31111, // 请求端口
        urlPath: "/bot/submit" // 请求路径
    },
    webSocket: {
        
    }
}

文件命名规范

  • 多个单词大驼峰
  • 单个单词小写(除非专用词)

编码规划

  • 函数里不应该修改对象参数, 如果需要, 拷贝一份对象再使用

http 模式流程

服务器 -> 收到信息 -> 分析信息 -> 发布信息到对应分类

处理器 -> 订阅信息 -> 处理

订阅内容:

{
    ...msg, // msg详见上报消息
    content: "内容", // 检测 文本消息内容 (指令)
    atMe: true, // 是否 at 自己
}

编写 plugin 步骤

  • 在 src/plugins/ 里建立一个新的 plugin 包, 写一个主程序js文件
  • 修改 src/plugins/config.js, 在 plugins 里添加 主程序 js 文件
// test-plugin/app.js
import MsgSubUtil from '../../util/MsgSubUtil.js'

MsgSubUtil.subPrefixR("#", (msg) => {
    return "收到指令: " + msg.content;
})
export default {
    plugins: ["./test-plugin/app.js"]
}

TODO

  • 参数校验
  • 订阅超时检验

About

基于LLOneBot的QQ机器人

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published