mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
refactor: inline getApiContext()
This commit is contained in:
@@ -24,7 +24,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload): Promise<any> {
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
const NTQQMsgApi = this.CoreContext.apis.MsgApi;
|
||||
const msgId = payload.message_id || payload.id;
|
||||
if (!msgId) {
|
||||
throw Error('message_id is required');
|
||||
|
||||
@@ -28,9 +28,9 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload): Promise<Response> {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
const NTQQFriendApi = this.CoreContext.getApiContext().FriendApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const NTQQMsgApi = this.CoreContext.apis.MsgApi;
|
||||
const NTQQFriendApi = this.CoreContext.apis.FriendApi;
|
||||
//处理参数
|
||||
const uid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||
const MsgCount = payload.count || 20;
|
||||
|
||||
@@ -22,7 +22,7 @@ export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
|
||||
if (!payload.type) {
|
||||
payload.type = WebHonorType.ALL;
|
||||
}
|
||||
const NTQQWebApi = this.CoreContext.getApiContext().WebApi;
|
||||
const NTQQWebApi = this.CoreContext.apis.WebApi;
|
||||
return await NTQQWebApi.getGroupHonorInfo(payload.group_id.toString(), payload.type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload): Promise<Response> {
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
const NTQQMsgApi = this.CoreContext.apis.MsgApi;
|
||||
//处理参数
|
||||
const isReverseOrder = payload.reverseOrder || true;
|
||||
const MsgCount = payload.count || 20;
|
||||
|
||||
@@ -15,7 +15,7 @@ export class GetOnlineClient extends BaseAction<void, Array<any>> {
|
||||
|
||||
async _handle(payload: void) {
|
||||
//注册监听
|
||||
const NTQQSystemApi = this.CoreContext.getApiContext().SystemApi;
|
||||
const NTQQSystemApi = this.CoreContext.apis.SystemApi;
|
||||
NTQQSystemApi.getOnlineDev();
|
||||
await sleep(500);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
||||
|
||||
async _handle(payload: Payload): Promise<OB11User> {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const user_id = payload.user_id.toString();
|
||||
const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id);
|
||||
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
|
||||
|
||||
@@ -22,7 +22,7 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
||||
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
||||
let UploadImage: { id: string, width: number, height: number } | undefined = undefined;
|
||||
if (payload.image) {
|
||||
//公告图逻辑
|
||||
|
||||
@@ -24,8 +24,8 @@ export default class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null>
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async getPeer(payload: Payload): Promise<Peer> {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQFriendApi = this.CoreContext.getApiContext().FriendApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const NTQQFriendApi = this.CoreContext.apis.FriendApi;
|
||||
if (payload.user_id) {
|
||||
const peerUid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||
if (!peerUid) {
|
||||
|
||||
Reference in New Issue
Block a user