eventReg

huan_kong

314字约1分钟

2023-12-07

函数列表

1.快捷注册事件处理函数

函数名: eventReg

函数参数:

字段类型说明默认值
type"message" | "notice" | "request"事件类型undefined
callbackmessageCallback noticeCallback requestCallback事件被触发时需要执行的函数undefined
prioritynumber调用时的顺序1

priority 的值越大越先执行

请最大不要超过 100

最小不要小于 1

2.快捷判断是否@了机器人

函数名: haveAt

函数参数:

字段类型说明默认值
contextSocketHandle['message']事件返回的 context 对象undefined
commandNamestring手动指定命令名@

返回值(匹配成功):

{
  "name": "@",
  "params": []
}

返回值(匹配失败):

false

3.格式化命令

函数名: format

函数参数:

字段类型说明默认值
messagestring消息undefined

返回值 : commandFormat | false

4.缺少参数

函数名: missingParams

函数参数:

字段类型说明默认值
contextSocketHandle['message']事件返回的 context 对象undefined
commandcommandFormat命令对象undefined
paramsLengthnumber需要的参数长度undefined

接口

messageCallback

type messageCallback = (event: SocketHandle['message'],command: commandFormat | false) => Promise<undefined | any | 'quit'>

noticeCallback

type noticeCallback = (event: SocketHandle['notice']) => Promise<undefined | any | 'quit'>

requestCallback

type requestCallback = (event: SocketHandle['request']) => Promise<undefined | any | 'quit'>

commandFormat

interface commandFormat {
  name: string
  params: string[]
}