SHARE
TWEET

Untitled

a guest Jun 16th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import telegram.bot
  2. from telegram.ext import messagequeue as mq
  3.  
  4.  
  5. class MQBot(telegram.bot.Bot):
  6.     def __init__(self, *args, is_queued_def=True, mqueue=None, **kwargs):
  7.         super(MQBot, self).__init__(*args, **kwargs)
  8.         self._is_messages_queued_default = is_queued_def
  9.         self._msg_queue = mqueue or mq.MessageQueue()
  10.  
  11.     def __del__(self):
  12.         try:
  13.             self._msg_queue.stop()
  14.         except:
  15.             pass
  16.         super(MQBot, self).__del__()
  17.  
  18.     @mq.queuedmessage
  19.     def send_message(self, *args, **kwargs):
  20.         super(MQBot, self).send_message(*args, **kwargs)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top