Comments (4)
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.
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.
I have the same question as LonamiWebs/Telethon#335
from pyrogram.
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)
- There are multiple videos in a message, but only one video will be downloaded through message.video. Obviously, this is illogical HOT 2
- Обновить
- ОБНОВИТЬ ПАКЕТ СУКА!!!!!!!!!!!!!!!
- ГДЕ ЁБАНЫЕ ОБНОВЛЕНИЯ????????
- Your library is the BEST!
- Which is the Best Fork of Pyrogram? HOT 9
- Message missing text HOT 5
- Fix: Smart-plugin not supporting an off-drive path
- forward_messages missing HOT 2
- Pyrogram is incompatible with PYTHONOPTIMIZE=2 (or -OO)
- CHAT_ADMIN_REQUIRED HOT 5
- Unable to connect due to network issues: Connection timed out
- Hardcoded Session.START_TIMEOUT
- issue tiwh
- Trouble Accessing Messages Containing Quotes HOT 2
- Fetch more than 200 or filter by deleted / last seen a long time ago #4342 HOT 1
- Ability to specify session file path HOT 1
- Issue: Ban from 'pyrogramchat' Telegram Group Due to Verification Bot Malfunction HOT 1
- Slow Upload Speed HOT 1
- [400 PEER_ID_INVALID] but I met this peer in a group chat! On real client I can DM them. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyrogram.