python - 多账户加法器电报的 api 脚本
问题描述
嗨,我正在开发一个多添加电报成员,这里是代码:
ffrom telethon.sync import TelegramClient
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty
import csv
api_id = 5961821 #Enter Your 7 Digit Telegram API ID.
api_hash = 'bcc6ac1940207e2c7c460413b90efdaa' #Enter Yor 32 Character API Hash.
phone = '21695953978' #Enter Your Mobilr Number With Country Code.
client = TelegramClient(phone, api_id, api_hash)
async def main():
# Now you can use all client methods listed below, like for example...
await client.send_message('me', 'Hello !!!!')
with client:
client.loop.run_until_complete(main())
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
client.sign_in(phone, input('Enter verification code: '))
chats = []
last_date = None
chunk_size = 200
groups=[]
result = client(GetDialogsRequest(
offset_date=last_date,
offset_id=0,
offset_peer=InputPeerEmpty(),
limit=chunk_size,
hash = 0
))
chats.extend(result.chats)
for chat in chats:
try:
if chat.megagroup== True:
groups.append(chat)
except:
continue
print('From Which Group Yow Want To Scrape Members:')
i=0
for g in groups:
print(str(i) + '- ' + g.title)
i+=1
g_index = input("Please! Enter a Number: ")
target_group=groups[int(g_index)]
print('Fetching Members...')
all_participants = []
all_participants = client.get_participants(target_group, aggressive=True)
print('Saving In file...')
with open("Scraped.csv","w",encoding='UTF-8') as f:#Enter your file name.
writer = csv.writer(f,delimiter=",",lineterminator="\n")
writer.writerow(['username','user id', 'access hash','name','group', 'group id'])
for user in all_participants:
if user.username:
username= user.username
else:
username= ""
if user.first_name:
first_name= user.first_name
else:
first_name= ""
if user.last_name:
last_name= user.last_name
else:
last_name= ""
name= (first_name + ' ' + last_name).strip()
writer.writerow([username,user.id,user.access_hash,name,target_group.title, target_group.id])
print('Members scraped successfully.......')
我怎么做才能添加带有多个电话号码的多个 API?我的目标是能够同时访问多个 API 文件并使用它们,而不是像这个脚本中那样只使用一个。
我想访问多个电话号码,而不是像此脚本中的一个。脚本使用第一个然后添加第二个和第三个......我想同时访问多个帐户以避免洪水错误和每天添加50个成员的限制。
太谢谢了!
解决方案
推荐阅读
- javascript - Make imported code run only in specific page [Module Pattern + ES6]
- php - PHP+PSR7:getParsedBody() 总是将 json 上的空字符串转换为 null
- javascript - How to loop through JSON array and get specific values
- r - Multiple inputs to reactive value R Shiny
- java - RxJava 在没有响应体时捕获网络响应代码
- javascript - how to use @types/module in combination with with npm module that types are written for?
- python - Python Heads or Tails 游戏,除了子句不显示
- r - Concatenate and count the number of elements in each row?
- macos - 具有匹配宽度 DocumentView 的 NSScrollView
- sql - Syntax error while fetching table list from teradata using python