Telegram comment post as channel

675 Views Asked by At

Some comments in telegram discussions are sent from channels (click to name and visit channel page). This messages has sender_chat property. How can I post comments as channel? (manually or via pyrogram). P.S. I can select sender if comment is in my channel, but other chats does'nt have sender switcher btn. Sorry for my bad English

2

There are 2 best solutions below

0
Ali Abdi On

Specify set_send_as_chat() before invoking send_message() like below (Pyrogram 2.0+):

from pyrogram import Client

Credentials = Client(
    name="ad_comment_on_channel",
    api_id=---,
    api_hash="---",
    device_model="Ad Comment On Channel",
    app_version="ACoCh v1.0",
)

with Credentials as app:
    # Discussion Group's Numeric ID (starting with -100) [integer]
    group_ID = -1001234567890
    # ID of a post in the discussion group [integer]
    msg_ID = 123

    # Select your public channel for anonymous commenting
    app.set_send_as_chat(group_ID, "YourPublicChannelUserName")

    app.send_message(
        chat_id=group_ID,
        reply_to_message_id=msg_ID,
        text="My Comment"
    )
0
IML On

Thank you Ali Abdi for helping! Additional details - you must be channel owner to post messages as channel (admins can't do that)