mirai-ts
Version:
Mirai TypeScript SDK
2 lines (1 loc) • 21.2 kB
JavaScript
var U=Object.defineProperty;var g=(n,e)=>{for(var t in e)U(n,t,{get:e[t],enumerable:!0})};import de from"node:events";import{createConsola as ye}from"consola";var l={name:"mirai-ts",type:"module",version:"2.4.8",packageManager:"pnpm@9.7.1",description:"Mirai TypeScript SDK",author:{name:"YunYouJun",email:"me@yunyoujun.cn",url:"https://www.yunyoujun.cn"},license:"AGPL-3.0",homepage:"https://www.yunyoujun.cn/mirai-ts/",repository:{type:"git",url:"https://github.com/YunYouJun/mirai-ts"},keywords:["mirai","http","api","sdk","typescript","node","js"],exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"}},main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",files:["dist"],scripts:{build:"tsup src/index.ts",demo:"node demo/index.js","demo:ts":"tsx watch demo/index.ts",dev:"npm run watch",prepare:"husky install",prepublishOnly:"npm run build","docs:build":"typedoc","docs:dev":"cd docs && live-server",lint:"eslint .",mcl:"cd mcl && ./mcl",watch:"tsup src/index.ts --watch",release:"bumpp --commit --push --tag",test:"tsx watch test/index.ts",typecheck:"tsc --noEmit"},dependencies:{axios:"^1.7.4",chalk:"4",consola:"^3.2.3","form-data":"^4.0.0",ws:"^8.18.0"},devDependencies:{"@antfu/eslint-config":"^2.26.0","@types/js-yaml":"^4.0.9","@types/node":"^22.4.0","@types/ws":"^8.5.12",bumpp:"^9.5.1",dotenv:"^16.4.5",eslint:"^9.9.0",husky:"8.0.3","js-yaml":"^4.1.0","lint-staged":"^15.2.9",prettier:"^3.3.3",tsup:"6.7.0",tsx:"^4.17.0",typedoc:"^0.26.5",typescript:"^5.5.4"},"lint-staged":{"*.ts":["eslint --fix"]}};import V from"node:process";import c from"axios";function R(n,e=0){return n&&(c.defaults.baseURL=n),c.defaults.timeout=e,c.interceptors.request.use(t=>t,t=>(V.env.NODE_ENV!=="production"&&console.error(t),Promise.reject(t))),c}import ge from"node:process";import A from"form-data";import le from"ws";import{createConsola as ce}from"consola";var I={};g(I,{includes:()=>C,is:()=>T,isAt:()=>v,isChatMessage:()=>m,match:()=>H,re:()=>B});function T(n,e){return Array.isArray(e)?e.includes(n):n===e}function C(n,e){return Array.isArray(e)?e.every(t=>n.includes(t)):n.includes(e)}function B(n,e){let t=null;typeof e=="string"?t=new RegExp(e):t=new RegExp(e.pattern,e.flags||"i");let s=t.exec(n);return s&&s[0]?s:!1}function H(n,e){return e.re?B(n,e.re):e.is?T(n,e.is):e.includes?C(n,e.includes):!1}function m(n){return!n||!n.type?!1:["FriendMessage","GroupMessage","TempMessage"].includes(n.type)}function v(n,e){if(e)return n.messageChain.some(t=>t.type==="At"&&t.target===e);{let t;return n.messageChain.some(s=>s.type==="At"?(t=s,!0):!1),t||!1}}var d=class{constructor(e){this.api=e}async listen(){let{data:e}=await this.api.axios.post("/cmd",{sessionKey:this.api.sessionKey});return e}async register(e,t,s,r){let{data:i}=await this.api.axios.post("/cmd/register",{sessionKey:this.api.sessionKey,name:e,alias:t,description:s,usage:r});return i}async execute(e){let{data:t}=await this.api.axios.post("/cmd/execute",{sessionKey:this.api.sessionKey,command:[{type:"Plain",text:e.join(" ")}]});return t}};var y=class{constructor(e){this.api=e}async list(e){let{data:t}=await this.api.axios.get("/file/list",{params:{sessionKey:this.api.sessionKey,...e}});return t}async info(e){let{data:t}=await this.api.axios.get("/file/info",{params:{sessionKey:this.api.sessionKey,...e}});return t}async mkdir(e){let{data:t}=await this.api.axios.post("/file/mkdir",{sessionKey:this.api.sessionKey,...e});return t}async delete(e){let{data:t}=await this.api.axios.post("/file/delete",{sessionKey:this.api.sessionKey,...e});return t}async move(e){let{data:t}=await this.api.axios.post("/groupFileMove",{sessionKey:this.api.sessionKey,...e});return t}async rename(e){let{data:t}=await this.api.axios.post("/groupFileRename",{sessionKey:this.api.sessionKey,...e});return t}};var Q=(s=>(s[s.Accept=0]="Accept",s[s.Refuse=1]="Refuse",s[s.RefuseAndBlock=2]="RefuseAndBlock",s))(Q||{}),W=(i=>(i[i.Accept=0]="Accept",i[i.Refuse=1]="Refuse",i[i.Ignore=2]="Ignore",i[i.RefuseAndBlock=3]="RefuseAndBlock",i[i.IgnoreAndBlock=4]="IgnoreAndBlock",i))(W||{}),X=(t=>(t[t.Accept=0]="Accept",t[t.Refuse=1]="Refuse",t))(X||{}),f=class{constructor(e){this.api=e}async _request(e,t,s=""){let{data:r}=await this.api.axios.post(`/resp/${e.type[0].toLowerCase()}${e.type.substring(1)}`,{sessionKey:this.api.sessionKey,eventId:e.eventId,fromId:e.fromId,groupId:e.groupId,operate:t,message:s});return r}newFriendRequest(e,t,s){return this._request(e,t,s)}memberJoinRequest(e,t,s){return this._request(e,t,s)}botInvitedJoinGroupRequest(e,t,s){return this._request(e,t,s)}};var Y=(a=>(a[a.NORMAL=0]="NORMAL",a[a.ERROR_VERIFY_KEY=1]="ERROR_VERIFY_KEY",a[a.BOT_NOT_EXIST=2]="BOT_NOT_EXIST",a[a.SESSION_INVALID=3]="SESSION_INVALID",a[a.SESSION_INACTIVATED=4]="SESSION_INACTIVATED",a[a.TARGET_NOT_EXIST=5]="TARGET_NOT_EXIST",a[a.FILE_NOT_EXIST=6]="FILE_NOT_EXIST",a[a.NO_OPERATION_AUTH=10]="NO_OPERATION_AUTH",a[a.BOT_MUTED=20]="BOT_MUTED",a[a.MESSAGE_TOO_LONG=30]="MESSAGE_TOO_LONG",a[a.WRONG_VISIT=400]="WRONG_VISIT",a[a.ERROR_SERVER=500]="ERROR_SERVER",a))(Y||{}),z=new Map([[0,"\u6B63\u5E38"],[1,"\u9519\u8BEF\u7684 auth key"],[2,"\u6307\u5B9A\u7684 Bot \u4E0D\u5B58\u5728"],[3,"Session \u5931\u6548\u6216\u4E0D\u5B58\u5728"],[4,"Session \u672A\u8BA4\u8BC1(\u672A\u6FC0\u6D3B)"],[5,"\u53D1\u9001\u6D88\u606F\u76EE\u6807\u4E0D\u5B58\u5728(\u6307\u5B9A\u5BF9\u8C61\u4E0D\u5B58\u5728)"],[6,"\u6307\u5B9A\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u51FA\u73B0\u4E8E\u53D1\u9001\u672C\u5730\u56FE\u7247"],[10,"\u65E0\u64CD\u4F5C\u6743\u9650\uFF0C\u6307 Bot \u6CA1\u6709\u5BF9\u5E94\u64CD\u4F5C\u7684\u9650\u6743"],[20,"Bot \u88AB\u7981\u8A00\uFF0C\u6307 Bot \u5F53\u524D\u65E0\u6CD5\u5411\u6307\u5B9A\u7FA4\u53D1\u9001\u6D88\u606F"],[30,"\u6D88\u606F\u8FC7\u957F"],[400,"\u9519\u8BEF\u7684\u8BBF\u95EE\uFF0C\u5982\u53C2\u6570\u9519\u8BEF\u7B49"],[500,"\u670D\u52A1\u5668\u7AEF\u9519\u8BEF\u7684\u54CD\u5E94\uFF08mirai-console/mirai-api-http \u80CC\u9505\uFF09"]]);function P(n){return z.get(n)||"\u672A\u77E5\u7684\u9519\u8BEF"}var E={};g(E,{App:()=>pe,At:()=>ee,AtAll:()=>te,Face:()=>se,FlashImage:()=>re,Image:()=>ne,Json:()=>oe,MusicShare:()=>me,Plain:()=>b,Poke:()=>ue,Quote:()=>Z,Voice:()=>ie,Xml:()=>ae});function Z(n){return{type:"Quote",id:n}}function ee(n){return{type:"At",target:n,display:""}}function te(){return{type:"AtAll"}}function se(n,e=""){return{type:"Face",faceId:n,name:e}}function b(n){return{type:"Plain",text:n}}function ne(n=null,e=null,t=null,s=null){return{type:"Image",imageId:n,url:e,path:t,base64:s}}function re(n=null,e=null,t=null){return{type:"FlashImage",imageId:n,url:e,path:t}}function ie(n=null,e=null,t=null,s=null){return{type:"Voice",voiceId:n,url:e,path:t,base64:s}}function ae(n){return{type:"Xml",xml:n}}function oe(n){return{type:"Json",json:n}}function pe(n){return{type:"App",content:n}}function ue(n){return{type:"Poke",name:n}}function me(n,e,t,s,r,i,o){return{type:"MusicShare",kind:n,title:e,summary:t,jumpUrl:s,pictureUrl:r,musicUrl:i,brief:o}}function M(n){return typeof n=="string"?n=[b(n)]:Array.isArray(n)||(n=[n]),n}var h=class{constructor(e,t){this.mirai=e;this.axios=t;this.setting=this.mirai.mahSetting;let s=this.setting.adapterSettings.ws;this.ws.address=this.mirai.options.ws?.address||`ws://${s.host}:${s.port}`;let r=this.setting.adapterSettings.http;this.http.address=this.mirai.options.http?.address||`http://${r.host}:${r.port}`,this.axios.defaults.baseURL=this.http.address,this.axios.defaults.maxContentLength=Number.POSITIVE_INFINITY,this.axios.defaults.maxBodyLength=Number.POSITIVE_INFINITY,this.command=new d(this),this.file=new y(this),this.resp=new f(this)}setting;sessionKey="";http={address:""};ws={sessionKey:"",address:""};qq=0;verified=!1;command;file;resp;logger=ce().withTag("mirai-api-http");async handleStatusCode(){this.axios.interceptors.response.use(async e=>{if(e.status===200&&e.data){let t=e.data.code,s=P(t);t&&s&&(this.logger.error(`Code ${t}: ${s}`),(t===3||t===4)&&(this.logger.warn("\u6B63\u5728\u5C1D\u8BD5\u91CD\u65B0\u5EFA\u7ACB\u8FDE\u63A5..."),await this.verify(),await this.bind(this.qq)))}return e},e=>(this.logger.error(`\u54CD\u5E94\u5931\u8D25\uFF1A${e.message}`),ge.env.NODE_ENV!=="production"&&console.error(e),Promise.reject(e)))}async about(){let{data:e}=await this.axios.get("/about");return e}async verify(e=this.setting.verifyKey){this.logger.info(`[http] Address: ${this.http.address}`);let{data:t}=await this.axios.post("/verify",{verifyKey:e});return t.code===0&&(this.sessionKey=t.session,this.axios.defaults.headers&&(this.axios.defaults.headers.common.sessionKey=this.sessionKey)),t}async bind(e){this.qq=e;let{data:t}=await this.axios.post("/bind",{sessionKey:this.sessionKey,qq:e});return this.verified=t.code===0,t}async release(e=this.qq){let{data:t}=await this.axios.post("/release",{sessionKey:this.sessionKey,qq:e});return t.code===0&&(this.verified=!1),t}async fetchMessage(e=10){let{data:t}=await this.axios.get("/fetchMessage",{params:{sessionKey:this.sessionKey,count:e}});return t}async fetchLatestMessage(e=10){let{data:t}=await this.axios.get("/fetchLatestMessage",{params:{sessionKey:this.sessionKey,count:e}});return t}async peekMessage(e=10){let{data:t}=await this.axios.get("/peekMessage",{params:{sessionKey:this.sessionKey,count:e}});return t}async peekLatestMessage(e=10){let{data:t}=await this.axios.get("/peekLatestMessage",{params:{sessionKey:this.sessionKey,count:e}});return t}async messageFromId(e,t){let{data:s}=await this.axios.get("/messageFromId",{params:{sessionKey:this.sessionKey,messageId:e,target:t}});return s.code===0?s.data:s}async sendFriendMessage(e,t,s){e=M(e);let r={sessionKey:this.sessionKey,target:t,messageChain:e};s&&(r.quote=s);let{data:i}=await this.axios.post("/sendFriendMessage",r);return i}async sendGroupMessage(e,t,s){e=M(e);let r={sessionKey:this.sessionKey,target:t,messageChain:e};s&&(r.quote=s);let{data:i}=await this.axios.post("/sendGroupMessage",r);return i}async sendTempMessage(e,t,s,r){e=M(e);let i={sessionKey:this.sessionKey,qq:t,group:s,messageChain:e};r&&(i.quote=r);let{data:o}=await this.axios.post("/sendTempMessage",i);return o}async sendImageMessage(e,t,s,r){let{data:i}=await this.axios.post("/sendImageMessage",{sessionKey:this.sessionKey,target:t,qq:s,group:r,urls:e});return i}async uploadImage(e,t){let s=new A;s.append("sessionKey",this.sessionKey),s.append("type",e),s.append("img",t);let{data:r}=await this.axios.post("/uploadImage",s,{headers:s.getHeaders()});return r}async uploadVoice(e,t){let s=new A;s.append("sessionKey",this.sessionKey),s.append("type",e),s.append("voice",t);let{data:r}=await this.axios.post("/uploadVoice",s,{headers:s.getHeaders()});return r}async uploadFileAndSend(e,t,s,r){let i=new A;i.append("sessionKey",this.sessionKey),i.append("type",e),i.append("target",t),i.append("path",s),i.append("file",r);let{data:o}=await this.axios.post("/uploadFileAndSend",i,{headers:i.getHeaders()});return o}async recall(e){if(typeof e!="object"||!e.messageId||!e.target)throw new Error("\u8BF7\u540C\u65F6\u4F20\u5165\u5305\u542B\u6709 messageId \u4E0E target \u7684\u5BF9\u8C61");let t=e.messageId,s=e.target;m(e)&&e.messageChain[0].id&&(t=e.messageChain[0].id,s=e.sender.id);let{data:r}=await this.axios.post("/recall",{sessionKey:this.sessionKey,messageId:t,target:s});return r}async friendList(){let{data:e}=await this.axios.get("/friendList",{params:{sessionKey:this.sessionKey}});return e}async groupList(){let{data:e}=await this.axios.get("/groupList",{params:{sessionKey:this.sessionKey}});return e}async memberList(e){let{data:t}=await this.axios.get("/memberList",{params:{sessionKey:this.sessionKey,target:e}});return t}async botProfile(){let{data:e}=await this.axios.get("/botProfile");return e}async friendProfile(e){let{data:t}=await this.axios.get("/friendProfile",{params:{sessionKey:this.sessionKey,target:e}});return t}async memberProfile(e,t){let{data:s}=await this.axios.get("/memberProfile",{params:{sessionKey:this.sessionKey,target:e,memberId:t}});return s}async muteAll(e){let{data:t}=await this.axios.post("/muteAll",{sessionKey:this.sessionKey,target:e});return t}async unmuteAll(e){let{data:t}=await this.axios.post("/unmuteAll",{sessionKey:this.sessionKey,target:e});return t}async mute(e,t,s=60){let{data:r}=await this.axios.post("/mute",{sessionKey:this.sessionKey,target:e,memberId:t,time:s});return r}async unmute(e,t){let{data:s}=await this.axios.post("/unmute",{sessionKey:this.sessionKey,target:e,memberId:t});return s}async kick(e,t,s="\u60A8\u5DF2\u88AB\u79FB\u51FA\u7FA4\u804A"){let{data:r}=await this.axios.post("/kick",{sessionKey:this.sessionKey,target:e,memberId:t,msg:s});return r}async quit(e){let{data:t}=await this.axios.post("/quit",{sessionKey:this.sessionKey,target:e});return t}async groupConfig(e,t){if(t){let{data:s}=await this.axios.post("/groupConfig",{sessionKey:this.sessionKey,target:e,config:t});return s}else{let{data:s}=await this.axios.get("/groupConfig",{params:{sessionKey:this.sessionKey,target:e}});return s}}async memberInfo(e,t,s){if(s){let{data:r}=await this.axios.post("/memberInfo",{sessionKey:this.sessionKey,target:e,memberId:t,info:s});return r}else{let{data:r}=await this.axios.get("/memberInfo",{params:{sessionKey:this.sessionKey,target:e,memberId:t}});return r}}_buildWsChannel(e,t){let s={message:"\u6D88\u606F",event:"\u4E8B\u4EF6",all:"\u6D88\u606F\u4E0E\u4E8B\u4EF6"};this.logger.info(`[websocket] [${e}](${s[e]}) ${this.ws.address}`);let r=new URLSearchParams;r.append("verifyKey",this.setting.verifyKey),r.append("qq",this.qq.toString());let i=new le(`${this.ws.address}/${e}?${r.toString()}`);this.ws.client=i,i.on("open",()=>{let o=setInterval(()=>i.ping(),this.mirai.options.ws?.heartbeatInterval||6e4);i.on("close",()=>clearInterval(o))}),i.once("message",o=>{let u=JSON.parse(o.toString());u.data.session?(this.ws.sessionKey=u.data.session,this.logger.info(`[ws] Session: ${this.ws.sessionKey}`)):this.logger.error(u)}),i.on("message",o=>{let u=JSON.parse(o.toString());t(u.data)})}message(e){this._buildWsChannel("message",e)}event(e){this._buildWsChannel("event",e)}all(e){this._buildWsChannel("all",e)}async managers(){let{data:e}=await this.axios.get("/managers",{params:{qq:this.qq}});return e}async setEssence(e){let{data:t}=await this.axios.post("/setEssence",{sessionKey:this.sessionKey,target:e});return t}async sendNudge(e,t,s="Group"){let{data:r}=await this.axios.post("/sendNudge",{sessionKey:this.sessionKey,target:e,subject:t,kind:s});return r}};function F(n){let e="";return n.forEach(t=>{t.type==="Plain"&&(e+=t.text)}),e}function S(n){let e=[];if(n.length<900)e.push(n);else{let t=Math.ceil(n.length/800);for(let s=0;s<t;s++){let r=n.slice(s*800,(s+1)*800);e.push(r)}}return e}function q(n,e){n.curMsg=e,m(e)&&(e.plain=F(e.messageChain),e.type==="GroupMessage"&&(e.isAt=t=>v(e,t||n.qq)),e.group=(...t)=>t.includes(e.sender.group.id),e.friend=(...t)=>t.includes(e.sender.id),e.get=t=>{let s=null;return e.messageChain.some(r=>r.type===t?(s=r,!0):!1),s}),e.reply=async(t,s=!1)=>n.reply(t,e,s),e.type==="NewFriendRequestEvent"?e.respond=async(t,s)=>n.api.resp.newFriendRequest(e,t,s):e.type==="MemberJoinRequestEvent"?e.respond=async(t,s)=>n.api.resp.memberJoinRequest(e,t,s):e.type==="BotInvitedJoinGroupRequestEvent"&&(e.respond=async(t,s)=>n.api.resp.botInvitedJoinGroupRequest(e,t,s))}var w={adapters:["http","ws"],enableVerify:!0,verifyKey:"el-psy-congroo",debug:!0,singleMode:!1,cacheSize:4096,adapterSettings:{http:{host:"localhost",port:4859},ws:{host:"localhost",port:4859}}},G={ws:{heartbeatInterval:6e4}};var x=class{mahSetting;options;api;logger=ye().withTag("mirai-ts");axios;qq;verified;active;beforeListener;afterListener;interval;retries;curMsg;eventEmitter=new de.EventEmitter;constructor(e,t){this.mahSetting={...w,...e},this.options={...G,...t},this.axios=R(),this.api=new h(this,this.axios),this.qq=0,this.verified=!1,this.active=!0,this.beforeListener=[],this.afterListener=[],this.interval=200,this.retries=10,this.eventEmitter.setMaxListeners(9999)}async about(){this.logger.info(`Version ${l.version}`),this.logger.info(`Docs: ${l.homepage}`),this.logger.info(`GitHub: ${l.repository.url}`)}async link(e){return this.qq=e,this.api.handleStatusCode(),await this.verify(),await this.bind()}async verify(){let e=await this.api.verify();return e.code===0&&this.logger.info(`[http] Session: ${e.session}`),e}async bind(){let e=await this.api.bind(this.qq);return e.code===0?(this.logger.success("\u9A8C\u8BC1\u6210\u529F"),this.verified=!0):this.logger.error("\u9A8C\u8BC1\u5931\u8D25"),e}async release(){let e=await this.api.release();return e.code===0&&this.logger.success(`\u91CA\u653E ${this.qq} Session: ${this.api.sessionKey}`),e}_adaptMessageForAll(e,t){let s=this.eventEmitter;["FriendMessage","GroupMessage","TempMessage"].forEach(i=>{s[e](i,t)})}on(e,t){let s=this.eventEmitter;if(e==="message")this._adaptMessageForAll("on",t);else try{s.on(e,t)}catch(r){console.error(r)}}once(e,t){let s=this.eventEmitter;if(e==="message")this._adaptMessageForAll("once",t);else try{s.once(e,t)}catch(r){console.error(r)}}off(e,t){let s=this.eventEmitter;if(e==="message")this._adaptMessageForAll("off",t);else try{s.off(e,t)}catch(r){console.error(r)}}async reply(e,t,s=!1){let r=0,i=0,o="friend";switch(m(t)&&s&&t.messageChain[0].type==="Source"&&(r=t.messageChain[0].id),typeof e!="string"&&!Array.isArray(e)&&(e=[e]),t.type){case"TempMessage":return this.api.sendTempMessage(e,t.sender.id,t.sender.group.id,r);case"FriendMessage":o="friend",i=t.sender.id;break;case"GroupMessage":o="group",i=t.sender.group.id;break;case"BotOnlineEvent":case"BotOfflineEventActive":case"BotOfflineEventForce":case"BotOfflineEventDropped":case"BotReloginEvent":o="friend",i=t.qq;break;case"GroupRecallEvent":case"BotGroupPermissionChangeEvent":case"BotJoinGroupEvent":case"GroupNameChangeEvent":case"GroupEntranceAnnouncementChangeEvent":case"GroupMuteAllEvent":case"GroupAllowAnonymousChatEvent":case"GroupAllowConfessTalkEvent":case"GroupAllowMemberInviteEvent":o="group";break;case"MemberJoinEvent":case"MemberLeaveEventKick":case"MemberLeaveEventQuit":case"MemberCardChangeEvent":case"MemberSpecialTitleChangeEvent":case"MemberPermissionChangeEvent":case"MemberMuteEvent":case"MemberUnmuteEvent":o="group",i=t.member.group.id;break;case"MemberJoinRequestEvent":o="group",i=t.groupId;break;case"NudgeEvent":o=t.subject.kind.toLowerCase(),i=t.subject.id;break;default:break}if(typeof e=="string"){let u=S(e);if(u.length>1){let p=[];for await(let D of u){let J=await this._sendMessageByType(o,D,i,r);p.push(J)}return p}}return this._sendMessageByType(o,e,i,r)}_sendMessageByType(e,t,s,r){if(e==="friend")return this.api.sendFriendMessage(t,s,r);if(e==="group")return this.api.sendGroupMessage(t,s,r)}handle(e){q(this,e),this.beforeListener.forEach(t=>{t(e)}),this.active&&this.eventEmitter.emit(e.type,e),this.afterListener.forEach(t=>{t(e)}),delete this.curMsg}before(e){this.beforeListener.push(e)}after(e){this.afterListener.push(e)}listen(){if(this.mahSetting.adapters.includes("ws"))this.api.all(e=>{this.handle(e)});else{let e=0,t=setInterval(()=>{this.api.fetchMessage().then(s=>{let{data:r}=s;r&&r.length&&(e=0,r.forEach(i=>{this.handle(i)}))}).catch(s=>{if(this.logger.error(s.message),e++,e>=this.retries)throw clearInterval(t),new Error(`fetchMessage \u5DF2\u8FDE\u7EED ${this.retries} \u6B21\u672A\u6536\u5230\u4EFB\u4F55\u6D88\u606F\u5185\u5BB9\uFF0C\u629B\u51FA\u5F02\u5E38\u3002`)})},this.interval)}}};var O={};g(O,{card:()=>fe,getInfoByType:()=>K});function K(n){let e={icon:"",name:""};switch(n){case"bilibili":e.name="\u54D4\u54E9\u54D4\u54E9",e.icon="http://miniapp.gtimg.cn/public/appicon/432b76be3a548fc128acaa6c1ec90131_200.jpg";break;default:break}return e}function fe(n){return n.type&&(n=Object.assign(K(n.type),n)),`<?xml version='1.0' encoding='UTF-8' standalone='yes'?><msg templateID="123" url="${n.url}" serviceID="1" action="web" actionData="" a_actionData="" i_actionData="" brief="${n.brief}" flag="0"><item layout="2"><picture cover="${n.cover}"/><title>${n.title}</title><summary>${n.summary}</summary></item><source url="${n.url}" icon="${n.icon}" name="${n.name}" appid="0" action="web" actionData="" a_actionData="tencent0://" i_actionData=""/></msg>`}function at(n,e="friend",t=640){let s=null;return e==="friend"?s=`https://q1.qlogo.cn/g?b=qq&nk=${n}&s=${t}`:e==="group"&&(s=`https://p.qlogo.cn/gh/${n}/${n}/${t}`),s}var Me=(s=>(s.UNKNOWN="UNKNOWN",s.MALE="MALE",s.FEMALE="FEMALE",s))(Me||{});var L={};g(L,{Params:()=>k,Response:()=>N});var k={};var N={};var he={};var xe={};var _;(e=>{let n;(p=>(p.Poke="Poke",p.ShowLove="ShowLove",p.Like="Like",p.Heartbroken="Heartbroken",p.SixSixSix="SixSixSix",p.FangDaZhao="FangDaZhao"))(n=e.PokeName||={})})(_||={});var ve={};var yt=x;export{L as Api,X as BotInvitedJoinGroupRequestOperationType,d as Command,he as Config,xe as Contact,ve as EventType,y as File,W as MemberJoinRequestOperationType,E as Message,_ as MessageType,x as Mirai,h as MiraiApiHttp,Q as NewFriendRequestOperationType,f as Resp,Me as Sex,Y as StatusCode,z as StatusCodeMap,I as check,yt as default,at as getAvatarById,P as getMessageFromStatusCode,O as template,M as toMessageChain};