GithubHelp home page GithubHelp logo

dhm-bot's Introduction

本项目是一个基于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

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

dhm-bot's People

Contributors

wwkk-y avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.