YunYouJun / Mirai Ts
Licence: agpl-3.0
🔧 Mirai(QQ Bot) JavaScript/TypeScript SDK for Node.js/Browser
Stars: ✭ 86
Programming Languages
javascript
184084 projects - #8 most used programming language
typescript
32286 projects
Projects that are alternatives of or similar to Mirai Ts
Botbuilder Dotnet
Welcome to the Bot Framework SDK for .NET repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using .NET.
Stars: ✭ 631 (+633.72%)
Mutual labels: bot, sdk
Pymessager
Python API to develop chatbot on Facebook Messenger Platform
Stars: ✭ 580 (+574.42%)
Mutual labels: bot, sdk
Botframework Sdk
Bot Framework provides the most comprehensive experience for building conversation applications.
Stars: ✭ 6,673 (+7659.3%)
Mutual labels: bot, sdk
Botlibre
An open platform for artificial intelligence, chat bots, virtual agents, social media automation, and live chat automation.
Stars: ✭ 412 (+379.07%)
Mutual labels: bot, sdk
Matrix Bot Sdk
TypeScript/JavaScript SDK for Matrix bots
Stars: ✭ 63 (-26.74%)
Mutual labels: bot, sdk
Botbuilder Js
Welcome to the Bot Framework SDK for JavaScript repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using JavaScript.
Stars: ✭ 469 (+445.35%)
Mutual labels: bot, sdk
Line Bot Sdk Nodejs
LINE Messaging API SDK for Node.js
Stars: ✭ 683 (+694.19%)
Mutual labels: bot, sdk
Newbe.mahua.framework
本SDK为实现QQ机器人平台的大一统,支持多种机器人平台:酷Q、MyPCQQ、QQLight等
Stars: ✭ 849 (+887.21%)
Mutual labels: sdk, qq
Line Bot Sdk Python
LINE Messaging API SDK for Python
Stars: ✭ 1,198 (+1293.02%)
Mutual labels: bot, sdk
mirai-ts
mirai-api-http 的 JavaScript/TypeScript SDK,附带声明文件,拥有良好的注释和类型提示。可运行于 Node.js 与浏览器端。
除了 Node.js,它还兼容浏览器端。这意味着你可以使用它来开发 Web 界面与你的 mirai 机器人进行交互。(可以参考还在咕的 el-bot-web)
如何使用
自行配置好你的 mirai 与 mirai-api-http,确保
localhost:你配置的端口号/about
是可访问的。
npm install mirai-ts
# yarn add mirai-ts
快速开始
JavaScript
node demo/index.js
TypeScript
ts-node demo/index.ts
Browser
基于 mirai-ts 开发面向浏览器端的应用程序时,您还需要安装 events 以在浏览器端替代 Node.js 原生 events 模块。
yarn add events
# npm install events mirai-ts
Why Typescript & mirai-ts?
Make JavaScript Great Again!
- 更友好的提示:TypeScript 配合 VSCode 代码提示有奇效。
- 更清晰的语义:函数命名与 mirai-api-http 保持一致。
- 更易懂的注释:因为会用到 QQ 机器人 99.99% 是国人,所以是全中文注释。
- 更优雅的结构:看起来是在自吹自擂,但自我感觉良好。
- 更广泛的平台:支持 Node.js 与浏览器端,以及 WebSocket。
简介
结构
types
目录下为对应类型定义
-
api
: API 发送与响应-
response
: API 响应格式
-
-
contact
: 用户信息格式(如 Friend, Member, Group 等) -
event-type
: 事件类型 -
message-type
: 消息类型
工具类
const { Message, Logger, check, MessageType, EventType } = require("mirai-ts");
import { Message, Logger, check, MessageType, EventType } from "mirai-ts";
详情请参见 API 文档。
Message
-
Message
: 生成对应消息的辅助方法,如生成艾特某人的消息Message.At(qq)
消息链应当是一个数组,如
messageChain = [Message.At(qq), Message.Plain('来点色图')]
Logger
简单的日志工具,当然你可以自由使用其他工具替代它。
import { Logger } from "mirai-ts";
// 你可以自定义你的前缀
const logger = new Logger({ prefix: "[mirai-ts]" });
logger.success("We are free!");
check
消息匹配与检测。
如判断消息链是否有艾特某人:
const { check } = require("mirai-ts");
// msg 为消息链 MessageChain
// qq 为 QQ 号
check.isAt(msg, qq);
// or just
msg.isAt(qq);
// 留空则判断是否艾特机器人自身
示例模版
- el-bot:你可以参考它的使用方式,你也可以直接使用它。
el-bot 展示了整个 mirai-ts 的使用流程,并内置了一些如自动应答、转发、命令行、RSS 等常用功能(默认插件),开箱即用。
你只需要一些自定义的配置,而不再需要编写繁琐的脚本内容。
但这并不是束缚,在插件系统中你仍然可以调用机器人所有的上下文,并通过编写插件的形式快速实现你想要的功能。
更多请参见文档 el-bot | El Bot Docs
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].