-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,49 @@ | ||
# Linquebot_v2 | ||
|
||
[api referances](https://lhcfl.github.io/Linquebot_v2/) | ||
## How to use | ||
|
||
开发中,请参阅dev.md | ||
复制 `config.example.yml` 到 `config.yml` | ||
|
||
``` | ||
cp config.example.yml config.yml | ||
``` | ||
|
||
接下来,按 `config.example.yml` 的说明配置 `config.yml` | ||
|
||
最后,启动 | ||
|
||
``` | ||
npm run build | ||
npm run start | ||
``` | ||
|
||
## Develop Plugin | ||
|
||
[Api referances](https://lhcfl.github.io/Linquebot_v2/) | ||
|
||
Linquebot的基本组成部分是 Plugin。每个 Plugin 单独在 `src/plugins/` 下有一个文件夹。 | ||
|
||
每个 Plugin 必须有一个 `index.js` (或 `index.ts` 然后编译) `export` 一个 `PluginInit` 类型的 `init`。 | ||
|
||
下面是一个 Plugin 的 `index.ts` 的模板: | ||
|
||
```typescript | ||
import { commandHandleFunction } from '@/lib/command.js'; | ||
import { PluginInit } from '@/types/plugin.js'; | ||
|
||
const sayHello: commandHandleFunction = (app, msg) => { | ||
app.bot.sendMessage(msg.chat.id, 'hello, world!'); | ||
}, | ||
|
||
const init: PluginInit = (app) => { | ||
console.log('plugin loaded!'); | ||
app.registCommand({ | ||
command: 'hellp', | ||
chat_type: 'all', | ||
description: 'say hello', | ||
handle: sayHello, | ||
}); | ||
}; | ||
|
||
export { init }; | ||
``` |