mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: 209
This commit is contained in:
parent
b51ce24d0c
commit
44448895a0
@ -1,4 +1,12 @@
|
||||
import { type Friend, type FriendRequest, type Group, type GroupMember, type SelfInfo } from '../ntqqapi/types'
|
||||
import {
|
||||
CategoryFriend,
|
||||
type Friend,
|
||||
type FriendRequest,
|
||||
type Group,
|
||||
type GroupMember,
|
||||
type SelfInfo,
|
||||
User,
|
||||
} from '../ntqqapi/types'
|
||||
import { type FileCache, type LLOneBotError } from './types'
|
||||
import { NTQQGroupApi } from '../ntqqapi/api/group'
|
||||
import { log } from './utils/log'
|
||||
@ -14,8 +22,8 @@ export const selfInfo: SelfInfo = {
|
||||
}
|
||||
export const WebGroupData = {
|
||||
GroupData: new Map<string, Array<WebApiGroupMember>>(),
|
||||
GroupTime: new Map<string, number>()
|
||||
};
|
||||
GroupTime: new Map<string, number>(),
|
||||
}
|
||||
export let groups: Group[] = []
|
||||
export let friends: Friend[] = []
|
||||
export let friendRequests: Map<number, FriendRequest> = new Map<number, FriendRequest>()
|
||||
@ -53,7 +61,8 @@ export async function getGroup(qq: string): Promise<Group | undefined> {
|
||||
if (group) {
|
||||
groups.push(group)
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return group
|
||||
}
|
||||
@ -111,3 +120,5 @@ export function getUidByUin(uin: string) {
|
||||
}
|
||||
|
||||
export let tempGroupCodeMap: Record<string, string> = {} // peerUid => 群号
|
||||
|
||||
export let rawFriends: CategoryFriend[] = []
|
@ -1,26 +1,26 @@
|
||||
import { BrowserWindow } from 'electron'
|
||||
import { NTQQApiClass, NTQQApiMethod } from './ntcall'
|
||||
import { NTQQMsgApi, sendMessagePool } from './api/msg'
|
||||
import { ChatType, Group, GroupMember, GroupMemberRole, RawMessage, User } from './types'
|
||||
import { CategoryFriend, ChatType, Group, GroupMember, GroupMemberRole, RawMessage, User } from './types'
|
||||
import {
|
||||
deleteGroup,
|
||||
friends,
|
||||
getFriend,
|
||||
getGroupMember,
|
||||
groups,
|
||||
groups, rawFriends,
|
||||
selfInfo,
|
||||
tempGroupCodeMap,
|
||||
uidMaps,
|
||||
} from '../common/data'
|
||||
} from '@/common/data'
|
||||
import { OB11GroupDecreaseEvent } from '../onebot11/event/notice/OB11GroupDecreaseEvent'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { postOb11Event } from '../onebot11/server/post-ob11-event'
|
||||
import { getConfigUtil, HOOK_LOG } from '../common/config'
|
||||
import { getConfigUtil, HOOK_LOG } from '@/common/config'
|
||||
import fs from 'fs'
|
||||
import { dbUtil } from '../common/db'
|
||||
import { dbUtil } from '@/common/db'
|
||||
import { NTQQGroupApi } from './api/group'
|
||||
import { log } from '../common/utils/log'
|
||||
import { isNumeric, sleep } from '../common/utils/helper'
|
||||
import { log } from '@/common/utils'
|
||||
import { isNumeric, sleep } from '@/common/utils'
|
||||
import { OB11Constructor } from '../onebot11/constructor'
|
||||
|
||||
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
||||
@ -380,8 +380,10 @@ registerReceiveHook<{
|
||||
|
||||
// 好友列表变动
|
||||
registerReceiveHook<{
|
||||
data: { categoryId: number; categroyName: string; categroyMbCount: number; buddyList: User[] }[]
|
||||
data:CategoryFriend[]
|
||||
}>(ReceiveCmdS.FRIENDS, (payload) => {
|
||||
rawFriends.length = 0;
|
||||
rawFriends.push(...payload.data);
|
||||
for (const fData of payload.data) {
|
||||
const _friends = fData.buddyList
|
||||
for (let friend of _friends) {
|
||||
|
@ -10,6 +10,7 @@ export interface QQLevel {
|
||||
moonNum: number
|
||||
starNum: number
|
||||
}
|
||||
|
||||
export interface User {
|
||||
uid: string // 加密的字符串
|
||||
uin: string // QQ号
|
||||
@ -72,4 +73,12 @@ export interface SelfInfo extends User {
|
||||
online?: boolean
|
||||
}
|
||||
|
||||
export interface Friend extends User {}
|
||||
export interface Friend extends User {
|
||||
}
|
||||
|
||||
export interface CategoryFriend {
|
||||
categoryId: number;
|
||||
categroyName: string;
|
||||
categroyMbCount: number;
|
||||
buddyList: User[]
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import GetMsg from './msg/GetMsg'
|
||||
import GetLoginInfo from './system/GetLoginInfo'
|
||||
import GetFriendList from './user/GetFriendList'
|
||||
import { GetFriendList, GetFriendWithCategory} from './user/GetFriendList'
|
||||
import GetGroupList from './group/GetGroupList'
|
||||
import GetGroupInfo from './group/GetGroupInfo'
|
||||
import GetGroupMemberList from './group/GetGroupMemberList'
|
||||
@ -58,6 +58,7 @@ export const actionHandlers = [
|
||||
new SetConfigAction(),
|
||||
new GetGroupAddRequest(),
|
||||
new SetQQAvatar(),
|
||||
new GetFriendWithCategory(),
|
||||
// onebot11
|
||||
new SendLike(),
|
||||
new GetMsg(),
|
||||
|
@ -21,6 +21,7 @@ export enum ActionName {
|
||||
SetConfig = 'set_config',
|
||||
Debug = 'llonebot_debug',
|
||||
GetFile = 'get_file',
|
||||
GetFriendsWithCategory = 'get_friends_with_category',
|
||||
// onebot 11
|
||||
SendLike = 'send_like',
|
||||
GetLoginInfo = 'get_login_info',
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { OB11User } from '../../types'
|
||||
import { OB11Constructor } from '../../constructor'
|
||||
import { friends } from '../../../common/data'
|
||||
import { friends, rawFriends } from '@/common/data'
|
||||
import BaseAction from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
import { NTQQFriendApi } from '../../../ntqqapi/api'
|
||||
import { log } from '../../../common/utils'
|
||||
import { NTQQFriendApi } from '@/ntqqapi/api'
|
||||
import { CategoryFriend } from '@/ntqqapi/types'
|
||||
|
||||
interface Payload {
|
||||
no_cache: boolean | string
|
||||
}
|
||||
|
||||
class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
||||
export class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
||||
actionName = ActionName.GetFriendList
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
@ -26,4 +26,11 @@ class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
||||
}
|
||||
}
|
||||
|
||||
export default GetFriendList
|
||||
|
||||
export class GetFriendWithCategory extends BaseAction<void, Array<CategoryFriend>> {
|
||||
actionName = ActionName.GetFriendsWithCategory;
|
||||
|
||||
protected async _handle(payload: void) {
|
||||
return rawFriends;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user