Guest User

Untitled

a guest
Sep 7th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. from telegram import Bot, ReplyMarkup, MessageId
  2.  
  3. TOKEN =
  4. CHAT_ID =
  5. MESSAGE_ID =
  6.  
  7. bot = Bot(TOKEN)
  8. r = bot.copy_message(chat_id=CHAT_ID, from_chat_id=CHAT_ID, message_id=MESSAGE_ID, caption="")
  9. bot.send_message(chat_id=CHAT_ID, text="Without changes ^", reply_to_message_id=r.message_id)
  10.  
  11.  
  12. class newBot(Bot):
  13. def copy_message(self, chat_id, from_chat_id, message_id, caption=None, parse_mode=None,caption_entities=None,
  14. disable_notification=None, reply_to_message_id=None, allow_sending_without_reply=None,
  15. reply_markup=None, timeout=None, api_kwargs=None):
  16. data = {
  17. 'chat_id': chat_id,
  18. 'from_chat_id': from_chat_id,
  19. 'message_id': message_id,
  20. 'parse_mode': parse_mode,
  21. 'disable_notification': disable_notification,
  22. 'allow_sending_without_reply': allow_sending_without_reply,
  23. }
  24. if caption is not None:
  25. data['caption'] = caption
  26. if caption_entities:
  27. data['caption_entities'] = caption_entities
  28. if reply_to_message_id:
  29. data['reply_to_message_id'] = reply_to_message_id
  30. if reply_markup:
  31. if isinstance(reply_markup, ReplyMarkup):
  32. data['reply_markup'] = reply_markup.to_json()
  33. else:
  34. data['reply_markup'] = reply_markup
  35. result = self._post('copyMessage', data, timeout=timeout, api_kwargs=api_kwargs)
  36. return MessageId.de_json(result, self)
  37.  
  38.  
  39. bot = newBot(TOKEN)
  40. r = bot.copy_message(chat_id=CHAT_ID, from_chat_id=CHAT_ID, message_id=MESSAGE_ID, caption="")
  41. bot.send_message(chat_id=CHAT_ID, text="With changes ^", reply_to_message_id=r.message_id)
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment