Last active
April 4, 2021 10:44
-
-
Save Kylmakalle/6fa772e4ebce74fec6138675b343a9cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from telethon import TelegramClient | |
from telethon.tl.functions.messages import GetFullChatRequest | |
api_id = 12345 # my.telegram.org | |
api_hash = 'n91hds91hd90qwd' # credenitals | |
phone_number = '+1231241213' | |
client = TelegramClient('telegram_script', api_id, api_hash) # feel free to edit %sessionname% as you want | |
client.connect() # logining and connecting to Telegram servers | |
if not client.is_user_authorized(): # authorization (if there is no .session file created before) | |
client.send_code_request(phone_number) | |
client.sign_in(phone_number, input('Enter the code: ')) | |
# Using built-in methods | |
dialogs, entities = client.get_dialogs(10) | |
for i in range(10): | |
if 'title' in dir(entities[i]): | |
print(i, entities[i].title) | |
print('Got your first groups, provide a chat number: ') | |
chat = input() | |
print(entities[int(chat)].id) | |
result = client.invoke( | |
GetFullChatRequest(entities[int(chat)].id) | |
) | |
info = result | |
print(info) | |
"""Traceback (most recent call last): | |
File "GetFullChatRequest.py", line 26, in <module> | |
GetFullChatRequest(entities[int(chat)].id) | |
File "A:\PYTHON64\lib\site-packages\telethon\telegram_client.py", line 247, in invoke | |
request, timeout=timeout, updates=updates) | |
File "A:\PYTHON64\lib\site-packages\telethon\telegram_bare_client.py", line 189, in invoke | |
self.sender.receive(request, timeout, updates=updates) | |
File "A:\PYTHON64\lib\site-packages\telethon\network\mtproto_sender.py", line 105, in receive | |
remote_msg_id, remote_seq, reader, updates) | |
File "A:\PYTHON64\lib\site-packages\telethon\network\mtproto_sender.py", line 205, in _process_msg | |
return self._handle_rpc_result(msg_id, sequence, reader) | |
File "A:\PYTHON64\lib\site-packages\telethon\network\mtproto_sender.py", line 353, in _handle_rpc_result | |
raise error | |
telethon.errors.rpc_errors_400.ChatIdInvalidError: (ChatIdInvalidError(...), 'Invalid object ID for a chat. Make sure to pass the right types.')""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment