Skip to content

Commit

Permalink
🎨 fix: kritor bot (not tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikechan8370 committed Apr 27, 2024
1 parent efb86fd commit 32553a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/adapter/kritor/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { kritor, common, Cfg, Bot } from '#Karin'
import { KarinAdapter } from '../adapter.js'

/**
* @extends KarinAdapter
*/
export default class Kritor extends KarinAdapter {
constructor (grpc, account) {
super()
Expand Down
5 changes: 4 additions & 1 deletion lib/adapter/kritor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class Kritor {
RegisterPassiveListener: (call) => {
const metadata = call.metadata.getMap()
const { 'kritor-self-uid': uid, 'kritor-self-uin': uin } = metadata

let bot = Bot.adapter[uid]
/** 监听上报事件 */
call.on('data', data => {
logger.debug('上报事件:', data)
Expand All @@ -85,18 +85,21 @@ export default class Kritor {
/** 消息事件 */
case kritor.event.EventType.EVENT_TYPE_MESSAGE: {
const message = Converters.messageConverter.convert(data.message, uin || uid)
message.bot = bot
Bot.emit('message', message)
break
}
/** 通知事件 */
case kritor.event.EventType.EVENT_TYPE_NOTICE: {
const notice = Converters.noticeConverter.convert(data.notice, uin || uid)
notice.bot = bot
Bot.emit('notice', notice)
break
}
/** 请求事件 */
case kritor.event.EventType.EVENT_TYPE_REQUEST: {
const request = Converters.requestConverter.convert(data.request, uin || uid)
request.bot = bot
Bot.emit('request', request)
break
}
Expand Down

0 comments on commit 32553a1

Please sign in to comment.