This commit is contained in:
Il Harper 2024-07-20 15:12:45 +08:00
parent 3d2e17889a
commit 895992ff9e
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
3 changed files with 28 additions and 2 deletions

View File

@ -1,4 +1,9 @@
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 sendQueue: string[] = [] export const sendQueue: string[] = []
export const groupMap: Record<string, Group> = {}
export const friendMap: Record<string, Profile> = {}

View File

@ -4,6 +4,7 @@ import type {
OnAddSendMsg, OnAddSendMsg,
OnBuddyListChange, OnBuddyListChange,
OnBuddyReqChange, OnBuddyReqChange,
OnGroupListUpdate,
OnMemberInfoChange, OnMemberInfoChange,
OnMemberListChange, OnMemberListChange,
OnMsgInfoListUpdate, OnMsgInfoListUpdate,
@ -19,7 +20,13 @@ import type {
import { ChatType, MsgType, SendType } from '@chronocat/red' import { ChatType, MsgType, SendType } from '@chronocat/red'
import type { ChronocatContext } from '@chronocat/shell' import type { ChronocatContext } from '@chronocat/shell'
import type { IpcManData } from 'ipcman' import type { IpcManData } from 'ipcman'
import { emittedBuddyReqList, requestMethodMap, sendQueue } from './globalVars' import {
emittedBuddyReqList,
friendMap,
groupMap,
requestMethodMap,
sendQueue,
} from './globalVars'
import { import {
FriendRequestDispatchMessage, FriendRequestDispatchMessage,
MessageCreatedDispatchMessage, MessageCreatedDispatchMessage,
@ -192,6 +199,15 @@ const dispatcher = async (
return return
} }
case 'onGroupListUpdate':
case 'nodeIKernelGroupListener/onGroupListUpdate': {
const { groupList } = payload as OnGroupListUpdate
for (const group of groupList) groupMap[group.groupCode] = group
return
}
case 'onBuddyListChange': case 'onBuddyListChange':
case 'nodeIKernelBuddyListener/onBuddyListChange': { case 'nodeIKernelBuddyListener/onBuddyListChange': {
const { data } = payload as OnBuddyListChange const { data } = payload as OnBuddyListChange
@ -199,6 +215,9 @@ const dispatcher = async (
for (const category of data) { for (const category of data) {
for (const buddy of category.buddyList) { for (const buddy of category.buddyList) {
ctx.chronocat.uix.add(buddy.uid, buddy.uin) ctx.chronocat.uix.add(buddy.uid, buddy.uin)
// buddy.category = category.categoryName
friendMap[buddy.uin] = buddy
} }
} }

View File

@ -19,6 +19,7 @@ import type h from '@satorijs/element'
import { Buffer } from 'node:buffer' import { Buffer } from 'node:buffer'
import type { O } from 'ts-toolbelt' import type { O } from 'ts-toolbelt'
import { parseMsgTypes } from './msgt' import { parseMsgTypes } from './msgt'
import { groupMap } from '../globalVars'
export const buildParser = export const buildParser =
( (
@ -111,7 +112,8 @@ export const parseMessage = async (
event.channel.type = 0 // ChannelType.TEXT event.channel.type = 0 // ChannelType.TEXT
event.channel.id = event.guild.id = message.peerUid event.channel.id = event.guild.id = message.peerUid
event.channel.name = event.guild.name = message.peerName event.channel.name = event.guild.name =
groupMap[message.peerUid]!.groupName // message.peerName
event.guild.avatar = `https://p.qlogo.cn/gh/${message.peerUid}/${message.peerUid}/640` event.guild.avatar = `https://p.qlogo.cn/gh/${message.peerUid}/${message.peerUid}/640`
break break
} }