Telegram
telegron登录:
async with TelegramClient(account, api_id, api_hash, proxy=proxy) as client:
需要发送一条信息之后才能显示online
await client.send_message("me",str(talkTime))
此时5分钟以后自动下线
防止下线,5分钟以内给自己发个信息
while 1:
talkTime=random.randint(200,250)
await client.send_message("me",str(talkTime))
print(account,"发送成功")
await asyncio.sleep(talkTime)
telethon获取群成员:
方式一
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch
from time import sleep
offset = 0
limit = 100
all_participants = []
while True:
participants = client(GetParticipantsRequest(
channel, ChannelParticipantsSearch(''), offset, limit,
hash=0
))
if not participants.users:
break
all_participants.extend(participants.users)
offset += len(participants.users)
但是我测试了发现limit最多一次取202个,而且最终获取到的offset是10000,更多就获取不到了。
方式二
members=await client.get_participants(channel,aggressive=False)
官方文档上说如果需要获取超过10000的人,应该使用方式二,而且aggressive=True,我测试的账号群内成员8w,aggressive=True依然会报错。