Skip to content

Commit

Permalink
fix: 修正描述 继续挖坑 咕咕咕
Browse files Browse the repository at this point in the history
  • Loading branch information
Lain. committed Jun 3, 2024
1 parent 7ae39ad commit 2e18050
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 140 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
- [ ] 支持onebot HTTP
- [x] 支持[onebots](https://github.com/lc-cn/onebots)
- [x] ~~puppeteer渲染图片~~
- [x] 外置[puppeteer](https://github.com/KarinJS/karin-plugin-puppeteer)
- [ ] 支持redis集群
- [x] 外置[puppeteer](https://github.com/KarinJS/karin-plugin-puppeteer)\
- [ ] 降低对`redis`的依赖
- [ ] 支持 package.karin
- [ ] 支持db通用接口
- [ ] 支持动态加载插件
- [ ] 支持`redis`集群

> 关于`puppeteer`,由于内置的chrome过于臃肿,将会移除内置的pupppeteer,分开搭建或使用远程、作为插件等方式使用puppeteer。
> [karin-puppeteer](https://github.com/KarinJS/karin-puppeteer)
Expand Down
4 changes: 2 additions & 2 deletions lib/adapter/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ export class KarinAdapter {
/**
* 处理加群请求/邀请
* @param {string} flag - 加群请求的 flag(需从上报的数据中获得)
* @param {string} sub_type - add 或 invite,请求类型(需要和上报消息中的 sub_type 字段相符)
* @param {string} sub_event - add 或 invite,请求类型(需要和上报消息中的 sub_event 字段相符)
* @param {boolean} [approve=true] - 是否同意请求/邀请
* @param {string} [reason=''] - 拒绝理由(仅在拒绝时有效)
*/
// eslint-disable-next-line no-unused-vars
async set_group_add_request (flag, sub_type, approve = true, reason = '') {
async set_group_add_request (flag, sub_event, approve = true, reason = '') {
throw new Error('Not implemented')
}

Expand Down
22 changes: 11 additions & 11 deletions lib/adapter/onebot/OneBot11.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class OneBot11 extends KarinAdapter {
this.logger('trace', `[心跳]:${JSON.stringify(data.status, null, 2)}`)
break
case 'lifecycle':
this.logger('debug', `[生命周期]:${{ enable: 'OneBot启用', disable: 'OneBot停用', connect: 'WebSocket连接成功' }[data.sub_type]}`)
this.logger('debug', `[生命周期]:${{ enable: 'OneBot启用', disable: 'OneBot停用', connect: 'WebSocket连接成功' }[data.sub_event]}`)
break
}

Expand Down Expand Up @@ -310,14 +310,14 @@ export class OneBot11 extends KarinAdapter {
group_id: data.group_id,
target_uid: data.user_id,
target_uin: data.user_id,
is_admin: data.sub_type === 'set'
is_admin: data.sub_event === 'set'
}
data = new KarinGroupAdminChangedNotice({ time, self_id, content })
break
}
case 'group_decrease': {
const content = { group_id: data.group_id }
switch (data.sub_type) {
switch (data.sub_event) {
// 主动退群
case 'leave':
content.type = 0
Expand Down Expand Up @@ -349,7 +349,7 @@ export class OneBot11 extends KarinAdapter {
operator_uin: data.operator_id,
target_uid: data.user_id,
target_uin: data.user_id,
type: data.sub_type === 'approve' ? 0 : 1
type: data.sub_event === 'approve' ? 0 : 1
}
data = new KarinGroupMemberIncreasedNotice({ time, self_id, content })
break
Expand All @@ -362,7 +362,7 @@ export class OneBot11 extends KarinAdapter {
target_uid: data.user_id,
target_uin: data.user_id,
duration: data.duration,
type: data.sub_type === 'ban' ? 1 : 0
type: data.sub_event === 'ban' ? 1 : 0
}
data = new KarinGroupMemberBanNotice({ time, self_id, content })
break
Expand Down Expand Up @@ -396,7 +396,7 @@ export class OneBot11 extends KarinAdapter {
break
}
case 'notify':
switch (data.sub_type) {
switch (data.sub_event) {
case 'poke': {
const content = {
group_id: data.group_id,
Expand Down Expand Up @@ -448,8 +448,8 @@ export class OneBot11 extends KarinAdapter {
* @param {string} remark 拒绝理由(仅在拒绝时有效)
*/
data.approve = async (approve, remark) => {
const { flag, sub_type } = data
let obj = { flag, sub_type, approve, remark }
const { flag, sub_event } = data
let obj = { flag, sub_event, approve, remark }
if (!remark) delete obj.remark
return await this.SendApi('set_group_add_request', obj)
}
Expand Down Expand Up @@ -981,12 +981,12 @@ export class OneBot11 extends KarinAdapter {
/**
* 处理加群请求/邀请
* @param {string} flag - 加群请求的 flag(需从上报的数据中获得)
* @param {string} sub_type - add 或 invite,请求类型(需要和上报消息中的 sub_type 字段相符)
* @param {string} sub_event - add 或 invite,请求类型(需要和上报消息中的 sub_event 字段相符)
* @param {boolean} [approve=true] - 是否同意请求/邀请
* @param {string} [reason=''] - 拒绝理由(仅在拒绝时有效)
*/
async set_group_add_request (flag, sub_type, approve = true, reason = '') {
await this.SendApi('set_group_add_request', { flag, sub_type, approve, reason })
async set_group_add_request (flag, sub_event, approve = true, reason = '') {
await this.SendApi('set_group_add_request', { flag, sub_event, approve, reason })
}

/**
Expand Down
11 changes: 8 additions & 3 deletions lib/bot/KarinElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,24 @@ export class KarinAtElement extends KarinElement {
/**
* 构建一个at元素
* @param {String} uid - 被at的uid 优先使用uid
* @param {Number|String} [uin] - 被at的qq号
* @param {String} [uin] - 被at的uin
* @param {String} [name] - 被at的昵称
*/
constructor (uid, uin) {
constructor (uid, uin, name) {
super()
this.type = 'at'
/**
* @type {String}
*/
this.uid = String(uid)
/**
* @type {Number|String}
* @type {String}
*/
this.uin = uin
/**
* @type {String} 被at的昵称
*/
this.name = name
}

/**
Expand Down
44 changes: 22 additions & 22 deletions lib/bot/KarinEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ export class KarinEvent {
/**
* 构造一个event
* @param {{
* event: 'message'|'request'|'notice',
* self_id: string,
* user_id: string,
* group_id?: string,
* time: number,
* contact: {
* scene: 'group'|'private'|'guild'|'group_temp'|'stranger'|'stranger_group',
* peer: string,
* sub_peer?: string
* },
* sender: {
* uid: string,
* uin: string,
* nick?: string
* },
* sub_type: 'group'|'friend'|'guild'|'group_temp'|'stranger'|'stranger_group'|'friend_poke' | 'friend_recall' | 'friend_file_come' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_banned' | 'group_sign' | 'group_whole_ban' | 'group_file_come'
* }} params
*/
constructor ({ event, self_id, user_id, group_id = '', time, contact, sender, sub_type }) {
* event: 'message'|'request'|'notice',
* self_id: string,
* user_id: string,
* group_id?: string,
* time: number,
* contact: {
* scene: 'group'|'private'|'guild'|'nearby'|'stranger'|'stranger_from_group',
* peer: string,
* sub_peer?: string
* },
* sender: {
* uid: string,
* uin: string,
* nick?: string
* },
* sub_event: 'group'|'friend'|'guild'|'nearby'|'stranger'|'stranger_from_group'|'friend_poke' | 'friend_recall' | 'friend_file_come' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_banned' | 'group_sign' | 'group_whole_ban' | 'group_file_uploaded'
* }} params
*/
constructor ({ event, self_id, user_id, group_id = '', time, contact, sender, sub_event }) {
this.self_id = self_id
this.user_id = user_id
this.group_id = group_id
this.time = time
this.event = event
this.contact = contact
this.sender = sender
this.sub_type = sub_type
this.sub_event = sub_event
}

/**
Expand Down Expand Up @@ -83,9 +83,9 @@ export class KarinEvent {

/**
* 事件类型
* @type {'group'|'friend'|'guild'|'group_temp'|'stranger'|'stranger_group'|'friend_poke' | 'friend_recall' | 'friend_file_come' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_banned' | 'group_sign' | 'group_whole_ban' | 'group_file_come'}
* @type {'group'|'friend'|'guild'|'nearby'|'stranger'|'stranger_from_group'|'friend_poke' | 'friend_recall' | 'friend_file_come' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_banned' | 'group_sign' | 'group_whole_ban' | 'group_file_uploaded'}
*/
sub_type
sub_event

/**
* 是否为主人
Expand Down
2 changes: 1 addition & 1 deletion lib/bot/KarinMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class KarinMessage extends KarinEvent {
file = {},
reply_id = ''
}) {
super({ event: 'message', self_id, user_id, group_id, time, contact, sender, sub_type: contact.scene })
super({ event: 'message', self_id, user_id, group_id, time, contact, sender, sub_event: contact.scene })
this.message_id = message_id
this.message_seq = message_seq
this.raw_message = raw_message
Expand Down
Loading

0 comments on commit 2e18050

Please sign in to comment.