Answer the question
In order to leave comments, you need to log in
How to pass chat parameters to telegram bot function, python-telegram-bot without Handler?
def bot():
print("bot online")
updater = Updater(token=Tokens.bot_token('live'))
dispatcher = updater.dispatcher
commands = Commands
# job
j = updater.job_queue
j.run_repeating(InfoMessage.use_discounts, 15) #<---- Задание с задержкой в которое нужно передать параметры (chat_id)
#commands
start_handler = CommandHandler('start', commands.start)
dispatcher.add_handler(start_handler)
contact_handler = MessageHandler(Filters.contact, commands.contact)
dispatcher.add_handler(contact_handler)
updater.start_polling()
if __name__ == '__main__':
bot()
class InfoMessage():
def use_discounts(bot, update):
print(update.message.chat_id)
Answer the question
In order to leave comments, you need to log in
update.message.chat_id is the number of the interlocutor, the function that is called according to the schedule does not and cannot have it,
but if you know someone's number, you can send him a message from this function
bot.send_message(chat_id=123456, text = '*wake up * Neo', parse_mode='Markdown')
j.run_repeating(func, 0)
def func(bot, job): <-- this should be job and not update
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question