All documentation refers to telegram bot api but we just made it easier.

Thanks To

  • Allah SWT
  • My Family
  • All Member @GasTestingGroup
  • All Member @botindonesia
  • Special Thanks @Oh_Yoon_Hee for tester

Example Used

var bot = new butthx.bot("token")
//The token is obtained from @BotFather. Token are usually in the form of random letters such as: 1234567890:ABCDEFGHIjklmNOPQRSTUVWXYZ
function doPost(e){
  bot.handleUpdate(e) // handle response from telegram
  bot.command("start",(res)=>{
    bot.reply("Hi,Welcome!")
  }) // if user type /start or !start or .start, then bot will reply
}  
  
//run (ctlr + r) this function (setWebhook) just once
function setWebhook(){  
  let res = bot.setWebhook("url") //The url getting from deployed as a web application.
  Logger.log(res)
}

if you used beta version :
var bot = new butthxbeta.bot("token")
and don't select version if description : 🐞 Bug? or 🐞 Bug

deploy

Follow the steps provided here to deploy as web.
⚠️ don't forget to set Who has access to the app to Anyone, even anonymous

handle update

listen(text||regex,callback)

bot.listen("hi",(res)=>{
  bot.reply("hi listen")
})
//or 
bot.listen(/hi/i,(res,exec)=>{
  bot.reply("hi listen")
})

command(array||text,callback,ignore)

bot.command("hi",(res)=>{  
  bot.reply("hi command")  
}) 
// Or
bot.command(["hi","hei"],(res)=>{  
  bot.reply("hi command")  
}) 
//or 
bot.command(["hi"],(res)=>{  
  bot.reply("hi command")  
}) 
// ignore
bot.command(["hi"],(res)=>{  
  bot.reply("hi command")  
},true) 

cmd(array||text,callback,ignore)
Shortcut from command
⚠️ The function of ignore here is if there is a command /start and then there is a message /start help then the /start command will follow the execution. to prevent it use ignore
cb(callback_data,callback)

bot.cb('hi',(res)=>{
  bot.reply('oh hi')
})
//or 
bot.cb(/hi/i,(res,exec)=>{
  bot.reply('oh hi')
})

⚠️ bot.cb will crash if you use bot.on('callbackQuery')
on(event,callback)

bot.on("callbackQuery",(res)=>{
  bot.reply("callbackQuery")
})  

Event : message|new_chat_members|left_chat_member|callback_query|edited_message|inline_query|sticker|document|poll|location|game|contact|audio|voice|animation|dice|text|video_note|pinned_message|channel_post|edited_channel_post|chosen_inline_result|shipping_query|pre_checkout_query|poll_answer|voice_chat_started|voice_chat_ended|voice_chat_participants_invited|notify_voice_chat|timer_message|chat_member|my_chat_member|forward_message|via_bot|media_group|new_chat_title|new_chat_photo|delete_chat_photo|group_chat_created|supergroup_chat_created|channel_chat_created|migrate_chat

Shortcut

shortcut from
reply sendMessage
botInfo getMe
replyPhoto sendPhoto
replyVideo sendVideo
replyDocument sendDocument
replyDice sendDice
replyAnimation sendAnimation
replyAudio sendAudio
replyVoice sendVoice
replyVideoNote sendVideoNote
replyMediaGroup sendMediaGroup
replyLocation sendLocation
replyVenue sendVenue
replyContact sendContact
replySticker sendSticker
replyMdV2 sendMessage
replyMd(text,advanced) sendMessage
replyHTML sendMessage
replyToMessage sendMessage
replyToUser sendMessage
getFileLink(path) To create a downloader url
getPathFileLink(file_id) To create downloader url
remsg replyToMessage
reuser replyToUser

Build

used : bot.build.<method_name>
button.url
To create a JSON button url

params type required
text String true
url String true

button.callback
To create a JSON callback button

params type required
text String true
callback_data String true
hide bolean opsional

loop

params type required
amount Number true
callback function true

Example :

.....bot.build.loop(3,(i)=>{
  bot.reply("hai "+i)
}).....

random

params type required
data Array true

Example :

bot.build.random([1,2,3,4,5])

⚠️ bot.build.button cannot be used on replyMd,replyMdV2,replyHTML,replyToMessage,replyToUser for version 07139 or lower.
file

params type required
filename String true
data blob[] true
content-type String opsional

zip

params type required
filename String true
file Array of Blob true
extension String opsional
unzip
params type required
file blob[] true

advanced

advanced here are additional params needed like reply_markup. ⚠️ advanced is a JSON object and doesn"t need stringify.

bot.reply("<i>html parse</i>",{
  parse_mode : "HTML"
})

Telegram Bot Api

used : bot.<method_name>

sleep

params type required
time String true

Example :

bot.sleep('2ms')
bot.sleep('2.5ms')
bot.sleep('2s')
bot.sleep('2.7s')
bot.sleep('2m')
bot.sleep('2.1m')
bot.sleep('2h')
bot.sleep('2.5h')
bot.sleep('2d')
bot.sleep('2.4d')

ms = Miliseconds
s = Second
m = Minutes
h = Hours d = Day

getUpdates

params type required
offset Integer true
limit Integer true
advanced JSON opsional

setWebhook

params type required
url String true
advanced JSON opsional

deleteWebhook

params type required
drop_pending_updates Bolean

getWebhookInfo

params type required
- - -

getMe

params type required
- - -

logOut

params type required
- - -

close

params type required
- - -

sendMessage

params type required
chat_id String or Integer true
text String true
advanced JSON opsional

forwardMessage

params type required
chat_id String or Integer true
from_chat_id String or Integer true
message_id Integer true
advanced JSON opsional

