Giter Club home page Giter Club logo

js-bot's Introduction

使用方法

(1) 安装 酷 QCoolQ HTTP API 插件

运行 酷 Q ,启用 cqhttp 插件,配置 websocket 服务如下:

{
    "use_ws": true,
    "ws_host": "127.0.0.1",
    "ws_port": 6700,
    "access_token": "mytoken",
}

(2) 用谷歌或火狐浏览器打开 https://pandolia.net/js-bot 网址,在输入框中输入以下代码注册事件处理的回调函数:

handler.onCqEvent = function (data, api) {
    console.log(JSON.stringify(data, null, '    '));
}

事件处理回调函数中的第一个参数 data 是事件数据,支持的事件列表及字段说明详见 cqhttp 事件列表

事件处理回调函数中的第二个参数 api 是用来调用 cqhttp-api 的函数,示例如下:

api('send_like', { user_id: 158297369 }).then(() => console.log('ok'));

其他 cqhttp-api 见 cqhttp API 列表 ,调用时需注意下面两个问题:

  • 第一个参数为 cqhttp-api 名称,前面不含斜杠 "/"
  • 第二个参数为 cqhttp-api 参数,与用户 id 相关的字段全部采用 number 类型(js-bot 内部采用的是 string 类型)

(3) 开发模式

下载本项目源码,运行 yarn install; yarn start ,修改 src/myhandler.ts 文件。

特别致谢

感谢酷 Q 软件和 Richard Chien 开发的 coolq-http-api

js-bot's People

Contributors

pandolia 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.