0

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 !

1 Answer 1

1

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))
Sign up to request clarification or add additional context in comments.

2 Comments

Hello Thanks for your reply ! I found that bot is on context like: context.bot.send_message
Correct, see my example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.