A while back, I used to send messages to channels like this:
def broadcast(bot, update):
bot.send_message(channel_id, text)
And I would reply to the user with:
def reply(bot, update):
update.message.reply_text(text)
Now, it seems that the arguments for CommandHandlers
have changed from (bot, update)
to (update, context)
. As a result, I can still reply to the user with the update
argument, something like this:
def reply(update, context):
update.message.reply_text(text)
But I can no longer send messages to a channel. How can I do this?
2
Answers
From documentation,
bot
is available incontext
.So the function,
can be rewritten like this:
As mentioned above
bot
is available incontext
so alternatively the functioncan be rewritten as