copyMessage

params type required
chat_id String or Integer true
from_chat_id String or Integer true
message_id Integer true
advanced JSON opsional

sendPhoto

params type required
chat_id String or Integer true
photo String or InputFile true
advanced JSON opsional

sendAudio

params type required
chat_id String or Integer true
audio String or InputFile true
advanced JSON opsional

sendDocument

params type required
chat_id String or Integer true
document String or InputFile true
advanced JSON opsional

sendVideo

params type required
chat_id String or Integer true
video String or InputFile true
advanced JSON opsional

sendAnimation

params type required
chat_id String or Integer true
animation String or InputFile true
advanced JSON opsional

sendVoice

params type required
chat_id String or Integer true
voice String or InputFile true
advanced JSON opsional

sendVideoNote

params type required
chat_id String or Integer true
video_note String or InputFile true
advanced JSON opsional

sendMediaGroup

params type required
chat_id String or Integer true
media Array true
advanced JSON opsional

sendLocation

params type required
chat_id String or Integer true
latitude Float number true
longitude Float number true
advanced JSON opsional

editMessageLiveLocation

params type required
chat_id String or Integer true
message_id Integer true
latitude Float number true
longitude Float number true
advanced JSON opsional

stopMessageLiveLocation

params type required
chat_id String or Integer true
message_id Integer true
advanced JSON opsional

sendVenue

params type required
chat_id String or Integer true
latitude Float number true
longitude Float number true
advanced JSON opsional

sendContact

params type required
chat_id String or Integer true
phone_number String true
first_name String true
advanced JSON opsional

sendPoll

params type required
chat_id String or Integer true
question String true
options Array true
advanced JSON opsional

sendDice

params type required
chat_id String or Integer true
emoji String true
advanced JSON opsional

sendChatAction

params type required
chat_id String or Integer true
action String true

getUserProfilePhotos

params type required
chat_id String or Integer true
offset Integer true
limit Integer true

getFile

params type required
file_id String or Integer true

kickChatMember

params type required
chat_id String or Integer true
user_id String or Integer true
advanced JSON opsional

unbanChatMember

params type required
chat_id String or Integer true
user_id String or Integer true
advanced JSON opsional

restrictChatMember

params type required
chat_id String or Integer true
user_id String or Integer true
advanced JSON opsional

promoteChatMember

params type required
chat_id String or Integer true
user_id String or Integer true
advanced JSON opsional

setChatAdministratorCustomTitle

params type required
chat_id String or Integer true
user_id String or Integer true
custom_title String true

setChatPermissions

params type required
chat_id String or Integer true
permissions JSON true
params type required
chat_id String or Integer true
params type required
chat_id String or Integer true
advanced JSON
params type required
chat_id String or Integer true
invite_link String true
advanced JSON
params type required
chat_id String or Integer true
invite_link String true

setChatPhoto

params type required
chat_id String or Integer true
photo String or InputFile true

deleteChatPhoto

params type required
chat_id String or Integer true

setChatTitle

params type required
chat_id String or Integer true
title String true

setChatDescription

params type required
chat_id String or Integer true
description String or InputFile true

pinChatMessage

params type required
chat_id String or Integer true
message_id Integer true
advanced JSON opsional

unpinChatMessage

params type required
chat_id String or Integer true
message_id Integer true

unpinAllChatMessages

params type required
chat_id String or Integer true

leaveChat

params type required
chat_id String or Integer true

getChat

params type required
chat_id String or Integer true

getChatAdministrators

params type required
chat_id String or Integer true

getChatMembersCount

params type required
chat_id String or Integer true

getChatMember

params type required
chat_id String or Integer true
user_id String or Integer true

setChatStickerSet

params type required
chat_id String or Integer true
sticker_set_name String true

deleteChatStickerSet

params type required
chat_id String or Integer true

answerCallbackQuery

params type required
callback_query_id String true
text String true
advanced JSON opsional

setMyCommands

params type required
command Array true

getMyCommands

params type required
- - -

editMessageText

params type required
chat_id String or Integer true
message_id Integer true
text String true
advanced JSON opsional

editMessageCaption

params type required
chat_id String or Integer true
message_id Integer true
caption String true
advanced JSON opsional

editMessageMedia

params type required
chat_id String or Integer true
message_id Integer true
media String or InputFile true
advanced JSON opsional

editMessageReplyMarkup

params type required
chat_id String or Integer true
message_id Integer true
reply_markup JSON true
advanced JSON opsional

stopPoll

params type required
chat_id String or Integer true
message_id Integer true
advanced JSON opsional

deleteMessage

params type opsional
chat_id String or Integer true
message_id Integer true

sendSticker

params type required
chat_id String or Integer true
sticker String or InputFile true
advanced JSON opsional

getStickerSet

params type required
name String true

uploadStickerFile

params type required
user_id Integer true
png_sticker InputFile true

createNewStickerSet

params type required
user_id Integer true
name String true
title String true
emojis String true
advanced JSON opsional

addStickerToSet

params type required
user_id Integer true
name String true
emojis String true
advanced JSON opsional

setStickerPositionInSet

params type required
sticker String true
position Integer true

deleteStickerFromSet

params type required
sticker String true

setStickerSetThumb

params type required
name String true
user_id Integer true
thumb String or InputFile true

answerInlineQuery

params type required
inline_query_id String true
results Array true
advanced JSON opsional

request

params type required
method String true
data JSON true

⚠️The value of data in the form of Array/JSON must be in JSON.stringify() to prevent errors.
Example :

let data = {
  chat_id: "123556",
  reply_markup : JSON.stringify({})
}  
request("sendMessage",data)

Butthx © 2021 All Rights Reserved