Answers for "telegram telethon get new user details"


telegram telethon get new user details

from telethon import TelegramClient

from import ResolveUsernameRequest
from import GetAdminLogRequest
from import GetParticipantsRequest

from import ChannelParticipantsRecent
from import InputChannel
from import ChannelAdminLogEventsFilter
from import InputUserSelf
from import InputUser
# These example values won't work. You must get your own api_id and
# api_hash from, under API Development.
api_id = 12345
api_hash = '8710a45f0f81d383qwertyuiop'
phone_number = '+123456789'

client = TelegramClient(phone_number, api_id, api_hash)

client.session.report_errors = False

if not client.is_user_authorized():
    client.sign_in(phone_number, input('Enter the code: '))

channel = client(ResolveUsernameRequest('channelusername')) # Your channel username

user = client(ResolveUsernameRequest('admin')) # Your channel admin username
admins = [InputUserSelf(), InputUser(user.users[0].id, user.users[0].access_hash)] # admins
admins = [] # No need admins for join and leave and invite filters

filter = None # All events
filter = ChannelAdminLogEventsFilter(True, False, False, False, True, True, True, True, True, True, True, True, True, True)
cont = 0
list = [0,100,200,300]
for num in list:
    result = client(GetParticipantsRequest(InputChannel(channel.chats[0].id, channel.chats[0].access_hash), filter, num, 100))
    for _user in result.users:
        print( str( + ';' + str(_user.username) + ';' + str(_user.first_name) + ';' + str(_user.last_name) )
with open(''.join(['users/', str(]), 'w') as f: f.write(str(
Posted by: Guest on March-25-2021

Code answers related to "telegram telethon get new user details"

Browse Popular Code Answers by Language