mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-25 18:03:40 +00:00
feat(event): implement guild-request
event
This commit is contained in:
parent
660c7d5a7e
commit
d4f322dd4d
@ -139,6 +139,17 @@ export const quitGroup = define<
|
|||||||
]
|
]
|
||||||
>('ns-ntApi-2', 'nodeIKernelGroupService/quitGroup')
|
>('ns-ntApi-2', 'nodeIKernelGroupService/quitGroup')
|
||||||
|
|
||||||
|
export const getSingleScreenNotifies = define<
|
||||||
|
unknown,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
doubt: boolean
|
||||||
|
startSeq: string // '1716209619000000'
|
||||||
|
number: number // 16
|
||||||
|
},
|
||||||
|
]
|
||||||
|
>('ns-ntApi-2', 'nodeIKernelGroupService/getSingleScreenNotifies')
|
||||||
|
|
||||||
export const operateSysNotify = define<
|
export const operateSysNotify = define<
|
||||||
unknown,
|
unknown,
|
||||||
[
|
[
|
||||||
|
@ -2,6 +2,7 @@ import type { Group, Profile } from '@chronocat/red'
|
|||||||
|
|
||||||
export const requestMethodMap: Record<string, string> = {}
|
export const requestMethodMap: Record<string, string> = {}
|
||||||
export const emittedBuddyReqList: string[] = []
|
export const emittedBuddyReqList: string[] = []
|
||||||
|
export const emittedGroupReqList: string[] = []
|
||||||
|
|
||||||
export const sendQueue: string[] = []
|
export const sendQueue: string[] = []
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import type {
|
|||||||
OnBuddyListChange,
|
OnBuddyListChange,
|
||||||
OnBuddyReqChange,
|
OnBuddyReqChange,
|
||||||
OnGroupListUpdate,
|
OnGroupListUpdate,
|
||||||
|
OnGroupSingleScreenNotifies,
|
||||||
OnMemberInfoChange,
|
OnMemberInfoChange,
|
||||||
OnMemberListChange,
|
OnMemberListChange,
|
||||||
OnMsgInfoListUpdate,
|
OnMsgInfoListUpdate,
|
||||||
@ -22,6 +23,7 @@ import type { ChronocatContext } from '@chronocat/shell'
|
|||||||
import type { IpcManData } from 'ipcman'
|
import type { IpcManData } from 'ipcman'
|
||||||
import {
|
import {
|
||||||
emittedBuddyReqList,
|
emittedBuddyReqList,
|
||||||
|
emittedGroupReqList,
|
||||||
friendMap,
|
friendMap,
|
||||||
groupMap,
|
groupMap,
|
||||||
requestMethodMap,
|
requestMethodMap,
|
||||||
@ -29,6 +31,7 @@ import {
|
|||||||
} from './globalVars'
|
} from './globalVars'
|
||||||
import {
|
import {
|
||||||
FriendRequestDispatchMessage,
|
FriendRequestDispatchMessage,
|
||||||
|
GuildRequestDispatchMessage,
|
||||||
MessageCreatedDispatchMessage,
|
MessageCreatedDispatchMessage,
|
||||||
MessageDeletedDispatchMessage,
|
MessageDeletedDispatchMessage,
|
||||||
} from './messages'
|
} from './messages'
|
||||||
@ -208,6 +211,30 @@ const dispatcher = async (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'nodeIKernelGroupListener/onGroupNotifiesUnreadCountUpdated': {
|
||||||
|
// const {} = payload as OnGroupNotifiesUnreadCountUpdated
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'nodeIKernelGroupListener/onGroupSingleScreenNotifies': {
|
||||||
|
const { notifies } = payload as OnGroupSingleScreenNotifies
|
||||||
|
|
||||||
|
for (const notify of notifies) {
|
||||||
|
const uin = ctx.chronocat.uix.getUin(notify.user1.uid)
|
||||||
|
if (!uin) return
|
||||||
|
|
||||||
|
const key = `${notify.group.groupCode}:${uin}:${notify.seq}`
|
||||||
|
if (emittedGroupReqList.includes(key)) return
|
||||||
|
|
||||||
|
emittedGroupReqList.push(key)
|
||||||
|
|
||||||
|
ctx.chronocat.emit(new GuildRequestDispatchMessage(notify, uin))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
case 'onBuddyListChange':
|
case 'onBuddyListChange':
|
||||||
case 'nodeIKernelBuddyListener/onBuddyListChange': {
|
case 'nodeIKernelBuddyListener/onBuddyListChange': {
|
||||||
const { data } = payload as OnBuddyListChange
|
const { data } = payload as OnBuddyListChange
|
||||||
@ -225,8 +252,6 @@ const dispatcher = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'nodeIKernelBuddyListener/onBuddyReqChange': {
|
case 'nodeIKernelBuddyListener/onBuddyReqChange': {
|
||||||
if (channel !== 'IPC_DOWN_2') return
|
|
||||||
|
|
||||||
const { buddyReqs } = payload as OnBuddyReqChange
|
const { buddyReqs } = payload as OnBuddyReqChange
|
||||||
|
|
||||||
buddyReqs.forEach((x) => {
|
buddyReqs.forEach((x) => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { BuddyReq, RedMessage } from '@chronocat/red'
|
import type { BuddyReq, GroupNotify, RedMessage } from '@chronocat/red'
|
||||||
import type {
|
import type {
|
||||||
ChronocatContext,
|
ChronocatContext,
|
||||||
ChronocatLogCurrentConfig,
|
ChronocatLogCurrentConfig,
|
||||||
@ -38,6 +38,46 @@ export class MessageDeletedDispatchMessage implements SatoriDispatchMessage {
|
|||||||
.map((e) => ((e.type = 'message-deleted'), e))
|
.map((e) => ((e.type = 'message-deleted'), e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GuildRequestDispatchMessage implements SatoriDispatchMessage {
|
||||||
|
constructor(
|
||||||
|
private notify: GroupNotify,
|
||||||
|
private uin: string,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
type = 'satori' as const
|
||||||
|
|
||||||
|
toSatori = async (
|
||||||
|
ctx: ChronocatContext,
|
||||||
|
_config: O.Intersect<
|
||||||
|
ChronocatLogCurrentConfig,
|
||||||
|
ChronocatSatoriEventsConfig
|
||||||
|
>,
|
||||||
|
) => {
|
||||||
|
const event: Event = {
|
||||||
|
id: undefined as unknown as number,
|
||||||
|
type: 'guild-request',
|
||||||
|
|
||||||
|
platform: ctx.chronocat.platform,
|
||||||
|
self_id: undefined as unknown as string,
|
||||||
|
timestamp: new Date().getTime(),
|
||||||
|
|
||||||
|
guild: {
|
||||||
|
id: this.notify.group.groupCode,
|
||||||
|
name: this.notify.group.groupName,
|
||||||
|
avatar: `https://p.qlogo.cn/gh/${this.notify.group.groupCode}/${this.notify.group.groupCode}/640`,
|
||||||
|
},
|
||||||
|
|
||||||
|
user: {
|
||||||
|
id: `${this.uin}`,
|
||||||
|
name: this.notify.user1.nickName,
|
||||||
|
avatar: `http://thirdqq.qlogo.cn/headimg_dl?dst_uin=${this.uin}&spec=640`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return [event]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class FriendRequestDispatchMessage implements SatoriDispatchMessage {
|
export class FriendRequestDispatchMessage implements SatoriDispatchMessage {
|
||||||
constructor(
|
constructor(
|
||||||
private buddyReq: BuddyReq,
|
private buddyReq: BuddyReq,
|
||||||
|
@ -180,3 +180,80 @@ export interface MsgsIncludeSelf {
|
|||||||
export interface OnOpenParamChange {
|
export interface OnOpenParamChange {
|
||||||
data: Contact[]
|
data: Contact[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OnGroupNotifiesUnreadCountUpdated {
|
||||||
|
/**
|
||||||
|
* 是否有过滤消息
|
||||||
|
*/
|
||||||
|
doubt: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最旧未读消息 ID
|
||||||
|
*/
|
||||||
|
oldestUnreadSeq: string // '1716209619000000'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 未读消息数
|
||||||
|
*/
|
||||||
|
unreadCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OnGroupSingleScreenNotifies {
|
||||||
|
/**
|
||||||
|
* 是否是过滤消息列表
|
||||||
|
*/
|
||||||
|
doubt: false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页 ID
|
||||||
|
*/
|
||||||
|
nextStartSeq: '0'
|
||||||
|
|
||||||
|
notifies: GroupNotify[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GroupNotify {
|
||||||
|
seq: string // '1716209619000000'
|
||||||
|
|
||||||
|
type: number // 7
|
||||||
|
|
||||||
|
status: number // 1
|
||||||
|
|
||||||
|
group: {
|
||||||
|
groupCode: string
|
||||||
|
groupName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
user1: {
|
||||||
|
uid: string
|
||||||
|
nickName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
user2: {
|
||||||
|
uid: string
|
||||||
|
nickName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
actionUser: {
|
||||||
|
uid: string
|
||||||
|
nickName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
actionTime: string // '0'
|
||||||
|
|
||||||
|
invitationExt: {
|
||||||
|
srcType: number // 0
|
||||||
|
groupCode: string // '0'
|
||||||
|
waitStatus: number // 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证消息
|
||||||
|
*/
|
||||||
|
postscript: string
|
||||||
|
|
||||||
|
repeatSeqs: []
|
||||||
|
|
||||||
|
warningTips: string // '该账号存在风险,请谨慎操作'
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user