mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
refactor: uin - > uid
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { NTQQMsgApi } from '@/core/apis';
|
||||
import { NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
||||
import { ChatType, Peer } from '@/core/entities';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { getUidByUin } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
@@ -21,7 +20,7 @@ type Payload = FromSchema<typeof SchemaData>;
|
||||
class ForwardSingleMsg extends BaseAction<Payload, null> {
|
||||
protected async getTargetPeer(payload: Payload): Promise<Peer> {
|
||||
if (payload.user_id) {
|
||||
const peerUid = getUidByUin(payload.user_id.toString());
|
||||
const peerUid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||
if (!peerUid) {
|
||||
throw new Error(`无法找到私聊对象${payload.user_id}`);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { ChatType, Peer } from '@/core/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQMsgApi } from '@/core/apis';
|
||||
import { getFriend, getUidByUin } from '@/core/data';
|
||||
import { NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
||||
import { getFriend } from '@/core/data';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
user_id: { type: [ 'number' , 'string' ] },
|
||||
group_id: { type: [ 'number' , 'string' ] }
|
||||
user_id: { type: ['number', 'string'] },
|
||||
group_id: { type: ['number', 'string'] }
|
||||
}
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
@@ -18,12 +18,12 @@ type PlayloadType = FromSchema<typeof SchemaData>;
|
||||
class MarkMsgAsRead extends BaseAction<PlayloadType, null> {
|
||||
async getPeer(payload: PlayloadType): Promise<Peer> {
|
||||
if (payload.user_id) {
|
||||
const peerUid = getUidByUin(payload.user_id.toString());
|
||||
const peerUid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||
if (!peerUid) {
|
||||
throw `私聊${payload.user_id}不存在`;
|
||||
}
|
||||
const friend = await getFriend(peerUid);
|
||||
return { chatType: friend ? ChatType.friend: ChatType.temp, peerUid };
|
||||
return { chatType: friend ? ChatType.friend : ChatType.temp, peerUid };
|
||||
}
|
||||
if (!payload.group_id) {
|
||||
throw '缺少参数 group_id 或 user_id';
|
||||
@@ -50,11 +50,11 @@ export class MarkGroupMsgAsRead extends MarkMsgAsRead {
|
||||
}
|
||||
|
||||
|
||||
interface Payload{
|
||||
interface Payload {
|
||||
message_id: number
|
||||
}
|
||||
|
||||
export class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null>{
|
||||
export class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_MarkMsgAsRead;
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
|
||||
@@ -7,9 +7,9 @@ import {
|
||||
OB11PostSendMsg
|
||||
} from '@/onebot11/types';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot11/action/types';
|
||||
import { getFriend, getGroup, getUidByUin } from '@/core/data';
|
||||
import { getFriend, getGroup } from '@/core/data';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { ChatType, ElementType, Group, NTQQMsgApi, Peer, SendMessageElement, } from '@/core';
|
||||
import { ChatType, ElementType, Group, NTQQMsgApi, NTQQUserApi, Peer, SendMessageElement, } from '@/core';
|
||||
import fs from 'node:fs';
|
||||
import { logDebug, logError } from '@/common/utils/log';
|
||||
import { decodeCQCode } from '@/onebot11/cqcode';
|
||||
@@ -93,7 +93,8 @@ async function createContext(payload: OB11PostSendMsg): Promise<{
|
||||
const friend = await getFriend(payload.user_id.toString());
|
||||
if (!friend) {
|
||||
if (ALLOW_SEND_TEMP_MSG) {
|
||||
const tempUid = getUidByUin(payload.user_id.toString());
|
||||
//const tempUid = getUidByUin(payload.user_id.toString());
|
||||
const tempUid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||
if (tempUid) return {
|
||||
peer: {
|
||||
chatType: ChatType.temp,
|
||||
|
||||
Reference in New Issue
Block a user