LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
10.08k stars 1.41k forks source link

functions.help.GetUserInfoRequest fails even with a valid `user_id` argument's value provided. #4175

Closed nzdev03 closed 1 year ago

nzdev03 commented 1 year ago

Code that causes the issue

async with TelegramClient(...) as client:
  me = await client.get_me()
  result = await client(functions.help.GetUserInfoRequest(
  user_id=me.username
  ))
  print(result.stringify())

Expected behavior

The returned help.UserInfo object being returned.

Actual behavior

Raises telethon.errors.rpcerrorlist.UserInvalidError.

Traceback

Traceback (most recent call last):
  File "/Users/tz40/syri_botnet/test.py", line 106, in <module>
    asyncio.run(main())
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/tz40/syri_botnet/test.py", line 100, in main
    result = await client(functions.help.GetUserInfoRequest(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/telethon/client/users.py", line 87, in _call
    result = await future
             ^^^^^^^^^^^^
telethon.errors.rpcerrorlist.UserInvalidError: The given user was invalid (caused by GetUserInfoRequest

Telethon version

1.29.2

Python version

Python 3.11.3

Operating system (including distribution name and version)

macOS Ventura 13.4.1 (c) (M2 Chip)

Other details

I attempted to provide a Peer object, Channel object, username string and User object. I also tried providing a User ID (as both string and int) to no avail (there was a valid access hash for the user ID). It appears functions.help.GetUserInfoRequest fails entirely. I tried the before mentioned process on both the account logged into the Telethon application and also on other accounts via entity-like objects and strings/ints.

Checklist

Lonami commented 1 year ago

You are using raw API, which means the results you are getting come directly from Telegram, and Telethon is not changing them in any way (other than adapting some input parameters where needed, all while respecting the intended values). Unfortunately this means it's something Telethon cannot "fix" and it's just the way Telegram's API works.