Comments (18)
I can now see your problem.
You are logging in as Bot, right? Because this is a work in progress, you can install the latest development version: https://docs.pyrogram.ml/start/QuickInstallation#bleeding-edge,
restart your bot using this version and while is online, kick it and add it again to your channel/supergroup. Now resolve_peer with the id should work.
from pyrogram.
This is because basic groups are stored inside your account. This means that each member of a basic group have his own copy of the messages stored inside their own account (that's why you can't get old mesages in case you leave and delete the group). The method doesn't accept a chat_id for basic groups because message ids for them are shared with private messages ids.
In other words, any personal message id can be a message of either a private message or a basic group. Channels and Supergroups have their own message id space
from pyrogram.
@sviat9440 Hi, any bot API id starting with -100 is considered a channel or a supergroup, hence you can't use messages.GetChats, you need channels.GetChannels.
from pyrogram.
print(pycli.resolve_peer(1004766182)) # -1001004766182
# pyrogram.api.errors.exceptions.bad_request_400.PeerIdInvalid: [400 PEER_ID_INVALID]: The id/access_hash combination is invalid
print(pycli.resolve_peer("coding_ru"))
# {
# "_": "types.InputPeerChannel",
# "channel_id": 1004766182,
# "access_hash": -8125217233421763316
# }
from pyrogram.
Ok, thats works. All users needs to kick and add bot again?
Then, pycli.get_messages(chat_id=pycli.resolve_peer(1004766182), message_ids=list(range(141180, 141280)))
returns:
TypeError: unhashable type: 'InputPeerChannel'
from pyrogram.
Ok, thats works. All users needs to kick and add bot again?
No, is just the bot that wasn't aware of the channel/supergroup.
For the other errors, you are passing wrong values. Please read the docs, in particular read what kind of values you must pass: https://docs.pyrogram.ml/pyrogram/Client?highlight=get_messages#pyrogram.Client.get_messages
This is high-level convenience method, and accepts IDs as simple integers (it will automatically call resolve_peer for you). For any other raw methods not listed in the Client class you must use resolve_peer.
from pyrogram.
No, is just the bot that wasn't aware of the channel/supergroup.
That is, the client must always be running when you add the bot to the group?
For the other errors, you are passing wrong values.
tnx!
from pyrogram.
-258239875 -> simple private group
print(pycli.resolve_peer(258239875))
Traceback (most recent call last):
...
KeyError: -100258239875
...
Traceback (most recent call last):
File "test.py", line 11, in
print(pycli.resolve_peer(258239875))
File "C:\Users\sviat-pc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyrogram\client\client.py", line 983, in resolve_peer
raise PeerIdInvalid
pyrogram.api.errors.exceptions.bad_request_400.PeerIdInvalid: [400 PEER_ID_INVALID]: The id/access_hash combination is invalid
from pyrogram.
That is, the client must always be running when you add the bot to the group?
Currently, providing you are using the latest development version, it must be online only when you are adding it again, then pyrogram will remember the id (it is stored in the session file).
-258239875 -> simple private group
I think this is just the same problem, have you kicked and added it again?
Anyway, I flagged this issue as enhancement, some code needs to be added in order to make bots be aware of groups they are part of, even without the need of kicking them.
from pyrogram.
I think this is just the same problem, have you kicked and added it again?
Yes. Now I use method messages.GetMessages(id), but i cant set chat_id param.
In supergroups all works. Bot not in simle groups.
from pyrogram.
rgr, tnx
from pyrogram.
To summarize: if you want messages from private chats or basic groups, you use messages.GetMessages
(and pass only the message id). If you want messages from channels or supergroups, you use channels.GetMessages
.
The convenience method .get_messages()
is able to get messages for both entities. If you look at how's implemented you'll see that it'll use both raw functions, and will use channels.GetMessages
in case the provided chat_id belongs to a channel/supergroup.
from pyrogram.
Anyway, I flagged this issue as enhancement, some code needs to be added in order to make bots be aware of groups they are part of, even without the need of kicking them.
Please tell when you implemented it
from pyrogram.
Kings
from pyrogram.
.get_messages() is able to get messages for both entities.
line 2954 client.py raise exception if I try get messages from private chats\simple groups
Then line 2963 not running
from pyrogram.
Please tell when you implemented it
All changes live in the github repo. For new releases I write release notes which summarize what's been changed.
line 2954 client.py raise exception if I try get messages from private chats\simple groups
Well, what exception exactly? That's important...
from pyrogram.
Well, what exception exactly? That's important...
Hmm, all works. Sorry. Im noob))
from pyrogram.
Closing. Client.get_chat has been added.
from pyrogram.
Related Issues (20)
- 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
- 求大佬维护群聊管理员匿名用户的识别问题
- the handler receives the user's message twice
- Missing RDNS Parameter in proxy connection settings
- Missing Parameter in ban_member Method HOT 6
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.