mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-02 00:30:25 +00:00
style: 强类型大法
This commit is contained in:
@@ -8,9 +8,9 @@ const SchemaData = Type.Object({
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export class FriendPoke extends GetPacketStatusDepends<Payload, any> {
|
||||
actionName = ActionName.FriendPoke;
|
||||
payloadSchema = SchemaData;
|
||||
export class FriendPoke extends GetPacketStatusDepends<Payload, void> {
|
||||
override actionName = ActionName.FriendPoke;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
await this.core.apis.PacketApi.pkt.operation.FriendPoke(+payload.user_id);
|
||||
|
||||
@@ -13,14 +13,14 @@ const SchemaData = Type.Object({
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export class GetCookies extends OneBotAction<Payload, Response> {
|
||||
actionName = ActionName.GetCookies;
|
||||
payloadSchema = SchemaData;
|
||||
override actionName = ActionName.GetCookies;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const cookiesObject = await this.core.apis.UserApi.getCookies(payload.domain);
|
||||
//把获取到的cookiesObject转换成 k=v; 格式字符串拼接在一起
|
||||
const cookies = Object.entries(cookiesObject).map(([key, value]) => `${key}=${value}`).join('; ');
|
||||
const bkn = cookiesObject?.skey ? this.core.apis.WebApi.getBknFromCookie(cookiesObject) : '';
|
||||
const bkn = cookiesObject?.['skey'] ? this.core.apis.WebApi.getBknFromCookie(cookiesObject) : '';
|
||||
return { cookies, bkn };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ const SchemaData = Type.Object({
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
||||
actionName = ActionName.GetFriendList;
|
||||
payloadSchema = SchemaData;
|
||||
override actionName = ActionName.GetFriendList;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
//全新逻辑
|
||||
|
||||
@@ -10,16 +10,16 @@ const SchemaData = Type.Object({
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class GetRecentContact extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GetRecentContact;
|
||||
payloadSchema = SchemaData;
|
||||
export default class GetRecentContact extends OneBotAction<Payload, unknown> {
|
||||
override actionName = ActionName.GetRecentContact;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload, adapter: string, config: NetworkAdapterConfig) {
|
||||
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
||||
const ret = await this.core.apis.UserApi.getRecentContactListSnapShot(+payload.count);
|
||||
//烘焙消息
|
||||
return await Promise.all(ret.info.changedList.map(async (t) => {
|
||||
const FastMsg = await this.core.apis.MsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
|
||||
if (FastMsg.msgList.length > 0) {
|
||||
if (FastMsg.msgList.length > 0 && FastMsg.msgList[0]) {
|
||||
//扩展ret.info.changedList
|
||||
const lastestMsg = await this.obContext.apis.MsgApi.parseMessage(FastMsg.msgList[0], config.messagePostFormat);
|
||||
return {
|
||||
|
||||
@@ -10,8 +10,8 @@ const SchemaData = Type.Object({
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SendLike extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.SendLike;
|
||||
payloadSchema = SchemaData;
|
||||
override actionName = ActionName.SendLike;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
const qq = payload.user_id.toString();
|
||||
|
||||
@@ -11,8 +11,8 @@ const SchemaData = Type.Object({
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SetFriendAddRequest extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.SetFriendAddRequest;
|
||||
payloadSchema = SchemaData;
|
||||
override actionName = ActionName.SetFriendAddRequest;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
const approve = payload.approve?.toString() !== 'false';
|
||||
|
||||
Reference in New Issue
Block a user