teletron-ts
Version:
Fast and Flexible Telegram Bot API Framework for Node.js written in TypeScript.
2 lines (1 loc) • 28.5 kB
JavaScript
var L=Object.create;var d=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols,V=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var M=(p,e,t)=>e in p?d(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,a=(p,e)=>{for(var t in e||(e={}))P.call(e,t)&&M(p,t,e[t]);if(C)for(var t of C(e))O.call(e,t)&&M(p,t,e[t]);return p};var A=p=>d(p,"__esModule",{value:!0});var R=(p,e)=>{for(var t in e)d(p,t,{get:e[t],enumerable:!0})},k=(p,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of E(e))!P.call(p,i)&&(t||i!=="default")&&d(p,i,{get:()=>e[i],enumerable:!(n=v(e,i))||n.enumerable});return p},y=(p,e)=>k(A(d(p!=null?L(V(p)):{},"default",!e&&p&&p.__esModule?{get:()=>p.default,enumerable:!0}:{value:p,enumerable:!0})),p),q=(p=>(e,t)=>p&&p.get(e)||(t=k(A({}),e,1),p&&p.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var N={};R(N,{TelegramAPI:()=>_});var T=y(require("eventemitter3")),x=y(require("needle")),u=y(require("mime-types")),S=require("url");var r=class extends Error{constructor(e,t="InitializationError"){super();this.message=`${t} - ${e}`,this.errorCode=t,Error.captureStackTrace(this)}};var _=class{constructor(e){if(this._token=e,!e)throw new r("You must provide an API token","InitializationError");this.endpoint=`https://api.telegram.org/bot${this._token}/`,this.emitter=new T.default}async sendRequest(e,t,n,i){let m=await(await(0,x.default)(e,t,n,i)).body;return m.ok||this.emitter.emit("error",m),m}on(e,t){if(!e)throw new r("You should provide a valid event","Invalid Event");this.emitter.on(e,t)}once(e,t){if(!e)throw new r("You should provide a valid event","Invalid Event");this.emitter.once(e,t)}onMessage(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onMessageCallback=e}onEditedMessage(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onEditedMessageCallback=e}onChannelPost(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onChannelPostCallback=e}onEditedChannelPost(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onEditedChannelPostCallback=e}onCallbackQuery(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onCallbackQueryCallback=e}onInlineQuery(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onInlineQueryCallback=e}onChosenInlineResult(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onChosenInlineResultCallback=e}onShippingQuery(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onShippingQueryCallback=e}onPreCheckoutQuery(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onPreCheckoutQueryCallback=e}onPoll(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onPollCallback=e}onPollAnswer(e){if(typeof e!="function")throw new r(`The paramater callback must be from type 'function', recieved: ${typeof e}`,"Invalid Type");this.onPollAnswerCallback=e}processUpdates(e){e.forEach(t=>{this.offset=t.update_id+1;let n=t.message,i=t.edited_message,s=t.channel_post,m=t.edited_channel_post,l=t.inline_query,c=t.chosen_inline_result,f=t.callback_query,I=t.shipping_query,g=t.pre_checkout_query,b=t.poll,h=t.poll_answer,w=t.chat_join_request;n?(this.emitter.emit("message",n),this.onMessageCallback!==void 0&&this.onMessageCallback(n)):i?(this.emitter.emit("edited_message",i),this.onEditedMessageCallback!==void 0&&this.onEditedMessageCallback(i)):s?(this.emitter.emit("channel_post",s),this.onChannelPostCallback!==void 0&&this.onChannelPostCallback(s)):m?(this.emitter.emit("edited_channel_post",m),this.onEditedChannelPostCallback!==void 0&&this.onEditedChannelPostCallback(m)):f?(this.emitter.emit("callback_query",f),this.onCallbackQueryCallback!==void 0&&this.onCallbackQueryCallback(f)):l?(this.emitter.emit("inline_query",l),this.onInlineQueryCallback!==void 0&&this.onInlineQueryCallback(l)):c?(this.emitter.emit("chosen_inline_result",c),this.onChosenInlineResultCallback!==void 0&&this.onChosenInlineResultCallback(c)):I?(this.emitter.emit("shipping_query",I),this.onShippingQueryCallback!==void 0&&this.onShippingQueryCallback(I)):g?(this.emitter.emit("pre_checkout_query",g),this.onPreCheckoutQueryCallback!==void 0&&this.onPreCheckoutQueryCallback(g)):b?(this.emitter.emit("poll",b),this.onPollCallback!==void 0&&this.onPollCallback(b)):h?(this.emitter.emit("poll_answer",h),this.onPollAnswerCallback!==void 0&&this.onPollAnswerCallback(h)):w&&this.emitter.emit("chat_join_request",w)})}async getUpdates(e){if(!e)return e={},await this.sendRequest("get",this.endpoint+"getUpdates",e);let t=new S.URLSearchParams;for(let[n,i]of Object.entries(e))t.append(n,i);return(await this.sendRequest("post",this.endpoint+"getUpdates",t)).result}startPolling(){this.getUpdates({timeout:10,offset:this.offset}).then(e=>(e!==void 0&&this.processUpdates(e),null)).catch(e=>{throw e}).finally(()=>{this.timeout&&typeof this.timeout.refresh=="function"?this.timeout.refresh():this.timeout=setTimeout(()=>this.startPolling(),100)})}stopPolling(){clearTimeout(this.timeout)}async getMe(){return await(await this.sendRequest("get",this.endpoint+"getMe",{})).result}async sendMessage(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t)throw new r("The parameters 'chatId' and 'text' are required","Missing Parameters");let i=a({chat_id:e,text:t},n);return await(await this.sendRequest("post",this.endpoint+"sendMessage",i)).result}async sendPoll(e,t,n,i){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t||!n)throw new r("The parameters 'chat_id', 'question' and 'answer_options' are required","Missing Parameters");if(typeof n!="object")throw new r("The parameter 'answer_options' must be an array of strings!","Invalid Type");let s=a({chat_id:e,question:t,options:JSON.stringify(n)},i);return await(await this.sendRequest("post",this.endpoint+"sendPoll",s)).result}async forwardMessage(e,t,n,i){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t||!n)throw new r("The parameters 'chat_id', 'from_chat_id' and 'message_id' are required","Missing Parameters");let s=a({chat_id:e,from_chat_id:t,message_id:n},i);return await(await this.sendRequest("post",this.endpoint+"forwardMessage",s)).result}async copyMessage(e,t,n,i){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t||!n)throw new r("The parameters 'chat_id', 'from_chat_id' and 'message_id' are required","Missing Parameters");let s=a({chat_id:e,from_chat_id:t,message_id:n},i);return await(await this.sendRequest("post",this.endpoint+"copyMessage",s)).result}async sendPhoto(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="string"&&typeof t!="object")throw new r("A photo can either be an HTTP URL or an object e.g: {file:'local path to photo'}","Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'photo' are required","Missing Parameters");let i={};typeof t!="string"&&t.file?i=a({chat_id:e,photo:{file:t.file,content_type:t.content_type?t.content_type:u.default.lookup(t.file)}},n):i=a({chat_id:e,photo:t},n);let s;return s=await(await this.sendRequest("post",this.endpoint+"sendPhoto",i,{multipart:!0})).result,s}async sendAudio(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="string"&&typeof t!="object")throw new r("An audio can either be an HTTP URL or an object e.g: {file:'local path to audio'}","Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'audio' are required","Missing Parameters");let i={};typeof t!="string"&&t.file?i=a({chat_id:e,audio:{file:t.file,content_type:t.content_type?t.content_type:u.default.lookup(t.file)}},n):i=a({chat_id:e,audio:t},n);let s;return s=await(await this.sendRequest("post",this.endpoint+"sendAudio",i,{multipart:!0})).result,s}async sendVideo(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="string"&&typeof t!="object")throw new r("A video can either be an HTTP URL or an object e.g: {file:'local path to video'}","Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'video' are required","Missing Parameters");let i={};typeof t!="string"&&t.file?i=a({chat_id:e,video:{file:t.file,content_type:t.content_type?t.content_type:u.default.lookup(t.file)}},n):i=a({chat_id:e,video:t},n);let s;return s=await(await this.sendRequest("post",this.endpoint+"sendVideo",i,{multipart:!0})).result,s}async sendDocument(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="string"&&typeof t!="object")throw new r("A document can either be an HTTP URL or an object e.g: {file:'local path to document'}","Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'document' are required","Missing Parameters");let i={};typeof t!="string"&&t.file?i=a({chat_id:e,document:{file:t.file,content_type:t.content_type?t.content_type:u.default.lookup(t.file)}},n):i=a({chat_id:e,document:t},n);let s;return s=await(await this.sendRequest("post",this.endpoint+"sendDocument",i,{multipart:!0})).result,s}async sendAnimation(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="string"&&typeof t!="object")throw new r("An animation can either be an HTTP URL or an object e.g: {file:'local path to animation'}","Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'animation' are required","Missing Parameters");let i={};typeof t!="string"&&t.file?i=a({chat_id:e,animation:{file:t.file,content_type:t.content_type?t.content_type:u.default.lookup(t.file)}},n):i=a({chat_id:e,animation:t},n);let s;return s=await(await this.sendRequest("post",this.endpoint+"sendAnimation",i,{multipart:!0})).result,s}async sendVoice(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="string"&&typeof t!="object")throw new r("A voice can either be an HTTP URL or an object e.g: {file:'local path to voice'}","Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'voice' are required","Missing Parameters");let i={};typeof t!="string"&&t.file?i=a({chat_id:e,voice:{file:t.file,content_type:t.content_type?t.content_type:u.default.lookup(t.file)}},n):i=a({chat_id:e,voice:t},n);let s;return s=await(await this.sendRequest("post",this.endpoint+"sendVoice",i,{multipart:!0})).result,s}async sendVideoNote(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="string"&&typeof t!="object")throw new r("A video note can either be an HTTP URL or an object e.g: {file:'local path to the video note'}","Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'videoNote' are required","Missing Parameters");let i={};typeof t!="string"&&t.file?i=a({chat_id:e,video_note:{file:t.file,content_type:t.content_type?t.content_type:u.default.lookup(t.file)}},n):i=a({chat_id:e,video_note:t},n);let s;return s=await(await this.sendRequest("post",this.endpoint+"sendVideoNote",i,{multipart:!0})).result,s}async sendMediaGroup(e,t,n){let i={},s=[];return t.forEach(l=>{typeof l.media!="string"&&l.media.file?s.push({type:l.type,media:{file:l.media.file,content_type:l.media.content_type?l.media.content_type:u.default.lookup(l.media.file)}}):s.push({type:l.type,media:l.media})}),i=a({chat_id:e,media:JSON.stringify(s)},n),await(await this.sendRequest("post",this.endpoint+"sendMediaGroup",i,{multipart:!0})).result}async sendLocation(e,t,n,i){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t||!n)throw new r("The parameters 'chat_id', 'longitude' and 'latitude' are required","Missing Parameters");let s=a({chat_id:e,latitude:t,longitude:n},i);return await(await this.sendRequest("post",this.endpoint+"sendLocation",s)).result}async editMessageLiveLocation(e,t,n){if(!e||!t)throw new r("The parameters 'longitude' and 'latitude' are required","Missing Parameters");let i=a({latitude:e,longitude:t},n);return await(await this.sendRequest("post",this.endpoint+"editMessageLiveLocation",i)).result}async stopMessageLiveLocation(e){let t=a({},e);return await(await this.sendRequest("post",this.endpoint+"stopMessageLiveLocation",t)).result}async sendVenue(e,t,n,i,s,m){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t||!n||i||s)throw new r("The parameters 'chat_id', 'longitude', 'latitude', 'title' amd 'address' are required","Missing Parameters");let l=a({chat_id:e,latitude:t,longitude:n,title:i,address:s},m);return await(await this.sendRequest("post",this.endpoint+"sendVenue",l)).result}async sendContact(e,t,n,i){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t||!n)throw new r("The parameters 'chat_id', 'phone_number' and 'first_name' are required","Missing Parameters");let s=a({chat_id:e,phone_number:t,first_name:n},i);return await(await this.sendRequest("post",this.endpoint+"sendContact",s)).result}async sendDice(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let n=a({chat_id:e},t);return await(await this.sendRequest("post",this.endpoint+"sendDice",n)).result}async sendChatAction(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!e||!t)throw new r("The parameters 'chat_id' and 'action' are required","Missing Parameters");let n={chat_id:e,action:t};return await(await this.sendRequest("post",this.endpoint+"sendChatAction",n)).result}async getUserProfilePhotos(e,t){if(!e||typeof e!="number")throw new r(`user_id must be a number!, recieved: ${typeof e}`,typeof e===void 0?"Missing Parameters":"Invalid Type");let n=a({user_id:e},t);return await(await this.sendRequest("post",this.endpoint+"getUserProfilePhotos",n)).result}async getFile(e){return await(await this.sendRequest("post",this.endpoint+"getFile",{file_id:e})).result}async setMyCommands(e,t){if(!e||typeof e!="object")throw new r(`The commands parameter must be an Array of IBotCommand!, recieved ${typeof e}`,typeof e===void 0?"Missing Parameters":"Invalid Type");let n={};return t&&t.scope?n={commands:JSON.stringify(e),scope:JSON.stringify(t.scope),language_code:t.language_code?t.language_code:"en"}:n={commands:JSON.stringify(e)},await(await this.sendRequest("post",this.endpoint+"setMyCommands",n)).result}async deleteMyCommands(e){let t={};switch(e){case(e==null?void 0:e.scope):t={scope:JSON.stringify(e==null?void 0:e.scope)};break;case(e==null?void 0:e.language_code):t={language_code:e==null?void 0:e.language_code};break;case((e==null?void 0:e.language_code)&&e.scope):t={scope:JSON.stringify(e==null?void 0:e.scope),language_code:e==null?void 0:e.language_code};break;default:t={}}return await(await this.sendRequest("post",this.endpoint+"deleteMyCommands",t)).result}async getMyCommands(e,t){if(!e||typeof e!="object")throw new r("The scope parameter is required and is from type object!, recieved "+typeof e,typeof e===void 0?"Missing Parameters":"Invalid Type");let n={scope:JSON.stringify(e),language_code:t};return await(await this.sendRequest("post",this.endpoint+"getMyCommands",n)).result}async banChatMember(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`user_id is required and must be a number, received: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let i=a({chat_id:e,user_id:t},n);return await(await this.sendRequest("post",this.endpoint+"banChatMember",i)).result}async unbanChatMember(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`user_id is required and must be a number, received: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let i={chat_id:e,user_id:t,only_if_banned:n};return await(await this.sendRequest("post",this.endpoint+"unbanChatMember",i)).result}async restrictChatMember(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`user_id is required and must be a number, received: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let i=a({chat_id:e,user_id:t},n);return await(await this.sendRequest("post",this.endpoint+"restrictChatMember",i)).result}async promoteChatMember(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`user_id is required and must be a number, received: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let i=a({chat_id:e,user_id:t},n);return await(await this.sendRequest("post",this.endpoint+"promoteChatMember",i)).result}async setChatAdministratorCustomTitle(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`user_id is required and must be a number, received: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");if(!n||typeof n!="string")throw new r("custom_title is required and must be from type string!",typeof n===void 0?"Missing Parameters":"Invalid Type");let i={chat_id:e,user_id:t,custom_title:n};return await(await this.sendRequest("post",this.endpoint+"setChatAdministratorCustomTitle",i)).result}async banChatSenderChat(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`sender_chat_id is required and must be a number, received: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,sender_chat_id:t};return await(await this.sendRequest("post",this.endpoint+"banChatSenderChat",n)).result}async unbanChatSenderChat(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`sender_chat_id is required must be a number, received: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,sender_chat_id:t};return await(await this.sendRequest("post",this.endpoint+"unbanChatSenderChat",n)).result}async setChatPermissions(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(typeof t!="object")throw new r(`The permissions should be an object from type IChatPermissions!, recieved: ${typeof t}`,"Invalid Type");if(!t)throw new r("The permissions parameter is required!","Missing Parameters");let n={chat_id:e,permissions:JSON.stringify(t)};return await(await this.sendRequest("post",this.endpoint+"setChatPermissions",n)).result}async exportChatInviteLink(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"exportChatInviteLink",t)).result}async createChatInviteLink(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let n=a({chat_id:e},t);return await(await this.sendRequest("post",this.endpoint+"createChatInviteLink",n)).result}async editChatInviteLink(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="string")throw new r("The parameter invite_link is required and must be a string!",typeof t===void 0?"Missing Parameters":"Invalid Type");let i=a({chat_id:e,invite_link:t},n);return await(await this.sendRequest("post",this.endpoint+"editChatInviteLink",i)).result}async revokeChatInviteLink(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="string")throw new r("The parameter invite_link is required and must be a string!",typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,invite_link:t};return await(await this.sendRequest("post",this.endpoint+"revokeChatInviteLink",n)).result}async approveChatJoinRequest(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r("The parameter user_id is required and must be a number!",typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,user_id:t};return await(await this.sendRequest("post",this.endpoint+"approveChatJoinRequest",n)).result}async declineChatJoinRequest(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r("The parameter user_id is required and must be a number!",typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,user_id:t};return await(await this.sendRequest("post",this.endpoint+"declineChatJoinRequest",n)).result}async setChatPhoto(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="object")throw new r("The parameter photo is required and must be an object from type LocalFile!",typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,photo:t};return await(await this.sendRequest("post",this.endpoint+"setChatPhoto",n)).result}async deleteChatPhoto(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"deleteChatPhoto",t)).result}async setChatTitle(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="string")throw new r("The parameter title is required and must be a string!",typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,title:t};return await(await this.sendRequest("post",this.endpoint+"setChatTitle",n)).result}async setChatDescription(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let n={chat_id:e,description:t};return await(await this.sendRequest("post",this.endpoint+"setChatDescription",n)).result}async pinChatMessage(e,t,n){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`The paramater message_id is required and must be a number!, recieved: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let i={chat_id:e,message_id:t,disable_notification:n};return await(await this.sendRequest("post",this.endpoint+"pinChatMessage",i)).result}async unpinChatMessage(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let n={chat_id:e,message_id:t};return await(await this.sendRequest("post",this.endpoint+"unpinChatMessage",n)).result}async unpinAllChatMessages(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"unpinAllChatMessages",t)).result}async leaveChat(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"leaveChat",t)).result}async getChat(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"getChat",t)).result}async getChatAdministrators(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"getChatAdministrators",t)).result}async getChatMemberCount(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"getChatMemberCount",t)).result}async getChatMember(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="number")throw new r(`user_id must be a number!, recieved: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,user_id:t};return await(await this.sendRequest("post",this.endpoint+"getChatMember",n)).result}async setChatStickerSet(e,t){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");if(!t||typeof t!="string")throw new r(`The paramater sticker_set_name is required and must be a string!, recieved: ${typeof t}`,typeof t===void 0?"Missing Parameters":"Invalid Type");let n={chat_id:e,sticker_set_name:t};return await(await this.sendRequest("post",this.endpoint+"setChatStickerSet",n)).result}async deleteChatStickerSet(e){if(typeof e!="string"&&typeof e!="number")throw new r(`chat id must be a string or a number, received: ${typeof e}`,"Invalid Type");let t={chat_id:e};return await(await this.sendRequest("post",this.endpoint+"deleteChatStickerSet",t)).result}async answerCallbackQuery(e,t){if(!e||typeof e!="string")throw new r(`callback_query_id is required and must be a string, received: ${typeof e}`,typeof e===void 0?"Missing Parameters":"Invalid Type");let n=a({callback_query_id:e},t);return await(await this.sendRequest("post",this.endpoint+"answerCallbackQuery",n)).result}async editMessageText(e,t){if(!e||typeof e!="string")throw new r(`text is required and must be a string, received: ${typeof e}`,typeof e===void 0?"Missing Parameters":"Invalid Type");let n=a({text:e},t);return await(await this.sendRequest("post",this.endpoint+"editMessageText",n)).result}async editMessageCaption(e,t){if(!e||typeof e!="string")throw new r(`caption is required and must be a string, received: ${typeof e}`,typeof e===void 0?"Missing Parameters":"Invalid Type");let n=a({caption:e},t);return await(await this.sendRequest("post",this.endpoint+"editMessageCaption",n)).result}};module.exports=q(N);0&&(module.exports={TelegramAPI});