I want to forward a message from multiple channels to another channel. For some reason, I cannot receive a message coming from another bot channel. My goal is to relay a message from a public channel that sends a signal to buy and sell crypto to my own channel.
I’ve attached some of the code generated by ChatGPT.
I can send a message from channelA and it will receive and copy it to channelB. But on the on_message on the channelB, I didn’t get any message. I have tried other public channels as well that seem using bot to send the message and I didn’t receive on_message from those channels.
How can I fix this?
from pyrogram import Client, filters
import logging
# Configure logging
logging.basicConfig(level=logging.INFO)
# Initialize Pyrogram client
app = Client("my_account")
# Channel usernames or IDs
channelA = 'channelA'
channelB = 'channelB'
channelC = 'channelC'
# Forward messages from ChannelA to ChannelB
@app.on_message(filters.chat(channelA))
def forward_to_channelB(client, message):
logging.info(f"Forwarding message from ChannelA: {message.text}")
message.copy(channelB) # Copy message to ChannelB
# Forward messages from ChannelB to ChannelC, including those sent by the bot
@app.on_message(filters.chat(channelB))
def forward_to_channelC(client, message):
logging.info(f"Forwarding message from ChannelB: {message.text}")
app.run()
I have tried reading all the message like this but if it’s coming from a bot channel it cannot receive any message.
@app.on_message()
def readMsg(client, message):
logging.info(f"Fo`your text`rwarding message: {message.text}")
I can’t seems to find related question regarding this but I’ve also try to use on_raw_update and it also don’t show any message. Some other question suggest that it might cause because the channel doesn’t allow copy or forward but it isn’t the case on mine. My guess is because the message is coming from other mtproto copy function. But anybody encounter this and have any suggestion?
William Adjandra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.