From 2954776539df68d6b6b3ed6e7776655a352dacee Mon Sep 17 00:00:00 2001 From: JerryZRF <858479588@qq.com> Date: Sat, 21 Dec 2024 20:43:15 +0800 Subject: [PATCH 1/3] feat: add `get_clientkey` --- src/onebot/action/extends/GetClientkey.ts | 14 ++ src/onebot/action/index.ts | 2 + src/onebot/action/router.ts | 226 +++++++++++----------- 3 files changed, 131 insertions(+), 111 deletions(-) create mode 100644 src/onebot/action/extends/GetClientkey.ts diff --git a/src/onebot/action/extends/GetClientkey.ts b/src/onebot/action/extends/GetClientkey.ts new file mode 100644 index 00000000..b63cf9ed --- /dev/null +++ b/src/onebot/action/extends/GetClientkey.ts @@ -0,0 +1,14 @@ +import { ActionName } from '@/onebot/action/router'; +import { OneBotAction } from '../OneBotAction'; + +interface GetClientkeyResponse { + clientkey?: string; +} + +export class GetClientkey extends OneBotAction { + actionName = ActionName.GetClientkey; + + async _handle() { + return { clientkey: (await this.core.apis.UserApi.forceFetchClientKey()).clientKey }; + } +} diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index b0475dea..5b659f34 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -102,6 +102,7 @@ import { SendGroupAiRecord } from "@/onebot/action/group/SendGroupAiRecord"; import { GetAiCharacters } from "@/onebot/action/extends/GetAiCharacters"; import { GetGuildList } from './guild/GetGuildList'; import { GetGuildProfile } from './guild/GetGuildProfile'; +import { GetClientkey } from './extends/GetClientKey'; export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) { @@ -123,6 +124,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo new GetGroupRootFiles(obContext, core), new SetGroupSign(obContext, core), new SendGroupSign(obContext, core), + new GetClientkey(obContext, core), // onebot11 new SendLike(obContext, core), new GetMsg(obContext, core), diff --git a/src/onebot/action/router.ts b/src/onebot/action/router.ts index 6376202f..f74f5405 100644 --- a/src/onebot/action/router.ts +++ b/src/onebot/action/router.ts @@ -1,3 +1,5 @@ +import { GetClientkey } from "./extends/GetClientKey"; + export type BaseCheckResult = ValidCheckResult | InvalidCheckResult; export interface ValidCheckResult { @@ -13,134 +15,136 @@ export interface InvalidCheckResult { [k: string | number]: any; } -export const ActionName = { +export const ActionName = { // onebot 11 - SendPrivateMsg : 'send_private_msg', - SendGroupMsg : 'send_group_msg', - SendMsg : 'send_msg', - DeleteMsg : 'delete_msg', - GetMsg : 'get_msg', - GoCQHTTP_GetForwardMsg : 'get_forward_msg', - SendLike : 'send_like', - SetGroupKick : 'set_group_kick', - SetGroupBan : 'set_group_ban', + SendPrivateMsg: 'send_private_msg', + SendGroupMsg: 'send_group_msg', + SendMsg: 'send_msg', + DeleteMsg: 'delete_msg', + GetMsg: 'get_msg', + GoCQHTTP_GetForwardMsg: 'get_forward_msg', + SendLike: 'send_like', + SetGroupKick: 'set_group_kick', + SetGroupBan: 'set_group_ban', // SetGroupAnoymousBan : 'set_group_anonymous_ban', - SetGroupWholeBan : 'set_group_whole_ban', - SetGroupAdmin : 'set_group_admin', + SetGroupWholeBan: 'set_group_whole_ban', + SetGroupAdmin: 'set_group_admin', // SetGroupAnoymous : 'set_group_anonymous', - SetGroupCard : 'set_group_card', - SetGroupName : 'set_group_name', - SetGroupLeave : 'set_group_leave', - SetSpecialTittle : 'set_group_special_title', - SetFriendAddRequest : 'set_friend_add_request', - SetGroupAddRequest : 'set_group_add_request', - GetLoginInfo : 'get_login_info', - GoCQHTTP_GetStrangerInfo : 'get_stranger_info', - GetFriendList : 'get_friend_list', - GetGroupInfo : 'get_group_info', - GetGroupList : 'get_group_list', - GetGroupMemberInfo : 'get_group_member_info', - GetGroupMemberList : 'get_group_member_list', - GetGroupHonorInfo : 'get_group_honor_info', - GetCookies : 'get_cookies', - GetCSRF : 'get_csrf_token', - GetCredentials : 'get_credentials', - GetRecord : 'get_record', - GetImage : 'get_image', - CanSendImage : 'can_send_image', - CanSendRecord : 'can_send_record', - GetStatus : 'get_status', - GetVersionInfo : 'get_version_info', + SetGroupCard: 'set_group_card', + SetGroupName: 'set_group_name', + SetGroupLeave: 'set_group_leave', + SetSpecialTittle: 'set_group_special_title', + SetFriendAddRequest: 'set_friend_add_request', + SetGroupAddRequest: 'set_group_add_request', + GetLoginInfo: 'get_login_info', + GoCQHTTP_GetStrangerInfo: 'get_stranger_info', + GetFriendList: 'get_friend_list', + GetGroupInfo: 'get_group_info', + GetGroupList: 'get_group_list', + GetGroupMemberInfo: 'get_group_member_info', + GetGroupMemberList: 'get_group_member_list', + GetGroupHonorInfo: 'get_group_honor_info', + GetCookies: 'get_cookies', + GetCSRF: 'get_csrf_token', + GetCredentials: 'get_credentials', + GetRecord: 'get_record', + GetImage: 'get_image', + CanSendImage: 'can_send_image', + CanSendRecord: 'can_send_record', + GetStatus: 'get_status', + GetVersionInfo: 'get_version_info', // Reboot : 'set_restart', // CleanCache : 'clean_cache', // go-cqhttp - SetQQProfile : 'set_qq_profile', + SetQQProfile: 'set_qq_profile', // QidianGetAccountInfo : 'qidian_get_account_info', - GoCQHTTP_GetModelShow : '_get_model_show', - GoCQHTTP_SetModelShow : '_set_model_show', - GetOnlineClient : 'get_online_clients', + GoCQHTTP_GetModelShow: '_get_model_show', + GoCQHTTP_SetModelShow: '_set_model_show', + GetOnlineClient: 'get_online_clients', // GetUnidirectionalFriendList : 'get_unidirectional_friend_list', - GoCQHTTP_DeleteFriend : 'delete_friend', + GoCQHTTP_DeleteFriend: 'delete_friend', // DeleteUnidirectionalFriendList : 'delete_unidirectional_friend', - GoCQHTTP_MarkMsgAsRead : 'mark_msg_as_read', - GoCQHTTP_SendGroupForwardMsg : 'send_group_forward_msg', - GoCQHTTP_SendPrivateForwardMsg : 'send_private_forward_msg', - GoCQHTTP_GetGroupMsgHistory : 'get_group_msg_history', - OCRImage : 'ocr_image', - IOCRImage : '.ocr_image', - GetGroupSystemMsg : 'get_group_system_msg', - GoCQHTTP_GetEssenceMsg : 'get_essence_msg_list', - GoCQHTTP_GetGroupAtAllRemain : 'get_group_at_all_remain', - SetGroupPortrait : 'set_group_portrait', - SetEssenceMsg : 'set_essence_msg', - DelEssenceMsg : 'delete_essence_msg', - GoCQHTTP_SendGroupNotice : '_send_group_notice', - GoCQHTTP_GetGroupNotice : '_get_group_notice', - GoCQHTTP_UploadGroupFile : 'upload_group_file', - GOCQHTTP_DeleteGroupFile : 'delete_group_file', - GoCQHTTP_CreateGroupFileFolder : 'create_group_file_folder', - GoCQHTTP_DeleteGroupFileFolder : 'delete_group_folder', - GoCQHTTP_GetGroupFileSystemInfo : 'get_group_file_system_info', - GoCQHTTP_GetGroupRootFiles : 'get_group_root_files', - GoCQHTTP_GetGroupFilesByFolder : 'get_group_files_by_folder', - GOCQHTTP_GetGroupFileUrl : 'get_group_file_url', - GOCQHTTP_UploadPrivateFile : 'upload_private_file', + GoCQHTTP_MarkMsgAsRead: 'mark_msg_as_read', + GoCQHTTP_SendGroupForwardMsg: 'send_group_forward_msg', + GoCQHTTP_SendPrivateForwardMsg: 'send_private_forward_msg', + GoCQHTTP_GetGroupMsgHistory: 'get_group_msg_history', + OCRImage: 'ocr_image', + IOCRImage: '.ocr_image', + GetGroupSystemMsg: 'get_group_system_msg', + GoCQHTTP_GetEssenceMsg: 'get_essence_msg_list', + GoCQHTTP_GetGroupAtAllRemain: 'get_group_at_all_remain', + SetGroupPortrait: 'set_group_portrait', + SetEssenceMsg: 'set_essence_msg', + DelEssenceMsg: 'delete_essence_msg', + GoCQHTTP_SendGroupNotice: '_send_group_notice', + GoCQHTTP_GetGroupNotice: '_get_group_notice', + GoCQHTTP_UploadGroupFile: 'upload_group_file', + GOCQHTTP_DeleteGroupFile: 'delete_group_file', + GoCQHTTP_CreateGroupFileFolder: 'create_group_file_folder', + GoCQHTTP_DeleteGroupFileFolder: 'delete_group_folder', + GoCQHTTP_GetGroupFileSystemInfo: 'get_group_file_system_info', + GoCQHTTP_GetGroupRootFiles: 'get_group_root_files', + GoCQHTTP_GetGroupFilesByFolder: 'get_group_files_by_folder', + GOCQHTTP_GetGroupFileUrl: 'get_group_file_url', + GOCQHTTP_UploadPrivateFile: 'upload_private_file', // GOCQHTTP_ReloadEventFilter : 'reload_event_filter', - GoCQHTTP_DownloadFile : 'download_file', - GoCQHTTP_CheckUrlSafely : 'check_url_safely', - GoCQHTTP_GetWordSlices : '.get_word_slices', - GoCQHTTP_HandleQuickAction : '.handle_quick_operation', + GoCQHTTP_DownloadFile: 'download_file', + GoCQHTTP_CheckUrlSafely: 'check_url_safely', + GoCQHTTP_GetWordSlices: '.get_word_slices', + GoCQHTTP_HandleQuickAction: '.handle_quick_operation', // 以下为扩展napcat扩展 - Unknown : 'unknown', - SharePeer : 'ArkSharePeer', - ShareGroupEx : 'ArkShareGroup', + Unknown: 'unknown', + SharePeer: 'ArkSharePeer', + ShareGroupEx: 'ArkShareGroup', // RebootNormal : 'reboot_normal', //无快速登录重新启动 - GetRobotUinRange : 'get_robot_uin_range', - SetOnlineStatus : 'set_online_status', - GetFriendsWithCategory : 'get_friends_with_category', - SetQQAvatar : 'set_qq_avatar', - GetFile : 'get_file', - ForwardFriendSingleMsg : 'forward_friend_single_msg', - ForwardGroupSingleMsg : 'forward_group_single_msg', - TranslateEnWordToZn : 'translate_en2zh', - SetMsgEmojiLike : 'set_msg_emoji_like', - GoCQHTTP_SendForwardMsg : 'send_forward_msg', - MarkPrivateMsgAsRead : 'mark_private_msg_as_read', - MarkGroupMsgAsRead : 'mark_group_msg_as_read', - GetFriendMsgHistory : 'get_friend_msg_history', - CreateCollection : 'create_collection', - GetCollectionList : 'get_collection_list', - SetLongNick : 'set_self_longnick', - GetRecentContact : 'get_recent_contact', - _MarkAllMsgAsRead : '_mark_all_as_read', - GetProfileLike : 'get_profile_like', - FetchCustomFace : 'fetch_custom_face', - FetchEmojiLike : 'fetch_emoji_like', - SetInputStatus : 'set_input_status', - GetGroupInfoEx : 'get_group_info_ex', - GetGroupIgnoreAddRequest : 'get_group_ignore_add_request', - DelGroupNotice : '_del_group_notice', - FetchUserProfileLike : 'fetch_user_profile_like', - FriendPoke : 'friend_poke', - GroupPoke : 'group_poke', - GetPacketStatus : 'nc_get_packet_status', - GetUserStatus : 'nc_get_user_status', - GetRkey : 'nc_get_rkey', - GetGroupShutList : 'get_group_shut_list', + GetRobotUinRange: 'get_robot_uin_range', + SetOnlineStatus: 'set_online_status', + GetFriendsWithCategory: 'get_friends_with_category', + SetQQAvatar: 'set_qq_avatar', + GetFile: 'get_file', + ForwardFriendSingleMsg: 'forward_friend_single_msg', + ForwardGroupSingleMsg: 'forward_group_single_msg', + TranslateEnWordToZn: 'translate_en2zh', + SetMsgEmojiLike: 'set_msg_emoji_like', + GoCQHTTP_SendForwardMsg: 'send_forward_msg', + MarkPrivateMsgAsRead: 'mark_private_msg_as_read', + MarkGroupMsgAsRead: 'mark_group_msg_as_read', + GetFriendMsgHistory: 'get_friend_msg_history', + CreateCollection: 'create_collection', + GetCollectionList: 'get_collection_list', + SetLongNick: 'set_self_longnick', + GetRecentContact: 'get_recent_contact', + _MarkAllMsgAsRead: '_mark_all_as_read', + GetProfileLike: 'get_profile_like', + FetchCustomFace: 'fetch_custom_face', + FetchEmojiLike: 'fetch_emoji_like', + SetInputStatus: 'set_input_status', + GetGroupInfoEx: 'get_group_info_ex', + GetGroupIgnoreAddRequest: 'get_group_ignore_add_request', + DelGroupNotice: '_del_group_notice', + FetchUserProfileLike: 'fetch_user_profile_like', + FriendPoke: 'friend_poke', + GroupPoke: 'group_poke', + GetPacketStatus: 'nc_get_packet_status', + GetUserStatus: 'nc_get_user_status', + GetRkey: 'nc_get_rkey', + GetGroupShutList: 'get_group_shut_list', - GetGuildList : 'get_guild_list', - GetGuildProfile : 'get_guild_service_profile', + GetGuildList: 'get_guild_list', + GetGuildProfile: 'get_guild_service_profile', - GetGroupIgnoredNotifies : 'get_group_ignored_notifies', + GetGroupIgnoredNotifies: 'get_group_ignored_notifies', - SetGroupSign : "set_group_sign", - SendGroupSign : "send_group_sign", + SetGroupSign: "set_group_sign", + SendGroupSign: "send_group_sign", - GetMiniAppArk : "get_mini_app_ark", + GetMiniAppArk: "get_mini_app_ark", // UploadForwardMsg : "upload_forward_msg", - GetAiRecord : "get_ai_record", - GetAiCharacters : "get_ai_characters", - SendGroupAiRecord : "send_group_ai_record", + GetAiRecord: "get_ai_record", + GetAiCharacters: "get_ai_characters", + SendGroupAiRecord: "send_group_ai_record", + + GetClientkey: "get_clientkey", } as const; From a1700dd503fa411e89263dbf792193e9ebe012f5 Mon Sep 17 00:00:00 2001 From: JerryZRF <858479588@qq.com> Date: Sun, 22 Dec 2024 01:33:42 +0800 Subject: [PATCH 2/3] fix: incorrect import --- src/onebot/action/router.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/onebot/action/router.ts b/src/onebot/action/router.ts index f74f5405..1bbc0d62 100644 --- a/src/onebot/action/router.ts +++ b/src/onebot/action/router.ts @@ -1,5 +1,3 @@ -import { GetClientkey } from "./extends/GetClientKey"; - export type BaseCheckResult = ValidCheckResult | InvalidCheckResult; export interface ValidCheckResult { From b96076b297d240cb3af21b7bbc1fc50ac7f5ddae Mon Sep 17 00:00:00 2001 From: JerryZRF <858479588@qq.com> Date: Sun, 22 Dec 2024 13:28:20 +0800 Subject: [PATCH 3/3] fix: incorrect import --- src/onebot/action/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index 5b659f34..1ce94005 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -102,8 +102,8 @@ import { SendGroupAiRecord } from "@/onebot/action/group/SendGroupAiRecord"; import { GetAiCharacters } from "@/onebot/action/extends/GetAiCharacters"; import { GetGuildList } from './guild/GetGuildList'; import { GetGuildProfile } from './guild/GetGuildProfile'; -import { GetClientkey } from './extends/GetClientKey'; - +import { GetClientkey } from './extends/GetClientkey'; + export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) { const actionHandlers = [