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