GithubHelp home page GithubHelp logo

Comments (4)

delivrance avatar delivrance commented on May 7, 2024

It depends whether you want to listen for new Messages or retrieve old ones.
In both cases you'll end up with a Message object which contains the optional fwd_from field; if the field exists (i.e.: is not None) the message is a forwarded message.

from pyrogram.

AmirMahmood avatar AmirMahmood commented on May 7, 2024

i listen for updates with below code. i get forward id from "message.fwd_from" but how can i get username and title of channel or User by this id ?

def update_handler(client, update, users, chats):
    if isinstance(update, types.UpdateNewChannelMessage):
        message = update.message

        if isinstance(message, types.Message):  # Filter by Message to exclude MessageService and MessageEmpty
            if not chats[message.to_id.channel_id].megagroup:  # Only handle messages from Channels not Supergroups
                message_fwd_from_id = None
                message_fwd_from_username = None
                message_fwd_from_title = None

                if message.fwd_from is not None:
                    if message.fwd_from.channel_id is not None:
                        message_fwd_from_id = message.fwd_from.channel_id
                        message_fwd_from_username = ???
                        message_fwd_from_title = ???
                    if message.fwd_from.from_id is not None:
                        message_fwd_from_id = message.fwd_from.from_id
                        message_fwd_from_username = ???
                        message_fwd_from_title = ???

client.set_update_handler(update_handler)

from pyrogram.

AmirMahmood avatar AmirMahmood commented on May 7, 2024

I have the same question as LonamiWebs/Telethon#335

from pyrogram.

delivrance avatar delivrance commented on May 7, 2024

From https://docs.pyrogram.ml/pyrogram/Client#pyrogram.Client.set_update_handler

chats (dict) – Dictionary of all Chat and Channel mentioned in the update. You can access extra info about the chat (such as title, participants_count, etc…) by using the IDs you find in the update argument (e.g.: chats[1701277281]).

from pyrogram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.