Advertisement
disk6969

Telethon ChatList join

Nov 15th, 2023 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. from telethon.sync import TelegramClient
  2. from telethon import functions, types
  3. from telethon.tl.functions.messages import SendReactionRequest
  4. from telethon import functions, types
  5. from telethon.tl.functions.chatlists import JoinChatlistInviteRequest
  6.  
  7. with TelegramClient(...) as client:
  8.   hash = "esdbZr0CHrVhN2Iy"
  9.   result = client(functions.chatlists.CheckChatlistInviteRequest(slug=hash))
  10.   if isinstance(result, types.chatlists.ChatlistInviteAlready):
  11.     print("chatlist already joined")
  12.   else:
  13.     print(f"ChatList: {hash} has {len(result.peers)} chats")
  14.  
  15.     result = client(
  16.       functions.chatlists.JoinChatlistInviteRequest(slug=hash, peers=result.peers)
  17.     )
  18.     print("Joined")
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement