Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def say_hello_mass(context: CallbackContext):
- """React on command"""
- # context.bot_data.data = collections.deque([[message_to_user1, user1], [message_to_user2, user2]])
- context.bot_data.users = {...} # some data inside already
- context.bot_data.users.update({user1.id: "Hello", user2.id: "Bye"})
- context.job_queue.run_once(callback=say_hello_mass_job, when=0)
- def say_hello_mass_job(update: Update, context: CallbackContext):
- """Here need to be vigilant to no overwrite a dict/queue with a new call,
- so preferable thar the dict/queue item will contain every required data.
- Therefore, it should be created during app startup and in future only append to it
- """
- for text, user in context.bot_data.users.items(): # Not sure if enumerate will work here
- say_hello_personal_job(user, text, context)
- def say_hello_personal_job(user, text, context):
- if user.conversation_data is not None and user is not None:
- context.bot.send_message(chat_id=user.id, message=context.job.context)
- context.bot_data.data[user.id] = None # Delete are preferable but may break the order
- time.sleep(1) # UPD
- def end_conversation(context):
- context.job_queue.run_once(callback=say_hello_personal_job, when=0) # In
- return CH.END
Advertisement
RAW Paste Data
Copied
Advertisement