Skip to content

Commit

Permalink
⚡ feat:Complete all notification events
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Apr 8, 2024
1 parent 3fe6676 commit 0c7e206
Show file tree
Hide file tree
Showing 2 changed files with 867 additions and 25 deletions.
176 changes: 161 additions & 15 deletions lib/adapter/kritor/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ import {
KarinImageElement,
KarinTextElement,
KarinReplyElement,
KarinGroupRecallNotice,
KarinFriendPokeNotice,
KarinFriendRecallNotice
KarinFriendRecallNotice,
KarinFriendFileUploadedNotice,
KarinGroupPokeNotice,
KarinGoupCardChangedNotice,
KarinGroupUniqueTitleChangedNotice,
KarinGroupEssenceMessageNotice,
KarinGroupRecallNotice,
KarinGroupMemberIncreasedNotice,
KarinGroupMemberDecreasedNotice,
KarinGroupAdminChangedNotice,
KarinGroupMemberBanNotice,
KarinGroupSignInNotice,
KarinGroupWholeBanNotice,
KarinGroupFileUploadedNotice
} from '../../bot/model.js'
import { logger, Bot, kritor } from '#Karin'
import { KarinMessage } from '../../event/type.js'
Expand Down Expand Up @@ -149,68 +161,202 @@ export class NoticeConverter extends Converter {
}
/** 私聊文件上传 */
case kritor.event.NoticeEvent.NoticeType.FRIEND_FILE_COME: {
// todo
e = new KarinFriendFileUploadedNotice({ self_id, time: data.time, content: data.friend_file_uploaded })
e.raw_message = [
'<friend_file_uploaded',
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'file_id=' + e.content.file_id,
'file_sub_id=' + e.content.file_sub_id,
'file_name=' + e.content.file_name,
'file_size=' + e.content.file_size,
'expire_time=' + e.content.expire_time,
'url=' + e.url,
'>'
].join(' ')
break
}
/** 群头像戳一戳 */
case kritor.event.NoticeEvent.NoticeType.GROUP_POKE: {
// todo
e = new KarinGroupPokeNotice({ self_id, time: data.time, content: data.group_poke })
e.raw_message = [
'<group_poke',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'action=' + e.content.action,
'suffix=' + e.content.suffix,
'action_image=' + e.content.action_image,
'>'
].join(' ')
break
}
/** 群名片改变 */
case kritor.event.NoticeEvent.NoticeType.GROUP_CARD_CHANGED: {
// todo
e = new KarinGoupCardChangedNotice({ self_id, time: data.time, content: data.group_card_changed })
e.raw_message = [
'<group_card_changed',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'new_card=' + e.content.new_card,
'>'
].join(' ')
break
}

/** 群成员专属头衔改变 */
case kritor.event.NoticeEvent.NoticeType.GROUP_MEMBER_UNIQUE_TITLE_CHANGED: {
// todo
e = new KarinGroupUniqueTitleChangedNotice({ self_id, time: data.time, content: data.group_member_unique_title_changed })
e.raw_message = [
'<group_member_unique_title_changed',
'group_id' + e.group_id,
'target=' + e.content.target,
'title=' + e.content.title,
'>'
].join(' ')
break
}
/** 群精华消息改变 */
case kritor.event.NoticeEvent.NoticeType.GROUP_ESSENCE_CHANGED: {
// todo
e = new KarinGroupEssenceMessageNotice({ self_id, time: data.time, content: data.group_essence_changed })
e.raw_message = [
'<group_essence_changed',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'message_id=' + e.content.message_id,
'sub_type=' + e.content.sub_type,
'>'
].join(' ')
break
}
/** 群消息撤回 */
case kritor.event.NoticeEvent.NoticeType.GROUP_RECALL: {
e = new KarinGroupRecallNotice({ self_id, time: data.time, content: data.group_recall })
e.raw_message = `<group_recall operator_uin=${e.sender.operator_uin} operator_uid=${e.sender.operator_uid} target_uin=${e.sender.target_uin} target_uid=${e.sender.target_uid} message_id=${e.message_id}>`
e.raw_message = [
'<group_recall',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'message_id=' + e.content.message_id,
'message_seq=' + e.content.message_seq,
'tip_text=' + e.content.tip_text,
'>'
].join(' ')
break
}
/** 群成员增加 */
case kritor.event.NoticeEvent.NoticeType.GROUP_MEMBER_INCREASE: {
// todo
e = new KarinGroupMemberIncreasedNotice({ self_id, time: data.time, content: data.group_member_increase })
e.raw_message = [
'<group_member_increase',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'type=' + e.content.type,
'>'
].join(' ')
break
}
/** 群成员减少 */
case kritor.event.NoticeEvent.NoticeType.GROUP_MEMBER_DECREASE: {
// todo
e = new KarinGroupMemberDecreasedNotice({ self_id, time: data.time, content: data.group_member_decrease })
e.raw_message = [
'<group_member_decrease',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'type=' + e.content.new_card,
'>'
].join(' ')
break
}
/** 群管理员变动 */
case kritor.event.NoticeEvent.NoticeType.GROUP_ADMIN_CHANGED: {
// todo
e = new KarinGroupAdminChangedNotice({ self_id, time: data.time, content: data.group_admin_change })
e.raw_message = [
'<group_admin_change',
'group_id' + e.group_id,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'is_admin=' + e.content.is_admin,
'>'
].join(' ')
break
}
/** 群成员被禁言 */
case kritor.event.NoticeEvent.NoticeType.GROUP_MEMBER_BANNED: {
// todo
e = new KarinGroupMemberBanNotice({ self_id, time: data.time, content: data.group_member_ban })
e.raw_message = [
'<group_member_ban',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'duration=' + e.content.duration,
'type=' + e.content.type,
'>'
].join(' ')
break
}
/** 群签到 */
case kritor.event.NoticeEvent.NoticeType.GROUP_SIGN: {
// todo
e = new KarinGroupSignInNotice({ self_id, time: data.time, content: data.group_sign_in })
e.raw_message = [
'<group_sign_in',
'group_id' + e.group_id,
'target_uid=' + e.sender.target_uid,
'target_uin=' + e.sender.target_uin,
'action=' + e.content.action,
'suffix=' + e.content.suffix,
'rank_image=' + e.content.rank_image,
'>'
].join(' ')
break
}
/** 群全员禁言 */
case kritor.event.NoticeEvent.NoticeType.GROUP_WHOLE_BAN: {
// todo
e = new KarinGroupWholeBanNotice({ self_id, time: data.time, content: data.group_whole_ban })
e.raw_message = [
'<group_whole_ban',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'is_ban=' + e.content.is_ban,
'>'
].join(' ')
break
}
/** 群文件上传 */
case kritor.event.NoticeEvent.NoticeType.GROUP_FILE_COME: {
// todo
e = new KarinGroupFileUploadedNotice({ self_id, time: data.time, content: data.group_file_uploaded })
e.raw_message = [
'<group_file_uploaded',
'group_id' + e.group_id,
'operator_uid=' + e.sender.operator_uin,
'operator_uid=' + e.sender.operator_uid,
'file_id=' + e.content.file_id,
'file_sub_id=' + e.content.file_sub_id,
'file_name=' + e.content.file_name,
'file_size=' + e.content.file_size,
'expire_time=' + e.content.expire_time,
'url=' + e.url,
'>'
].join(' ')
break
}
}
Expand Down
Loading

0 comments on commit 0c7e206

Please sign in to comment.