Skip to content

Commit

Permalink
feat:#Karin加入kritor
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Apr 7, 2024
1 parent 427b524 commit 8474ef6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
51 changes: 25 additions & 26 deletions lib/adapter/kritor/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
KarinImageElement,
KarinTextElement
} from '../../bot/model.js'
import {kritor} from './protos/compiled.js'
import {logger, Bot} from '#Karin'
import {KarinMessage} from "../../event/type.js";
import { logger, Bot, kritor } from '#Karin'
import { KarinMessage } from "../../event/type.js";

// import { raw } from 'express'

Expand All @@ -31,7 +30,7 @@ export class MessageConverter extends Converter {
* @return {KarinMessage}
*/
convert(message) {
let {self_id} = message
let { self_id } = message
let time = message.time
let message_id = message.message_id
let message_seq = message.message_seq
Expand Down Expand Up @@ -84,10 +83,10 @@ export class MessageConverter extends Converter {
}

const e = new KarinMessage(self_id, sender.uid, contact.peer, time, message_id, message_seq, '', {
scene,
peer: contact.peer,
sub_peer: contact.sub_peer
}, sender, elements, '', '', [], '', false, false, false, false)
scene,
peer: contact.peer,
sub_peer: contact.sub_peer
}, sender, elements, '', '', [], '', false, false, false, false)

/**
* 快速回复
Expand All @@ -114,40 +113,40 @@ export class MessageConverter extends Converter {
for (let i of elements) {
switch (i.type) {
case 'text': {
const {TEXT: type} = ElementType
const {text} = i
_elements.push({type, text: {text}})
const { TEXT: type } = ElementType
const { text } = i
_elements.push({ type, text: { text } })
break
}
case 'image': {
const {IMAGE: type} = ElementType
const {file} = i
_elements.push({type, image: {file}})
const { IMAGE: type } = ElementType
const { file } = i
_elements.push({ type, image: { file } })
break
}
case 'at': {
const {AT: type} = ElementType
const {uid, uin = ''} = i
_elements.push({type, at: {uid, uin}})
const { AT: type } = ElementType
const { uid, uin = '' } = i
_elements.push({ type, at: { uid, uin } })
break
}
case 'face': {
const {FACE: type} = ElementType
const {id, is_big = false} = i
_elements.push({type, face: {id, is_big}})
const { FACE: type } = ElementType
const { id, is_big = false } = i
_elements.push({ type, face: { id, is_big } })
break
}
case 'reply': {
const {REPLY: type} = ElementType
const {id} = i
_elements.push({type, reply: {id}})
const { REPLY: type } = ElementType
const { id } = i
_elements.push({ type, reply: { id } })
break

}
case 'VOICE': {
const {VOICE: type} = ElementType
const {file} = i
_elements.push({type, voice: {file}})
const { VOICE: type } = ElementType
const { file } = i
_elements.push({ type, voice: { file } })
break
}
}
Expand Down
5 changes: 2 additions & 3 deletions lib/adapter/kritor/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Api from './api.js'
import { Bot, logger } from '#Karin'
import * as grpc from '@grpc/grpc-js'
import * as protoLoader from '@grpc/proto-loader'
import { kritor } from './protos/compiled.js'
import Api from './api.js'
import Converters from './converter.js'
import { Bot, logger, kritor } from '#Karin'

export default class Kritor {
/**
Expand Down
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import segment from './bot/segment.js'
import common from './common/common.js'
import plugin from './plugins/plugin.js'
import renderer from './puppeteer/puppeteer.js'
import { kritor } from './adapter/kritor/protos/compiled.js'

export { App, Bot, Cfg, common, logger, plugin, redis, segment, renderer }
export default { App, Bot, Cfg, common, logger, plugin, redis, segment, renderer }
export { App, Bot, Cfg, common, logger, plugin, redis, segment, renderer, kritor }
export default { App, Bot, Cfg, common, logger, plugin, redis, segment, renderer, kritor }

0 comments on commit 8474ef6

Please sign in to comment.