Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Thirdeye
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
Koishi Thirdeye
Commits
871266dd
Commit
871266dd
authored
Dec 18, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
readme
parent
016e94bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
README.md
README.md
+21
-1
No files found.
README.md
View file @
871266dd
...
...
@@ -13,7 +13,8 @@ npm install koishi-thirdeye koishi@next
可以简单定义类以快速开发 Koishi 插件。
```
ts
import
{
KoishiPlugin
,
DefineSchema
,
CommandUsage
,
PutOption
,
UseCommand
,
OnApply
}
from
'
koishi-thirdeye
'
import
{
KoishiPlugin
,
DefineSchema
,
CommandUsage
,
PutOption
,
UseCommand
,
OnApply
,
KoaContext
,
UseMiddleware
,
UseEvent
,
Get
}
from
'
koishi-thirdeye
'
;
import
{
Context
,
Session
}
from
'
koishi
'
;
export
class
MyPluginConfig
{
@
DefineSchema
({
default
:
'
bar
'
})
...
...
@@ -29,11 +30,26 @@ export default class MyPlugin implements OnApply {
// 该方法会在插件加载时调用,用于在上下文中注册事件等操作。
}
@
UseMiddleware
()
simpleMiddleware
(
session
:
Session
,
next
:
NextFunction
)
{
return
next
();
}
@
UseEvent
(
'
message
'
)
onMessage
(
session
:
Session
.
Payload
<
'
message
'
>
)
{
}
@
UseCommand
(
'
echo
'
,
'
命令描述
'
)
@
CommandUsage
(
'
命令说明
'
)
onEcho
(@
PutOption
(
'
content
'
,
'
-c <content:string> 命令参数
'
)
content
:
string
)
{
return
content
;
}
@
Get
(
'
/ping
'
)
onPing
(
ctx
:
KoaContext
)
{
ctx
.
body
=
'
pong
'
;
}
}
```
...
...
@@ -122,6 +138,10 @@ export interface OnDisconnect {
*
`@UseCommand(def: string, desc?: string, config?: Command.Config)`
注册指令。指令系统可以参考
[
Koishi 文档
](
https://koishi.js.org/guide/command.html
)
。指令回调参数位置和类型和 Koishi 指令一致。
*
若指定
`config.empty`
则不会注册当前函数为 action,用于没有 action 的父指令。
*
`@Get(path: string)`
`@Post(path: string)`
在 Koishi 的 Koa 路由中注册 GET/POST 路径。此外, PUT PATCH DELETE 等方法也有所支持。
### 指令描述装饰器
koishi-thirdeye 使用一组装饰器进行描述指令的行为。这些装饰器需要和
`@UseCommand(def)`
一起使用。
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment