fishpi 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/fishpi.min.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var FishPi=(function(e,t,n,r,i,a,o,s){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,ee=Object.getOwnPropertyNames,te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,re=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ee(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ne.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:c(te(e)),re(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e));t=d(t),n=d(n),r=d(r),i=d(i),a=d(a),s=d(s);let f=`fishpi.cn`;function ie(e){f=e}async function p(e){let{url:n,method:r=`get`,headers:i={},data:a}=e;g||(i[`User-Agent`]=`Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36`,i.Referer=`https://${f}/`);let o;o=a instanceof t.default?a:JSON.stringify(a);let s={method:r,headers:i,body:o},c;try{return c=fetch(`https://${f}/${n}`,s).then(e=>e.text()).then(e=>{try{return JSON.parse(e)}catch{return e}}),c}catch(e){if(e.response.status===401)return e.response;throw e}}function ae(e){if(!e||typeof e.attr!=`string`)return e;let t=e.attr.split(`&`);return e.attr={src:e.attr},t.forEach(t=>e.attr[t.split(`=`)[0]]=t.split(`=`)[1]),e.url=`https://${f}/gen?txt=${e.description}&url=${e.attr.src}`,e.icon=`https://${f}/gen?txt=&${e.attr.src}`,e}function m(e){try{let t=JSON.parse(e);return t.list.forEach((e,t,n)=>{n[t]=ae(e)}),t.list}catch{return[]}}function h(e){if(!e)return;let t=e.split(`/`);return{client:t[0],version:t[1]}}let g=typeof window<`u`,_=g?window.WebSocket:a.default.WebSocket,oe=g?class{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),this}off(e,t){let n=this.listeners.get(e);if(n){let e=n.indexOf(t);e>-1&&n.splice(e,1)}return this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n),this}emit(e,...t){let n=this.listeners.get(e);return n&&n.forEach(e=>e(...t)),this}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}}:o.EventEmitter;var v=class e{title=``;content=``;tags=``;commentable=!0;isNotifyFollowers=!1;type=b.Normal;isShowInList=!0;rewardContent;rewardPoint;isAnonymous;offerPoint;static from(t){return Object.assign(new e,t)}toJson(){return{articleTitle:this.title,articleContent:this.content,articleTags:this.tags,articleCommentable:this.commentable,articleNotifyFollowers:this.isNotifyFollowers,articleType:this.type,articleShowInList:this.isShowInList?1:0,articleRewardContent:this.rewardContent,articleRewardPoint:this.rewardPoint,articleAnonymous:this.isAnonymous,articleQnAOfferPoint:this.offerPoint}}},y=class e{articleId=``;isAnonymous=!1;isVisible=!0;content=``;originalId;static from(t){return Object.assign(new e,t)}toJson(){return{articleId:this.articleId,commentAnonymous:this.isAnonymous?1:0,commentVisible:this.isVisible?1:0,commentContent:this.content,commentOriginalCommentId:this.originalId}}};let b=function(e){return e[e.Normal=0]=`Normal`,e[e.Private=1]=`Private`,e[e.Broadcast=2]=`Broadcast`,e[e.Thought=3]=`Thought`,e[e.Question=5]=`Question`,e}({}),se=function(e){return e[e.Public=0]=`Public`,e[e.Private=1]=`Private`,e}({}),x=function(e){return e[e.normal=-1]=`normal`,e[e.up=0]=`up`,e[e.down=1]=`down`,e}({}),S=function(e){return e[e.Yes=0]=`Yes`,e[e.No=1]=`No`,e}({}),C=function(e){return e[e.Normal=0]=`Normal`,e[e.Ban=1]=`Ban`,e[e.Lock=2]=`Lock`,e}({}),ce=function(e){return e.Recent=``,e.Hot=`/hot`,e.Good=`/good`,e.Reply=`/reply`,e.Perfect=`/perfact`,e}({}),le=function(e){return e[e.Voted=0]=`Voted`,e[e.Unvote=-1]=`Unvote`,e}({});var w=class e{oId=``;title=``;description=``;iconPath=``;URI=``;CSS=``;badCnt=0;commentCount=0;followerCount=0;goodCnt=0;referenceCount=0;linkCount=0;seoDesc=``;seoKeywords=``;seoTitle=``;ad=``;isShowSideAd=!0;status=1;static from(t){let n=new e;return n.oId=t.oId,n.title=t.tagTitle,n.description=t.tagDescription,n.iconPath=t.tagIconPath,n.URI=t.tagURI,n.CSS=t.tagCSS,n.badCnt=t.tagBadCnt,n.commentCount=t.tagCommentCount,n.followerCount=t.tagFollowerCount,n.goodCnt=t.tagGoodCnt,n.referenceCount=t.tagReferenceCount,n.linkCount=t.tagLinkCount,n.seoDesc=t.tagSeoDesc,n.seoKeywords=t.tagSeoKeywords,n.seoTitle=t.tagSeoTitle,n.ad=t.tagAd,n.isShowSideAd=t.tagShowSideAd==1,n.status=t.tagStatus,n}},T=class e{online=!1;onlineMinute=0;tags=``;timezone=``;URL=``;latestArticleTime=0;nickname=``;appRole=0;status=0;province=``;currentCheckinStreak=0;userNo=0;avatarURL=``;language=``;usedPoint=0;points=0;commentCount=0;intro=``;oId=``;userName=``;articleCount=0;role=``;sysMetal;mbti=``;static from(t){let n=new e;return n.online=t.userOnlineFlag,n.onlineMinute=t.onlineMinute,n.tags=t.userTags,n.timezone=t.userTimezone,n.URL=t.userURL,n.latestArticleTime=t.userLatestArticleTime,n.nickname=t.userNickname,n.appRole=t.userAppRole,n.status=t.userStatus,n.province=t.userProvince,n.currentCheckinStreak=t.userCurrentCheckinStreak,n.userNo=t.userNo,n.avatarURL=t.userAvatarURL,n.language=t.userLanguage,n.usedPoint=t.userUsedPoint,n.points=t.userPoint,n.commentCount=t.userCommentCount,n.intro=t.userIntro,n.oId=t.oId,n.userName=t.userName,n.articleCount=t.userArticleCount,n.role=t.userRole,t.sysMetal&&(n.sysMetal=t.sysMetal),n.mbti=t.mbti,n}},E=class e{isShowInList=!0;authorId=``;badCnt=0;latestCmtTime=``;goodCnt=0;offerPoint=0;thumbnailURL=``;stickRemains=0;timeAgo=``;updateTime=``;authorName=``;type=b.Normal;isOffered=!1;createTime=``;viewCount=0;authorThumbnail20=``;watchCnt=0;previewContent=``;titleEmoj=``;titleEmojUnicode=``;title=``;authorThumbnail48=``;collectCnt=0;latestCmter=``;tagsContent=``;oId=``;cmtTimeAgo=``;stick=0;tags=[];isAnonymous=!1;thankCnt=0;status=C.Normal;heat=0;isPerfect=!1;authorThumbnail210=``;permalink=``;author=new T;thankedCnt=0;anonymousView=0;viewCntDisplay=``;commentable=!0;isRewarded=!1;rewardedCnt=0;rewardPoint=0;isFollowing=!1;isWatching=!1;isMyArticle=!1;isThanked=!1;audioURL=``;tableOfContents=``;content=``;originalContent=``;img1URL=``;vote=x.normal;authorIntro=``;city=``;authorURL=``;rewardContent=``;pagination;discussionViewable=!0;revisionCount=0;comments;niceComments;static from(t){var n;let r=new e;return r.isShowInList=t.articleShowInList,r.authorId=t.articleAuthorId,r.badCnt=t.articleBadCnt,r.goodCnt=t.articleGoodCnt,r.offerPoint=t.articleQnAOfferPoint,r.thumbnailURL=t.articleThumbnailURL,r.stickRemains=t.articleStickRemains,r.timeAgo=t.timeAgo,r.updateTime=t.articleUpdateTimeStr,r.authorName=t.articleAuthorName,r.type=t.articleType,r.isOffered=t.articleQnAOfferPoint>0,r.createTime=t.articleCreateTimeStr,r.viewCount=t.articleViewCount,r.authorThumbnail20=t.articleAuthorThumbnailURL20,r.watchCnt=t.articleWatchCnt,r.previewContent=t.articlePreviewContent,r.titleEmoj=t.articleTitleEmoj,r.titleEmojUnicode=t.articleTitleEmojUnicode,r.title=t.articleTitle,r.authorThumbnail48=t.articleAuthorThumbnailURL48,r.collectCnt=t.articleCollectCnt,r.latestCmter=t.articleLatestCmterName,r.tagsContent=t.articleTags,r.oId=t.oId,r.cmtTimeAgo=t.cmtTimeAgo,r.stick=t.articleStick,r.tags=((n=t.articleTagObjs)==null?void 0:n.map(e=>w.from(e)))||[],r.latestCmtTime=t.articleLatestCmtTimeStr,r.isAnonymous=t.articleAnonymous,r.thankCnt=t.articleThankCnt,r.status=t.articleStatus,r.heat=t.articleHeat,r.isPerfect=t.articlePerfect,r.authorThumbnail210=t.articleAuthorThumbnailURL210,r.permalink=t.articlePermalink,t.articleAuthor&&(r.author=T.from(t.articleAuthor)),r.thankedCnt=t.thankedCnt,r.anonymousView=t.articleAnonymousView,r.viewCntDisplay=t.articleViewCntDisplayFormat,r.commentable=t.articleCommentable,r.isRewarded=t.rewarded,r.rewardedCnt=t.rewardedCnt,r.rewardPoint=t.articleRewardPoint,r.isFollowing=t.isFollowing,r.isWatching=t.isWatching,r.isMyArticle=t.isMyArticle,r.isThanked=t.thanked,r.audioURL=t.articleAudioURL,r.tableOfContents=t.articleToC,r.content=t.articleContent,r.originalContent=t.articleOriginalContent,r.img1URL=t.articleImg1URL,r.vote=t.articleVote,r.authorIntro=t.articleAuthorIntro,r.city=t.articleCity,r.authorURL=t.articleAuthorURL,r.rewardContent=t.articleRewardContent,t.pagination&&(r.pagination=H.from(t.pagination)),r.discussionViewable=t.discussionViewable,r.revisionCount=t.articleRevisionCount,r.comments=t.articleComments?t.articleComments.map(e=>D.from(e)):void 0,r.niceComments=t.articleNiceComments?t.articleNiceComments.map(e=>D.from(e)):void 0,r}},D=class e{isNice=!1;createTime=``;authorId=``;score=0;authorURL=``;vote=x.normal;revisionCount=0;timeAgo=``;originalId=``;sysMetal=[];goodCnt=0;visible=S.Yes;articleId=``;rewardedCnt=0;sharpURL=``;isAnonymous=!1;replyCnt=0;oId=``;content=``;status=C.Normal;commenter=new T;authorName=``;thankCnt=0;badCnt=0;rewarded=!1;authorThumbnailURL=``;audioURL=``;isOffered=!1;static from(t){let n=new e;return n.isNice=t.commentNice,n.createTime=t.commentCreateTimeStr,n.authorId=t.commentAuthorId,n.score=t.commentScore,n.authorURL=t.commentAuthorURL,n.vote=t.commentVote,n.revisionCount=t.commentRevisionCount,n.timeAgo=t.timeAgo,n.originalId=t.commentOriginalCommentId,t.sysMetal&&(n.sysMetal=t.sysMetal),n.goodCnt=t.commentGoodCnt,n.visible=t.commentVisible,n.articleId=t.commentOnArticleId,n.rewardedCnt=t.rewardedCnt,n.sharpURL=t.commentSharpURL,n.isAnonymous=t.commentAnonymous,n.replyCnt=t.commentReplyCnt,n.oId=t.oId,n.content=t.commentContent,n.status=t.commentStatus,t.commenter&&(n.commenter=T.from(t.commenter)),n.authorName=t.commentAuthorName,n.thankCnt=t.commentThankCnt,n.badCnt=t.commentBadCnt,n.rewarded=t.rewarded,n.authorThumbnailURL=t.commentAuthorThumbnailURL,n.audioURL=t.commentAudioURL,n.isOffered=t.commentQnAOffered==1,n}},O=class e{articles=[];pagination=new H;tag;static from(t){let n=new e;return n.articles=t.articles.map(e=>E.from(e)),n.pagination=H.from(t.pagination),t.tag&&(n.tag=w.from(t.tag)),n}},k=class e{authorName=``;updatedAt=``;oId=``;createAt=``;authorThumbnail=``;timeAgo=``;content=``;city=``;static from(t){let n=new e;return n.authorName=t.breezemoonAuthorName,n.updatedAt=t.breezemoonUpdated,n.oId=t.oId,n.createAt=t.breezemoonCreated,n.authorThumbnail=t.breezemoonAuthorThumbnailURL48,n.timeAgo=t.timeAgo,n.content=t.breezemoonContent,n.city=t.breezemoonCity,n}},A=class e{pagination=new H;breezemoons=[];static from(t){let n=new e;return n.pagination=t.pagination,n.breezemoons=t.breezemoons.map(e=>k.from(e)),n}};let j=function(e){return e.Web=`Web`,e.PC=`PC`,e.Mobile=`Mobile`,e.Windows=`Windows`,e.macOS=`macOS`,e.Linux=`Linux`,e.iOS=`iOS`,e.Android=`Android`,e.IDEA=`IDEA`,e.Chrome=`Chrome`,e.Edge=`Edge`,e.VSCode=`VSCode`,e.Python=`Python`,e.Golang=`Golang`,e.Rust=`Rust`,e.Harmony=`Harmony`,e.CLI=`CLI`,e.Bird=`Bird`,e.IceNet=`IceNet`,e.ElvesOnline=`ElvesOnline`,e.Other=`Other`,e}({});var ue=class{client=j.Other;version=`latest`};let M=function(e){return e.Markdown=`md`,e.HTML=`html`,e}({}),N=function(e){return e[e.Context=0]=`Context`,e[e.Before=1]=`Before`,e[e.After=2]=`After`,e}({}),de=function(e){return e.online=`online`,e.discussChanged=`discussChanged`,e.revoke=`revoke`,e.msg=`msg`,e.redPacket=`redPacket`,e.redPacketStatus=`redPacketStatus`,e.barrager=`barrager`,e.custom=`customMessage`,e}({}),fe=function(e){return e[e.Rock=0]=`Rock`,e[e.Scissors=1]=`Scissors`,e[e.Paper=2]=`Paper`,e}({}),P=function(e){return e.Random=`random`,e.Average=`average`,e.Specify=`specify`,e.Heartbeat=`heartbeat`,e.RockPaperScissors=`rockPaperScissors`,e}({});var pe=class{type=P.Random;money=32;count=1;msg=`摸鱼者,事竟成`;recivers;gesture},F=class e{oId=``;userNo=``;userName=``;userNickname=``;URL=``;city=``;intro=``;online=!1;points=0;role=``;appRole=R.Hack;avatar=``;cardBg=``;following=0;follower=0;onlineMinute=0;canFollow=`hide`;ownedMetal=[];sysMetal=[];mbti=``;get name(){return this.userNickname?`${this.userNickname}(${this.userName})`:this.userName}static from(t){let n=new e;return n.oId=t.oId,n.userNo=t.userNo,n.userName=t.userName,n.userNickname=t.userNickname,n.URL=t.userURL,n.city=t.userCity,n.intro=t.userIntro,n.online=t.userOnlineFlag,n.points=t.userPoint,n.role=t.userRole,n.appRole=t.userAppRole,n.avatar=t.userAvatarURL,n.cardBg=t.cardBg,n.following=t.followingUserCount,n.follower=t.followerCount,n.onlineMinute=t.onlineMinute,n.canFollow=t.canFollow,n.ownedMetal=m(t.allMetalOwned),n.sysMetal=m(t.sysMetal),n.mbti=t.mbti,n}},I=class{url=``;backcolor=``;fontcolor=``;ver=.1;scale=.79;toString(){return`url=${this.url}&backcolor=${this.backcolor}&fontcolor=${this.fontcolor}&ver=${this.ver}&scale=${this.scale}`}},L=class{attr=new I;name=``;description=``;data=``;constructor(e){e&&(this.attr=Object.assign(new I,e.attr),this.name=e.name,this.description=e.description,this.data=e.data)}toUrl(e=!0){let t=`https://${f}/gen?txt=${this.name}&${this.attr.toString()}`;return e||(t=`https://${f}/gen?txt=&${this.attr.toString()}`),t}},me=class extends L{url;icon;enable=!0},he=class{userName=``;userAvatarURL=``;userNameLowerCase=``},ge=class{userName=``;stage=``;time=0};let _e=function(e){return e[e.checkin1day=0]=`checkin1day`,e[e.checkin2days=1]=`checkin2days`,e[e.patchCheckinCard=2]=`patchCheckinCard`,e[e.metalTicket=3]=`metalTicket`,e}({}),ve=function(e){return e.Point=`point`,e.Comment=`commented`,e.Reply=`reply`,e.At=`at`,e.Following=`following`,e.Broadcast=`broadcast`,e.System=`sys-announce`,e}({}),ye=function(e){return e.RefreshNotification=`refreshNotification`,e.ChatUnreadCountRefresh=`chatUnreadCountRefresh`,e.NewIdleChatMessage=`newIdleChatMessage`,e.WarnBroadcast=`warnBroadcast`,e.bzUpdate=`bzUpdate`,e}({}),be=function(e){return e[e.article=0]=`article`,e[e.comment=1]=`comment`,e[e.at=2]=`at`,e[e.commented=3]=`commented`,e[e.followingUser=4]=`followingUser`,e[e.pointCharge=5]=`pointCharge`,e[e.pointTransfer=6]=`pointTransfer`,e[e.pointArticleReward=7]=`pointArticleReward`,e[e.pointCommentThank=8]=`pointCommentThank`,e[e.broadcast=9]=`broadcast`,e[e.pointExchange=10]=`pointExchange`,e[e.abusePointDeduct=11]=`abusePointDeduct`,e[e.pointArticleThank=12]=`pointArticleThank`,e[e.reply=13]=`reply`,e[e.invitecodeUsed=14]=`invitecodeUsed`,e[e.sysAnnounceArticle=15]=`sysAnnounceArticle`,e[e.sysAnnounceNewUser=16]=`sysAnnounceNewUser`,e[e.newFollower=17]=`newFollower`,e[e.invitationLinkUsed=18]=`invitationLinkUsed`,e[e.sysAnnounceRoleChanged=19]=`sysAnnounceRoleChanged`,e[e.followingArticleUpdate=20]=`followingArticleUpdate`,e[e.followingArticleComment=21]=`followingArticleComment`,e[e.pointPerfectArticle=22]=`pointPerfectArticle`,e[e.articleNewFollower=23]=`articleNewFollower`,e[e.articleNewWatcher=24]=`articleNewWatcher`,e[e.commentVoteUp=25]=`commentVoteUp`,e[e.commentVoteDown=26]=`commentVoteDown`,e[e.articleVoteUp=27]=`articleVoteUp`,e[e.articleVoteDown=28]=`articleVoteDown`,e[e.pointCommentAccept=33]=`pointCommentAccept`,e[e.pointReportHandled=36]=`pointReportHandled`,e[e.chatRoomAt=38]=`chatRoomAt`,e[e.redPacket=39]=`redPacket`,e}({}),R=function(e){return e[e.Hack=0]=`Hack`,e[e.Artist=1]=`Artist`,e}({}),z=function(e){return e[e.article=0]=`article`,e[e.comment=1]=`comment`,e[e.user=2]=`user`,e[e.chatroom=3]=`chatroom`,e}({}),B=function(e){return e[e.advertise=0]=`advertise`,e[e.porn=1]=`porn`,e[e.violate=2]=`violate`,e[e.infringement=3]=`infringement`,e[e.attacks=4]=`attacks`,e[e.impersonate=5]=`impersonate`,e[e.advertisingAccount=6]=`advertisingAccount`,e[e.leakPrivacy=7]=`leakPrivacy`,e[e.other=8]=`other`,e}({});var xe=class{username=``;passwd=``;mfaCode=``},Se=class{username=``;phone=``;invitecode;captcha=``},Ce=class{role=``;passwd=``;userId=``;r},we=class{reportDataId=``;reportDataType=z.article;reportType=B.advertise;reportMemo=``},V=class e{oId=``;state=0;userId=``;jointVip=!1;color=``;underline=!1;metal=!1;autoCheckin=0;bold=!1;lvCode=``;expiresAt=0;createdAt=0;updatedAt=0;get isVip(){return this.state===1&&this.expiresAt*1e3>=Date.now()}get vipName(){return this.isVip?this.lvCode.replace(/_YEAR/,`(包年)`).replace(/_MONTH/,`(包月)`):`非会员`}get expireDate(){return new Date(this.expiresAt)}get createDate(){return new Date(this.createdAt)}get updateDate(){return new Date(this.updatedAt)}static from(t){var n,r,i,a,o,s;let c=new e;return c.oId=t.oId||``,c.state=t.state||0,c.userId=t.userId||``,c.jointVip=((n=t.config)==null?void 0:n.jointVip)||!1,c.color=((r=t.config)==null?void 0:r.color)||``,c.underline=((i=t.config)==null?void 0:i.underline)||!1,c.metal=((a=t.config)==null?void 0:a.metal)||!1,c.autoCheckin=((o=t.config)==null?void 0:o.autoCheckin)||0,c.bold=((s=t.config)==null?void 0:s.bold)||!1,c.lvCode=t.lvCode||``,c.expiresAt=t.expiresAt||0,c.createdAt=t.createdAt||0,c.updatedAt=t.updatedAt||0,c}},H=class e{pageCount=0;pageNums=[];static from(t){let n=new e;return n.pageCount=t.paginationPageCount,n.pageNums=t.paginationPageNums,n}},U=class{emitter=new oe;ws=null;rwsOptions={minReconnectionDelay:1e4,maxReconnectionDelay:6e5,reconnectionDelayGrowFactor:1.3,maxRetries:100,connectionTimeout:1e4};constructor(){}reconnect(){return this.ws?new Promise(e=>{!this.ws||this.ws.readyState===_.CONNECTING||(this.ws.reconnect(),this.ws.onopen=t=>{e(this.ws)})}):this.connect()}connect(e=!1){return new Promise(async(t,n)=>this.ws&&!e?t(this.ws):(this.ws&&this.ws.close(),n(Error(`请在子类中实现 connect 方法`))))}on(e,t){return(this.ws==null||this.ws.readyState!==_.OPEN)&&this.connect(),this.emitter.on(e,t)}off(e,t){return e?t?this.emitter.off(e,t):this.emitter.removeAllListeners(e):this.emitter.removeAllListeners()}once(e,t){return this.emitter.once(e,t)}clearListener(e){this.emitter.removeAllListeners(e)}removeListener(e,t){return this.off(e,t)}addListener(e,t){return this.on(e,t)}},W=class extends U{apiKey=``;_discusse=``;_onlines=[];wsTimer=null;client=j.Other;version=`Latest`;constructor(e=``){super(),e&&(this.apiKey=e)}get onlines(){return this._onlines}get discusse(){return this._discusse}set discusse(e){this.send(`[setdiscuss]${e}[/setdiscuss]`).catch(()=>{})}setToken(e){this.apiKey=e,this.redpacket.setToken(e)}setVia(e,t){this.client=e,this.version=t}async history(e=1,t=M.HTML){try{let n=await p({url:`chat-room/more?page=${e}&type=${t}&apiKey=${this.apiKey}`});if(n.code!=0)throw Error(n.msg);return n.data?(n.data.forEach((e,t,n)=>{try{n[t].type=`msg`,n[t].md=n[t].content,n[t].via=h(n[t].client),n[t].sysMetal=m(n[t].sysMetal),n[t].content=JSON.parse(e.content),n[t].content.recivers&&(n[t].content.recivers=JSON.parse(n[t].content.recivers)),n[t].type=n[t].content.msgType}catch{}}),n.data):n}catch(e){throw e}}async get({oId:e,mode:t=N.Context,size:n=25,type:r=M.HTML}){try{let i=await p({url:`chat-room/getMessage?oId=${e}&mode=${t}&size=${n}&type=${r}&apiKey=${this.apiKey}`});if(i.code!=0)throw Error(i.msg);if(!i.data)return i;let a;return i.data.forEach((e,t,n)=>{try{if(n[t].via=h(n[t].client),n[t].sysMetal=m(n[t].sysMetal),a=JSON.parse(e.content),a.msgType!==`redPacket`)return i;a.recivers&&(a.recivers=JSON.parse(a.recivers)),n[t].content=a}catch{}}),i.data}catch(e){throw e}}async revoke(e){let t;try{if(t=await p({url:`chat-room/revoke/${e}`,method:`delete`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async send(e,t,n){let r;try{if(r=await p({url:`chat-room/send`,method:`post`,data:{content:e,client:`${t||this.client}/${n||this.version}`,apiKey:this.apiKey}}),r.code)throw Error(r.msg)}catch(e){throw e}}async barrage(e,t=`#ffffff`){let n;try{if(n=await p({url:`chat-room/send`,method:`post`,data:{content:`[barrager]{\"color\":\"${t}\",\"content\":\"${e}\"}[/barrager]`,apiKey:this.apiKey}}),n.code)throw Error(n.msg)}catch(e){throw e}}async barragePay(){let e;try{if(e=await p({url:`chat-room/barrager/get?apiKey=${this.apiKey}`,method:`get`}),e.code!=0)throw Error(e.msg);let t=e.data.match(/([-0-9]+)(.+)/);return t?{cost:parseInt(t[1]),unit:t[2]}:{cost:20,unit:`积分`}}catch(e){throw e}}async mutes(){let e;try{if(e=await p({url:`chat-room/si-guo-list`,method:`get`}),e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async raw(e){let t;try{if(t=await p({url:`cr/raw/${e}`}),t.code)throw Error(t.msg);return t.replace(/<!--.*?-->/g,``)}catch(e){throw e}}redpacket=new Te(this,this.apiKey);async getNode(){let e;try{var t;if(e=await p({url:`chat-room/node/get?apiKey=${this.apiKey}`,method:`get`}),e.code!=0)throw Error(`获取节点失败:`+e.msg);return{recommend:{node:e.data,name:e.msg,online:((t=e.avaliable.find(t=>t.node===e.data))==null?void 0:t.online)||0},avaliable:e.avaliable}}catch(e){throw e}}async connect(e,t=10){return new Promise(async n=>{let r=``;if(r=e===void 0||e===``||e===!0?await this.getNode().then(e=>e.recommend.node).catch(()=>`wss://${f}/chat-room-channel?apiKey=${this.apiKey}`):e,r.includes(`apiKey=`)||(r+=`${r.includes(`?`)?`&`:`?`}apiKey=${this.apiKey}`),this.ws)return n(this.reconnect());this.ws=new s.default(r,[],{WebSocket:_,...this.rwsOptions,connectionTimeout:1e3*t}),this.ws.onopen=e=>{this.wsTimer&&clearInterval(this.wsTimer),this.wsTimer=setInterval(()=>{var e;(e=this.ws)==null||e.send(`-hb-`)},1e3*60*3),n(e),this.emitter.emit(`open`,e)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data),n=null;switch(t.type){case`online`:this._onlines=t.users,this._discusse=t.discussing,n=this._onlines;break;case`discussChanged`:n=t.newDiscuss,t.type=`discuss`;break;case`revoke`:n=t.oId;break;case`barrager`:{let{barragerContent:e,userAvatarURL:r,userAvatarURL20:i,userNickname:a,barragerColor:o,userName:s,userAvatarURL210:c,userAvatarURL48:l}=t;n={barragerContent:e,userAvatarURL:r,userAvatarURL20:i,userNickname:a,barragerColor:o,userName:s,userAvatarURL210:c,userAvatarURL48:l};break}case`msg`:{let{userOId:e,oId:r,time:i,userName:a,userNickname:o,userAvatarURL:s,content:c,md:l,client:u}=t;try{let e=JSON.parse(c);[`redPacket`,`music`,`weather`].includes(e.msgType)&&(c=e,t.type=e.msgType)}catch{}n={type:t.type,userOId:e,oId:r,time:i,userName:a,userNickname:o,userAvatarURL:s,content:c,md:l,client:u,via:h(u)};break}case`redPacketStatus`:{let{oId:e,count:r,got:i,whoGive:a,whoGot:o}=t;n={oId:e,count:r,got:i,whoGive:a,whoGot:o};break}case`customMessage`:n=t.message,t.type=`custom`;break}this.emitter.emit(t.type,n),this.emitter.emit(`all`,n)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}},Te=class{chatroom;apiKey=``;constructor(e,t){this.chatroom=e,this.apiKey=t}setToken(e){this.apiKey=e}async open(e,t){let n;try{if(n=await p({url:`chat-room/red-packet/open`,method:`post`,data:{oId:e,gesture:t,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n}catch(e){throw e}}async send(e){return await this.chatroom.send(`[redpacket]${JSON.stringify(e)}[/redpacket]`)}},G=class extends U{apiKey=``;constructor(e=``){super(),e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async count(){let e;try{if(e=await p({url:`notifications/unread/count?apiKey=${this.apiKey}`}),e.code!==0)throw Error(e.msg);return e.userNotifyStatus&&(e.userNotifyStatus=e.userNotifyStatus!=0),e}catch(e){throw e}}async list(e){let t;try{if(t=await p({url:`api/getNotifications?apiKey=${this.apiKey}&type=${e}`}),t.code!==0)throw Error(t.msg);return t.data.forEach(e=>(!e.description&&e.content&&(e.description=e.content),e)),t.data}catch(e){throw e}}async makeRead(e){let t;try{if(t=await p({url:`notifications/make-read/${e}?apiKey=${this.apiKey}`}),t.code!==0)throw Error(t.msg)}catch(e){throw e}}async readAll(){let e;try{if(e=await p({url:`notifications/all-read?apiKey=${this.apiKey}`}),e.code!==0)throw Error(e.msg)}catch(e){throw e}}reconnect(){return this.ws?new Promise(e=>{this.ws&&(this.ws.reconnect(),this.ws.onopen=t=>{e(this.ws)})}):this.connect()}connect(e=!1){return new Promise(async(t,n)=>{if(this.ws&&!e)return t(this.ws);if(this.ws&&this.ws.close(),!this.apiKey)return n(Error(`请先设置 API Key`));this.ws=new s.default(`wss://${f}/user-channel?apiKey=${this.apiKey}`,[],{WebSocket:_,connectionTimeout:1e4,maxRetries:10}),this.ws.onopen=e=>{t(this.ws)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data);t.command==`bz-update`&&(t={...t.bz,command:`bzUpdate`}),t.command&&this.emitter.emit(t.command,t)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}},K=class{apiKey=``;emojis=[];constructor(e=``){e&&this.setToken(e)}setToken(e){this.apiKey=e,e&&this.get().then(e=>this.emojis=e).catch(()=>{})}get default(){return{doge:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/doge.png`,trollface:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/trollface.png`,huaji:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/huaji.gif`,octocat:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/octocat.png`,wulian:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/wulian.png`,smile:`https://file.${f}/emoji/graphics/smile.png`,laughing:`https://file.${f}/emoji/graphics/laughing.png`,blush:`https://file.${f}/emoji/graphics/blush.png`,smiley:`https://file.${f}/emoji/graphics/smiley.png`,relaxed:`https://file.${f}/emoji/graphics/relaxed.png`,smirk:`https://file.${f}/emoji/graphics/smirk.png`,heart_eyes:`https://file.${f}/emoji/graphics/heart_eyes.png`,kissing_heart:`https://file.${f}/emoji/graphics/kissing_heart.png`,kissing_closed_eyes:`https://file.${f}/emoji/graphics/kissing_closed_eyes.png`,flushed:`https://file.${f}/emoji/graphics/flushed.png`,relieved:`https://file.${f}/emoji/graphics/relieved.png`,satisfied:`https://file.${f}/emoji/graphics/satisfied.png`,grin:`https://file.${f}/emoji/graphics/grin.png`,wink:`https://file.${f}/emoji/graphics/wink.png`,stuck_out_tongue_winking_eye:`https://file.${f}/emoji/graphics/stuck_out_tongue_winking_eye.png`,stuck_out_tongue_closed_eyes:`https://file.${f}/emoji/graphics/stuck_out_tongue_closed_eyes.png`,grinning:`https://file.${f}/emoji/graphics/grinning.png`,kissing:`https://file.${f}/emoji/graphics/kissing.png`,kissing_smiling_eyes:`https://file.${f}/emoji/graphics/kissing_smiling_eyes.png`,stuck_out_tongue:`https://file.${f}/emoji/graphics/stuck_out_tongue.png`,sleeping:`https://file.${f}/emoji/graphics/sleeping.png`,worried:`https://file.${f}/emoji/graphics/worried.png`,frowning:`https://file.${f}/emoji/graphics/frowning.png`,anguished:`https://file.${f}/emoji/graphics/anguished.png`,open_mouth:`https://file.${f}/emoji/graphics/open_mouth.png`,grimacing:`https://file.${f}/emoji/graphics/grimacing.png`,confused:`https://file.${f}/emoji/graphics/confused.png`,hushed:`https://file.${f}/emoji/graphics/hushed.png`,expressionless:`https://file.${f}/emoji/graphics/expressionless.png`,unamused:`https://file.${f}/emoji/graphics/unamused.png`,sweat_smile:`https://file.${f}/emoji/graphics/sweat_smile.png`,sweat:`https://file.${f}/emoji/graphics/sweat.png`,disappointed_relieved:`https://file.${f}/emoji/graphics/disappointed_relieved.png`,weary:`https://file.${f}/emoji/graphics/weary.png`,pensive:`https://file.${f}/emoji/graphics/pensive.png`,disappointed:`https://file.${f}/emoji/graphics/disappointed.png`,confounded:`https://file.${f}/emoji/graphics/confounded.png`,fearful:`https://file.${f}/emoji/graphics/fearful.png`,cold_sweat:`https://file.${f}/emoji/graphics/cold_sweat.png`,persevere:`https://file.${f}/emoji/graphics/persevere.png`,cry:`https://file.${f}/emoji/graphics/cry.png`,sob:`https://file.${f}/emoji/graphics/sob.png`,joy:`https://file.${f}/emoji/graphics/joy.png`,astonished:`https://file.${f}/emoji/graphics/astonished.png`,scream:`https://file.${f}/emoji/graphics/scream.png`,tired_face:`https://file.${f}/emoji/graphics/tired_face.png`,angry:`https://file.${f}/emoji/graphics/angry.png`,rage:`https://file.${f}/emoji/graphics/rage.png`,triumph:`https://file.${f}/emoji/graphics/triumph.png`,sleepy:`https://file.${f}/emoji/graphics/sleepy.png`,yum:`https://file.${f}/emoji/graphics/yum.png`,mask:`https://file.${f}/emoji/graphics/mask.png`,sunglasses:`https://file.${f}/emoji/graphics/sunglasses.png`,dizzy_face:`https://file.${f}/emoji/graphics/dizzy_face.png`,imp:`https://file.${f}/emoji/graphics/imp.png`,smiling_imp:`https://file.${f}/emoji/graphics/smiling_imp.png`,neutral_face:`https://file.${f}/emoji/graphics/neutral_face.png`,no_mouth:`https://file.${f}/emoji/graphics/no_mouth.png`,innocent:`https://file.${f}/emoji/graphics/innocent.png`,alien:`https://file.${f}/emoji/graphics/alien.png`,yellow_heart:`https://file.${f}/emoji/graphics/yellow_heart.png`,blue_heart:`https://file.${f}/emoji/graphics/blue_heart.png`,purple_heart:`https://file.${f}/emoji/graphics/purple_heart.png`,heart:`https://file.${f}/emoji/graphics/heart.png`,green_heart:`https://file.${f}/emoji/graphics/green_heart.png`,broken_heart:`https://file.${f}/emoji/graphics/broken_heart.png`,heartbeat:`https://file.${f}/emoji/graphics/heartbeat.png`,heartpulse:`https://file.${f}/emoji/graphics/heartpulse.png`,two_hearts:`https://file.${f}/emoji/graphics/two_hearts.png`,revolving_hearts:`https://file.${f}/emoji/graphics/revolving_hearts.png`,cupid:`https://file.${f}/emoji/graphics/cupid.png`,sparkling_heart:`https://file.${f}/emoji/graphics/sparkling_heart.png`,sparkles:`https://file.${f}/emoji/graphics/sparkles.png`,star:`https://file.${f}/emoji/graphics/star.png`,star2:`https://file.${f}/emoji/graphics/star2.png`,dizzy:`https://file.${f}/emoji/graphics/dizzy.png`,boom:`https://file.${f}/emoji/graphics/boom.png`,collision:`https://file.${f}/emoji/graphics/collision.png`,anger:`https://file.${f}/emoji/graphics/anger.png`,exclamation:`https://file.${f}/emoji/graphics/exclamation.png`,question:`https://file.${f}/emoji/graphics/question.png`,grey_exclamation:`https://file.${f}/emoji/graphics/grey_exclamation.png`,grey_question:`https://file.${f}/emoji/graphics/grey_question.png`,zzz:`https://file.${f}/emoji/graphics/zzz.png`,dash:`https://file.${f}/emoji/graphics/dash.png`,sweat_drops:`https://file.${f}/emoji/graphics/sweat_drops.png`,notes:`https://file.${f}/emoji/graphics/notes.png`,musical_note:`https://file.${f}/emoji/graphics/musical_note.png`,fire:`https://file.${f}/emoji/graphics/fire.png`,poop:`https://file.${f}/emoji/graphics/poop.png`,"+1":`https://file.${f}/emoji/graphics/%2B1.png`,thumbsup:`https://file.${f}/emoji/graphics/thumbsup.png`,"-1":`https://file.${f}/emoji/graphics/-1.png`,thumbsdown:`https://file.${f}/emoji/graphics/thumbsdown.png`,ok_hand:`https://file.${f}/emoji/graphics/ok_hand.png`,punch:`https://file.${f}/emoji/graphics/punch.png`,facepunch:`https://file.${f}/emoji/graphics/facepunch.png`,fist:`https://file.${f}/emoji/graphics/fist.png`,v:`https://file.${f}/emoji/graphics/v.png`,wave:`https://file.${f}/emoji/graphics/wave.png`,hand:`https://file.${f}/emoji/graphics/hand.png`,raised_hand:`https://file.${f}/emoji/graphics/raised_hand.png`,open_hands:`https://file.${f}/emoji/graphics/open_hands.png`,point_up:`https://file.${f}/emoji/graphics/point_up.png`,point_down:`https://file.${f}/emoji/graphics/point_down.png`,point_left:`https://file.${f}/emoji/graphics/point_left.png`,point_right:`https://file.${f}/emoji/graphics/point_right.png`,raised_hands:`https://file.${f}/emoji/graphics/raised_hands.png`,pray:`https://file.${f}/emoji/graphics/pray.png`,point_up_2:`https://file.${f}/emoji/graphics/point_up_2.png`,clap:`https://file.${f}/emoji/graphics/clap.png`,muscle:`https://file.${f}/emoji/graphics/muscle.png`,couple:`https://file.${f}/emoji/graphics/couple.png`,family:`https://file.${f}/emoji/graphics/family.png`,two_men_holding_hands:`https://file.${f}/emoji/graphics/two_men_holding_hands.png`,two_women_holding_hands:`https://file.${f}/emoji/graphics/two_women_holding_hands.png`,dancer:`https://file.${f}/emoji/graphics/dancer.png`,dancers:`https://file.${f}/emoji/graphics/dancers.png`,ok_woman:`https://file.${f}/emoji/graphics/ok_woman.png`,no_good:`https://file.${f}/emoji/graphics/no_good.png`,information_desk_person:`https://file.${f}/emoji/graphics/information_desk_person.png`,raising_hand:`https://file.${f}/emoji/graphics/raising_hand.png`,bride_with_veil:`https://file.${f}/emoji/graphics/bride_with_veil.png`,person_with_pouting_face:`https://file.${f}/emoji/graphics/person_with_pouting_face.png`,person_frowning:`https://file.${f}/emoji/graphics/person_frowning.png`,bow:`https://file.${f}/emoji/graphics/bow.png`,couplekiss:`https://file.${f}/emoji/graphics/couplekiss.png`,couple_with_heart:`https://file.${f}/emoji/graphics/couple_with_heart.png`,massage:`https://file.${f}/emoji/graphics/massage.png`,haircut:`https://file.${f}/emoji/graphics/haircut.png`,nail_care:`https://file.${f}/emoji/graphics/nail_care.png`,boy:`https://file.${f}/emoji/graphics/boy.png`,girl:`https://file.${f}/emoji/graphics/girl.png`,woman:`https://file.${f}/emoji/graphics/woman.png`,man:`https://file.${f}/emoji/graphics/man.png`,baby:`https://file.${f}/emoji/graphics/baby.png`,older_woman:`https://file.${f}/emoji/graphics/older_woman.png`,older_man:`https://file.${f}/emoji/graphics/older_man.png`,person_with_blond_hair:`https://file.${f}/emoji/graphics/person_with_blond_hair.png`,man_with_gua_pi_mao:`https://file.${f}/emoji/graphics/man_with_gua_pi_mao.png`,man_with_turban:`https://file.${f}/emoji/graphics/man_with_turban.png`,construction_worker:`https://file.${f}/emoji/graphics/construction_worker.png`,cop:`https://file.${f}/emoji/graphics/cop.png`,angel:`https://file.${f}/emoji/graphics/angel.png`,princess:`https://file.${f}/emoji/graphics/princess.png`,smiley_cat:`https://file.${f}/emoji/graphics/smiley_cat.png`,smile_cat:`https://file.${f}/emoji/graphics/smile_cat.png`,heart_eyes_cat:`https://file.${f}/emoji/graphics/heart_eyes_cat.png`,kissing_cat:`https://file.${f}/emoji/graphics/kissing_cat.png`,smirk_cat:`https://file.${f}/emoji/graphics/smirk_cat.png`,scream_cat:`https://file.${f}/emoji/graphics/scream_cat.png`,crying_cat_face:`https://file.${f}/emoji/graphics/crying_cat_face.png`,joy_cat:`https://file.${f}/emoji/graphics/joy_cat.png`,pouting_cat:`https://file.${f}/emoji/graphics/pouting_cat.png`,japanese_ogre:`https://file.${f}/emoji/graphics/japanese_ogre.png`,japanese_goblin:`https://file.${f}/emoji/graphics/japanese_goblin.png`,see_no_evil:`https://file.${f}/emoji/graphics/see_no_evil.png`,hear_no_evil:`https://file.${f}/emoji/graphics/hear_no_evil.png`,speak_no_evil:`https://file.${f}/emoji/graphics/speak_no_evil.png`,guardsman:`https://file.${f}/emoji/graphics/guardsman.png`,skull:`https://file.${f}/emoji/graphics/skull.png`,feet:`https://file.${f}/emoji/graphics/feet.png`,lips:`https://file.${f}/emoji/graphics/lips.png`,kiss:`https://file.${f}/emoji/graphics/kiss.png`,droplet:`https://file.${f}/emoji/graphics/droplet.png`,ear:`https://file.${f}/emoji/graphics/ear.png`,eyes:`https://file.${f}/emoji/graphics/eyes.png`,nose:`https://file.${f}/emoji/graphics/nose.png`,tongue:`https://file.${f}/emoji/graphics/tongue.png`,love_letter:`https://file.${f}/emoji/graphics/love_letter.png`,bust_in_silhouette:`https://file.${f}/emoji/graphics/bust_in_silhouette.png`,busts_in_silhouette:`https://file.${f}/emoji/graphics/busts_in_silhouette.png`,speech_balloon:`https://file.${f}/emoji/graphics/speech_balloon.png`,thought_balloon:`https://file.${f}/emoji/graphics/thought_balloon.png`}}async get(){let e;try{if(e=await p({url:`api/cloud/get`,method:`post`,data:{gameId:`emojis`,apiKey:this.apiKey}}),e.code)throw Error(e.msg);return this.emojis=JSON.parse(e.data),this.emojis.concat([])}catch(e){throw e}}async set(e){let t;try{if(t=await p({url:`api/cloud/sync`,method:`post`,data:{gameId:`emojis`,data:JSON.stringify(e),apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t}catch(e){throw e}}async append(e){let t=this.emojis.length>0?this.emojis:await this.get();if(t.indexOf(e)>=0)throw Error(`表情包已存在`);return t.push(e),await this.set(t),this.emojis=t,t.concat([])}async remove(e){let t=this.emojis.length>0?this.emojis:await this.get();return t.indexOf(e)<0?t:(t.splice(t.indexOf(e),1),await this.set(t),this.emojis=t,t.concat([]))}async exists(e){return(this.emojis.length>0?this.emojis:await this.get()).indexOf(e)>=0}},q=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async info(){try{let e=await p({url:`api/user?apiKey=${this.apiKey}`});if(e.code!=0)throw Error(e.msg);return e.data&&(e.data.sysMetal=m(e.data.sysMetal)),F.from(e.data)}catch(e){throw e}}async emotions(){let e;try{if(e=await p({url:`users/emotions?apiKey=${this.apiKey}`}),e.code!=0)throw Error(e.msg);return e.data=Object.keys(e.data),e.data}catch(e){throw e}}async liveness(){if(!this.apiKey)return 0;try{let e=await p({url:`user/liveness?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.liveness||0}catch(e){throw e}}async isCheckIn(){if(!this.apiKey)return!1;try{let e=await p({url:`user/checkedIn?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.checkedIn||!1}catch(e){throw e}}async isCollectedLiveness(){if(!this.apiKey)return!1;try{let e=await p({url:`api/activity/is-collected-liveness?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.isCollectedYesterdayLivenessReward||!1}catch(e){throw e}}async rewardLiveness(){if(!this.apiKey)return 0;try{let e=await p({url:`activity/yesterday-liveness-reward-api?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.sum||0}catch(e){throw e}}async transfer(e,t,n){try{let r=await p({method:`POST`,url:`point/transfer`,data:{apiKey:this.apiKey,userName:e,amount:t,memo:n}});if(r.code)throw Error(r.msg)}catch(e){throw e}}async follow(e){let t;try{if(t=await p({url:`follow/user`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unfollow(e){let t;try{if(t=await p({url:`unfollow/user`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async updateUserAvatar(e){let t;try{if(t=await p({url:`api/settings/avatar`,method:`post`,data:{apiKey:this.apiKey,userAvatarURL:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async updateUserInfo(e){let t;try{if(t=await p({url:`api/settings/profiles`,method:`post`,data:{apiKey:this.apiKey,...e}}),t.code)throw Error(t.msg)}catch(e){throw e}}},J=class{apiKey=``;channels={};constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async post(e){let t;try{if(t=await p({url:`article`,method:`post`,data:{...v.from(e).toJson(),apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t.articleId}catch(e){throw e}}async update(e,t){let n;try{if(n=await p({url:`article/${e}`,method:`put`,data:{...v.from(t).toJson(),apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.articleId}catch(e){throw e}}async list({type:e,page:t=1,size:n=20,tag:r}){let i;try{if(i=await p({url:`api/articles/${r?`tag/${r}`:`recent`}${e}?p=${t}&size=${n}&${this.apiKey?`apiKey=${this.apiKey}`:``}`}),i.code)throw Error(i.msg);return O.from(i.data)}catch(e){throw e}}async userArticles({userName:e,page:t=1,size:n=20}){let r;try{if(r=await p({url:`api/user/${e}/articles?p=${t}&size=${n}&${this.apiKey?`apiKey=${this.apiKey}`:``}`}),r.code)throw Error(r.msg);return O.from(r.data)}catch(e){throw e}}async detail(e,t=1){let n;try{if(n=await p({url:`api/article/${e}?apiKey=${this.apiKey}&p=${t}`}),n.code)throw Error(n.msg);return E.from(n.data.article)}catch(e){throw e}}async vote(e,t){let n;try{if(n=await p({url:`vote/${t}/article`,method:`post`,data:{dataId:e,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.type}catch(e){throw e}}async thank(e){let t;try{if(t=await p({url:`article/thank?articleId=${e}`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async follow(e){let t;try{if(t=await p({url:`follow/article`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unfollow(e){let t;try{if(t=await p({url:`unfollow/article`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async watch(e){let t;try{if(t=await p({url:`follow/article-watch`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unwatch(e){let t;try{if(t=await p({url:`unfollow/article-watch`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async reward(e){let t;try{if(t=await p({url:`article/reward?articleId=${e}`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async heat(e){let t;try{if(t=await p({url:`api/article/heat/${e}?apiKey=${this.apiKey}`,method:`get`}),t.code)throw Error(t.msg);return t.articleHeat}catch(e){throw e}}async md(e){let t;try{if(t=await p({url:`api/article/md/${e}?apiKey=${this.apiKey}`}),t.code)throw Error(t.msg);return t}catch(e){throw e}}channel(e,t){return this.channels[e]||(this.channels[e]=new Y(this.apiKey,e,t)),this.channels[e]}},Y=class extends U{apiKey=``;id=``;type=b.Normal;constructor(e,t,n){super(),e&&(this.apiKey=e)}async connect(e){return new Promise(async(t,n)=>this.ws&&!e?t(this.ws):(this.ws&&this.ws.close(),this.apiKey?(this.ws=new s.default(`wss://${f}/article-channel?articleId=${this.id}&articleType=${this.type}&apiKey=${this.apiKey}`,[],{WebSocket:_,connectionTimeout:1e4}),this.ws.onopen=e=>{this.emitter.emit(`open`,e)},this.ws.onmessage=e=>{let t=JSON.parse(e.data);t.type===`articleHeat`?this.emitter.emit(`heat`,t.data):this.emitter.emit(t.type,D.from(t.data))},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)},this.ws):n(Error(`请先设置 API Key`))))}},X=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async send(e){let t;try{if(t=await p({url:`comment`,method:`post`,data:{...y.from(e).toJson(),apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async update(e,t){let n;try{if(n=await p({url:`comment/${e}`,method:`put`,data:{...y.from(t).toJson(),apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.commentContent}catch(e){throw e}}async vote(e,t){let n;try{if(n=await p({url:`vote/${t}/comment`,method:`post`,data:{dataId:e,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.type}catch(e){throw e}}async thank(e){let t;try{if(t=await p({url:`comment/thank`,method:`post`,data:{apiKey:this.apiKey,commentId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async remove(e){let t;try{if(t=await p({url:`comment/${e}/remove`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t.commentId}catch(e){throw e}}},Ee=class extends U{apiKey=``;user=``;constructor(e,t){super(),this.apiKey=t,this.user=e}setToken(e){this.apiKey=e,this.connect(!0)}connect(e=!1){return new Promise(async(t,n)=>{if(this.ws&&!e)return t(this.ws);if(this.ws&&this.ws.close(),!this.user)return n(Error(`请先设置私聊用户名`));if(!this.apiKey)return n(Error(`请先设置 API Key`));this.ws=new s.default(`wss://${f}/chat-channel?apiKey=${this.apiKey}&toUser=${this.user}`,[],{WebSocket:_,connectionTimeout:1e4}),this.ws.onopen=e=>{t(this.ws)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data),n=`data`;t.type==`revoke`&&(n=`revoke`,t=t.data),this.emitter.emit(n,t)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}async send(e){var t;this.ws==null&&await this.connect(),this.user&&((t=this.ws)==null||t.send(e))}close(){var e;(e=this.ws)==null||e.close()}async get({page:e=1,size:t=20,autoRead:n=!0}){if(!this.user)return[];try{let r=await p({url:`chat/get-message?apiKey=${this.apiKey}&toUser=${this.user}&page=${e}&pageSize=${t}`});if(r.code)throw Error(r.msg);return n&&this.markRead(),r.data}catch(e){throw e}}async markRead(){if(this.user)try{let e=await p({url:`chat/mark-as-read?apiKey=${this.apiKey}&fromUser=${this.user}`});if(e.code)throw Error(e.msg)}catch(e){throw e}}},Z=class{apiKey=``;chats={};constructor(e=``){e&&(this.apiKey=e)}channel(e){return this.chats[e]||(this.chats[e]=new Ee(e,this.apiKey)),this.chats[e]}close(e=``){if(e){var t;(t=this.chats[e])==null||t.close(),delete this.chats[e];return}Object.values(this.chats).forEach(e=>e.close()),this.chats={}}setToken(e){this.apiKey=e,Object.values(this.chats).forEach(t=>t.setToken(e))}async list(){try{let e=await p({url:`chat/get-list?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async unread(){try{let e=await p({url:`chat/has-unread?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async revoke(e){try{let t=await p({url:`chat/revoke?apiKey=${this.apiKey}&oId=${e}`});if(t.code)throw Error(t.msg);return t.result}catch(e){throw e}}},Q=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async list(e=1,t=20){try{let n=await p({url:`api/breezemoons?p=${e}&size=${t}`});if(n.code)throw Error(n.msg);return n.breezemoons.map(e=>k.from(e))}catch(e){throw e}}async listByUser(e,t=1,n=20){try{let r=await p({url:`api/user/${e}/breezemoons?p=${t}&size=${n}&apiKey=${this.apiKey}`});if(r.code)throw Error(r.msg);return A.from(r.data)}catch(e){throw e}}async send(e){try{let t=await p({url:`breezemoon`,method:`post`,data:{apiKey:this.apiKey,breezemoonContent:e}});if(t.code)throw Error(t.msg)}catch(e){throw e}}},De=class{goldFingerKey=``;constructor(e){e&&(this.goldFingerKey=e)}setFinger(e){this.goldFingerKey=e}async addMofishScore({userName:e,stage:t,time:n=new Date().getTime()}){let r;try{if(r=await p({url:`api/games/mofish/score`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,stage:t,time:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async queryLatestLoginIP(e){let t;try{if(t=await p({url:`user/query/latest-login-iP`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code)throw Error(t.msg);return t.data}catch(e){throw e}}async addMetal(e,t){let n;t=new L(t);try{if(n=await p({url:`user/edit/give-metal`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,...t,attr:t.attr.toString()}}),n.code)throw Error(n.msg)}catch(e){throw e}}async deleteMetal(e,t){let n;try{if(n=await p({url:`user/edit/remove-metal`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,name:t}}),n.code)throw Error(n.msg)}catch(e){throw e}}async deleteMetalByUserId(e,t){let n;try{if(n=await p({url:`user/edit/remove-metal-by-user-id`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userId:e,name:t}}),n.code)throw Error(n.msg)}catch(e){throw e}}async queryUserBag(e){let t;try{if(t=await p({url:`user/query/items`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code)throw Error(t.msg);return t.data}catch(e){throw e}}async editUserBag(e,t,n){let r;try{if(r=await p({url:`user/edit/items`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,item:t,sum:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async editUserPoints(e,t,n){let r;try{if(r=await p({url:`user/edit/points`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,point:t,memo:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async getLiveness(e){let t;try{if(t=await p({url:`user/liveness`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code!==0)throw Error(t.msg);return t.liveness}catch(e){throw e}}async getYesterDayLivenessReward(e){let t;try{return t=await p({url:`activity/yesterday-liveness-reward-api`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.sum}catch(e){throw e}}},$=class{apiKey=``;chatroom=new W;notice=new G;emoji=new K;account=new q;article=new J;comment=new X;breezemoon=new Q;chat=new Z;constructor(e=``){e&&this.setToken(e)}get version(){return JSON.parse(n.default.readFileSync(r.default.resolve(__dirname,`../package.json`),`utf-8`)).version}async setToken(e){this.apiKey=e,this.chatroom.setToken(this.apiKey),this.notice.setToken(this.apiKey),this.emoji.setToken(this.apiKey),this.account.setToken(this.apiKey),this.article.setToken(this.apiKey),this.comment.setToken(this.apiKey),this.breezemoon.setToken(this.apiKey),this.chat.setToken(this.apiKey)}async setDomain(e){ie(e)}async login(e){try{let t=await p({url:`api/getKey`,method:`post`,data:{nameOrEmail:e.username,userPassword:(0,i.default)(e.passwd),mfaCode:e.mfaCode}});if(t.code!=0)throw Error(t.msg);return this.setToken(t.Key),t.Key}catch(e){throw e}}async preRegister(e){try{let t=await p({url:`register`,method:`post`,data:{userName:e.username,userPhone:e.phone,invitecode:e.invitecode,captcha:e.captcha}});if(t.code!=0)throw Error(t.msg)}catch(e){throw e}}async verify(e){try{let t=await p({url:`verify?code=`+e,method:`get`});if(t.code!=0)throw Error(t.msg);return t.userId}catch(e){throw e}}async register(e){try{let t=await p({url:`register2${e.r?`?r=${e.r}`:``}`,method:`post`,data:{userAppRole:e.role,userPassword:(0,i.default)(e.passwd),userId:e.userId}});if(t.code!=0)throw Error(t.msg)}catch(e){throw e}}async user(e){try{let t=await p({url:`user/${e}${this.apiKey?`?apiKey=${this.apiKey}`:``}`});return t.code&&t.code!==0?void 0:F.from(t)}catch(e){throw e}}async userPoints(e){try{let t=await p({url:`user/${e}/point`});return t.code&&t.code!==0?0:t.data.userPoint}catch(e){throw e}}async userByoId(e){try{let t=await p({url:`api/user/getInfoById?userId=${e}`});return t.code&&t.code!==0?void 0:{...t.data,oId:e}}catch(e){throw e}}async names(e){let t;try{return t=await p({url:`users/names`,method:`post`,data:{name:e}}),t.data||[]}catch(e){throw e}}async recentRegister(){let e;try{return e=await p({url:`api/user/recentReg`,method:`get`}),e.data||[]}catch(e){throw e}}async vipInfo(e){let t;try{if(t=await p({url:`api/membership/${e}`,method:`get`}),t.code!=0)throw Error(t.msg);return t.data.config&&(t.data.config=JSON.parse(t.data.config)),V.from(t.data)}catch(e){throw e}}async report(e){try{let t=await p({url:`report`,method:`post`,data:{apiKey:this.apiKey,...e}});if(t.code!=0)throw Error(t.msg);return t}catch(e){throw e}}async log({page:e=1,pageSize:t=30}){try{let n=await p({url:`/logs/more?page=${e}&pageSize=${t}`,method:`get`});if(n.code!=0)throw Error(n.msg);return n.data}catch(e){throw e}}async upload(e){let i;g?(i=new t.default,e.forEach(e=>i.append(`file[]`,e))):(i=new t.default,e.forEach(e=>i.append(`file[]`,n.default.readFileSync(e.toString()),r.default.basename(e.toString())))),i.append(`apiKey`,this.apiKey);let a;try{if(a=await p({url:`upload`,method:`post`,data:i,headers:g?void 0:i.getHeaders()}),a.code!=0)throw Error(a.msg);return a.data}catch(e){throw e}}generateAuthURL(e){let t=new URL(e).origin;return`https://${f}/openid/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.return_to=${encodeURIComponent(e)}&openid.realm=${encodeURIComponent(t)}&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select`}async authVerify(e){let t={"openid.ns":`http://specs.openid.net/auth/2.0`,"openid.mode":`check_authentication`,"openid.op_endpoint":e[`openid.op_endpoint`],"openid.return_to":e[`openid.return_to`],"openid.identity":e[`openid.identity`],"openid.claimed_id":e[`openid.claimed_id`],"openid.response_nonce":e[`openid.response_nonce`],"openid.assoc_handle":e[`openid.assoc_handle`],"openid.sig":e[`openid.sig`]},n;try{if(n=await p({url:`openid/verify`,method:`post`,data:t}),n.includes(`is_valid:true`)){var r;let t=(r=e[`openid.claimed_id`])==null?void 0:r.split(`/`).pop();return t?await this.userByoId(t):void 0}else return}catch(e){throw e}}};function Oe(e){return new De(e)}return e.Account=xe,e.Article=J,e.ArticleChannel=Y,e.ArticleComment=D,e.ArticleDetail=E,e.ArticleList=O,e.ArticleListType=ce,e.ArticlePost=v,e.ArticleStatus=C,e.ArticleTag=w,e.ArticleType=b,e.AtUser=he,e.Author=T,e.Breezemoon=Q,e.BreezemoonContent=k,e.BreezemoonList=A,e.Chat=Z,e.ChatContentType=M,e.ChatMessageType=N,e.ChatRoom=W,e.ChatRoomMessageType=de,e.ChatRoomSource=ue,e.ClientType=j,e.Comment=X,e.CommentPost=y,e.DataType=be,e.Emoji=K,e.Finger=De,e.FingerTo=Oe,e.FishPi=$,e.default=$,e.GestureType=fe,e.Metal=me,e.MetalAttr=I,e.MetalBase=L,e.MoFishGame=ge,e.Notice=G,e.NoticeCommandType=ye,e.NoticeType=ve,e.Pagination=H,e.PreRegisterInfo=Se,e.PublicStatus=se,e.RedPacketType=P,e.Redpacket=pe,e.RegisterInfo=Ce,e.Report=we,e.ReportDataType=z,e.ReportType=B,e.User=q,e.UserAppRole=R,e.UserBagType=_e,e.UserInfo=F,e.UserVIP=V,e.VoteStatus=x,e.VoteType=le,e.YesNoStatus=S,e})({},form_data,fs,path,js_md5,ws,events,reconnecting_websocket);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fishpi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "A Package to use API of fishpi.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "lib/index.d.mts",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"lib/index*",
|
|
17
|
+
"lib/fishpi.min.js",
|
|
17
18
|
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|