Catao
Catao

Reputation: 129

How to send message using python-telegram-bot

I'm new using python and telegram-bot

I'm trying to found a way to send messages using python-telegram-bot when I received a message without uses:

requests.post(
        'https://api.telegram.org/bot<token>/sendMessage?chat_id=<id>&text=Hello World!')

Flow:

Message arrived on channel A then send a new message to channel B (Message receveid on Channel A).

I only found reply_text. Is there other way to do it ?

Thanks !

Upvotes: 0

Views: 4147

Answers (1)

RJ Adriaansen
RJ Adriaansen

Reputation: 9619

reply_text won't work because it will send the message back to channel A. You would need bot.send_message where you can set the target channel with chat_id. A simple example:

def update_message_to_channel_B(update: object, context: CallbackContext) -> None:
    context.bot.send_message(chat_id=CHANNEL_B_ID, text='Message receveid on Channel A')

And add the handler:

dispatcher.add_handler(MessageHandler(Filters.text, update_message_to_channel_B))

Upvotes: 1

Related Questions