https://github.com/kokkorojs/kokkoro
とある咕咕の QQ 机器人框架 (OxO)?!...
https://github.com/kokkorojs/kokkoro
bot priconne qq qqbot
Last synced: 8 months ago
JSON representation
とある咕咕の QQ 机器人框架 (OxO)?!...
- Host: GitHub
- URL: https://github.com/kokkorojs/kokkoro
- Owner: kokkorojs
- License: mit
- Created: 2021-12-03T13:58:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-27T16:03:18.000Z (almost 2 years ago)
- Last Synced: 2025-09-23T22:39:25.594Z (9 months ago)
- Topics: bot, priconne, qq, qqbot
- Language: TypeScript
- Homepage: https://kokkoro.js.org
- Size: 1.09 MB
- Stars: 60
- Watchers: 2
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
---
[](https://priconne-redive.jp/)
[](https://jq.qq.com/?_wv=1027&k=3hcWCnhq)
[](https://www.npmjs.com/package/kokkoro)
[](https://nodejs.org)

## 介绍
本项目是一个基于 [Amesu](https://github.com/xueelf/amesu) SDK,使用 [TypeScript](https://www.typescriptlang.org/) 语言开发的 [QQ](https://im.qq.com/) 机器人框架。
## 使用
你可以使用 CLI 来快速构建项目:
```shell
npm i -g @kokkoro/cli
kokkoro init
```
```shell
✔ Please enter the project name: …
✔ Your robot appid: …
✔ Your robot token …
✔ Your robot secret …
✔ Is it a public domain robot? … No / Yes
SUCCESS Project initialization completed.
```
### 目录结构
```tex
.
├─ data 项目资源
├─ logs 日志列表
├─ plugins 插件目录
├─ index.js 程序入口
└─ kokkoro.json 配置文件
```
安装好依赖文件后,使用 `kokkoro start` 启动项目。
### 配置项
```json
{
// web 服务
"server": {
// 端口号
"port": 2333,
// 域名
"domain": "http://localhost"
},
// 日志等级
"log_level": "INFO",
// 订阅事件
"events": [],
// bot 信息,可添加多个
"bots": [
{
"appid": "1145141919",
"token": "38bc73e16208135fb111c0c573a44eaa",
"secret": "6208135fb111c0c5"
}
]
}
```
若要开发插件,可以在**项目根目录**使用下列命令:
```shell
kokkoro plugin
```
```shell
✔ Which plugin style would you like to use:
> Javascript
Typescript (Hook)
Typescript (Decorator)
INFO Plugin creation has been aborted.
```
### 插件
#### Javascript (Hook)
```javascript
import { useCommand, useEvent } from '@kokkoro/core';
/**
* @type {import('@kokkoro/core').Metadata}
*/
export const metadata = {
name: 'example',
description: '插件示例',
};
export default function Example() {
useEvent(
ctx => {
ctx.logger.mark('link start');
},
['session.ready'],
);
useCommand('/测试', () => 'hello world');
useCommand('/复读 ', ctx => ctx.query.message);
}
```
#### Typescript (Hook)
```typescript
import { Metadata, useCommand, useEvent } from '@kokkoro/core';
export const metadata: Metadata = {
name: 'example',
description: '示例插件',
};
export default function Example() {
useEvent(
ctx => {
ctx.logger.mark('link start');
},
['session.ready'],
);
useCommand('/测试', () => 'hello world');
useCommand<{ message: string }>('/复读 ', ctx => ctx.query.message);
}
```
#### Typescript (Decorator)
```typescript
import { Command, CommandContext, Context, Event, Plugin } from '@kokkoro/core';
@Plugin({
name: 'example',
description: '示例插件',
})
export default class Example {
@Event('session.ready')
onReady(ctx: Context<'session.ready'>) {
ctx.logger.mark('link start');
}
@Command('/测试')
testMessage() {
return 'hello world';
}
@Command('/复读 ')
replayMessage(ctx: CommandContext<{ message: string }>) {
return ctx.query.message;
}
}
```