Skip to content

Support for Telegram Bot API 5.4#912

Merged
yagop merged 8 commits intoyagop:masterfrom
danielperez9430:master
Nov 7, 2021
Merged

Support for Telegram Bot API 5.4#912
yagop merged 8 commits intoyagop:masterfrom
danielperez9430:master

Conversation

@danielperez9430
Copy link
Collaborator

@danielperez9430 danielperez9430 commented Nov 7, 2021

  • All tests pass
  • I have run npm run doc

Description

Support Bot API v5.4:

  • Add method approveChatJoinRequest()
  • Add method declineChatJoinRequest()
  • Add support for new updates:
    • chat_join_request
      Fixes:
  • Method editMessageMedia() (Now you can send local files)

References

Use examples

Listen event "chat_join_request":

bot.on('chat_join_request', data => { console.log("Join Request"); console.log(data); });

Example approveChatJoinRequest:

bot.on('chat_join_request', join_request => { let chat_id = join_request.chat.id; let user_id = join_request.from.id; bot.approveChatJoinRequest(chat_id, user_id); bot.sendMessage(chat_id, "Welcome " + join_request.from.first_name + ", invitation accepted") })

Example declineChatJoinRequest:

bot.on('chat_join_request', join_request => { let chat_id = join_request.chat.id; let user_id = join_request.from.id; bot.declineChatJoinRequest(chat_id, user_id) bot.sendMessage(chat_id, "Decline chat join for " + join_request.from.first_name) })
@danielperez9430
Copy link
Collaborator Author

Example send local file using method editMessageMedia:

bot.onText(/^\/document/, (msg) => { // You can use relative (filePath) or absolute patch (filePathFull ) const filePathFull = `${__dirname}/sample_video.mp4` const filePath = "./sample_video.mp4" bot.sendDocument(msg.chat.id , filePathFull ).then((resp) => { let chat_id = resp.chat.id let message_id = resp.message_id // Edit message before 2 seconds setTimeout(() => { bot.editMessageMedia( { type:"document", media: "attach://" + filePath, caption: 'Hello Word'}, { chat_id:chat_id, message_id:message_id }); }, 2000) }); })
@yagop yagop merged commit 68ac69c into yagop:master Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants