mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-21 22:58:10 +00:00
fix(event): fix chrononeko/bugtracker#74
This commit is contained in:
parent
3d2e17889a
commit
895992ff9e
@ -1,4 +1,9 @@
|
||||
import type { Group, Profile } from '@chronocat/red'
|
||||
|
||||
export const requestMethodMap: Record<string, string> = {}
|
||||
export const emittedBuddyReqList: string[] = []
|
||||
|
||||
export const sendQueue: string[] = []
|
||||
|
||||
export const groupMap: Record<string, Group> = {}
|
||||
export const friendMap: Record<string, Profile> = {}
|
||||
|
@ -4,6 +4,7 @@ import type {
|
||||
OnAddSendMsg,
|
||||
OnBuddyListChange,
|
||||
OnBuddyReqChange,
|
||||
OnGroupListUpdate,
|
||||
OnMemberInfoChange,
|
||||
OnMemberListChange,
|
||||
OnMsgInfoListUpdate,
|
||||
@ -19,7 +20,13 @@ import type {
|
||||
import { ChatType, MsgType, SendType } from '@chronocat/red'
|
||||
import type { ChronocatContext } from '@chronocat/shell'
|
||||
import type { IpcManData } from 'ipcman'
|
||||
import { emittedBuddyReqList, requestMethodMap, sendQueue } from './globalVars'
|
||||
import {
|
||||
emittedBuddyReqList,
|
||||
friendMap,
|
||||
groupMap,
|
||||
requestMethodMap,
|
||||
sendQueue,
|
||||
} from './globalVars'
|
||||
import {
|
||||
FriendRequestDispatchMessage,
|
||||
MessageCreatedDispatchMessage,
|
||||
@ -192,6 +199,15 @@ const dispatcher = async (
|
||||
return
|
||||
}
|
||||
|
||||
case 'onGroupListUpdate':
|
||||
case 'nodeIKernelGroupListener/onGroupListUpdate': {
|
||||
const { groupList } = payload as OnGroupListUpdate
|
||||
|
||||
for (const group of groupList) groupMap[group.groupCode] = group
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'onBuddyListChange':
|
||||
case 'nodeIKernelBuddyListener/onBuddyListChange': {
|
||||
const { data } = payload as OnBuddyListChange
|
||||
@ -199,6 +215,9 @@ const dispatcher = async (
|
||||
for (const category of data) {
|
||||
for (const buddy of category.buddyList) {
|
||||
ctx.chronocat.uix.add(buddy.uid, buddy.uin)
|
||||
|
||||
// buddy.category = category.categoryName
|
||||
friendMap[buddy.uin] = buddy
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import type h from '@satorijs/element'
|
||||
import { Buffer } from 'node:buffer'
|
||||
import type { O } from 'ts-toolbelt'
|
||||
import { parseMsgTypes } from './msgt'
|
||||
import { groupMap } from '../globalVars'
|
||||
|
||||
export const buildParser =
|
||||
(
|
||||
@ -111,7 +112,8 @@ export const parseMessage = async (
|
||||
|
||||
event.channel.type = 0 // ChannelType.TEXT
|
||||
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`
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user