>>>> client c1 created
Traceback (most recent call last):
File "C:/Users/Сергей/PycharmProjects/pythonProject7/Telegram-Invite-to-Channel-Group/invite_to_channel_group.py", line 78, in <module>
all_participants[key] = clients[key].get_participants(sour, aggressive=True)
File "C:\Users\Сергей\PycharmProjects\pythonProject7\pythonProject\lib\site-packages\telethon\sync.py", line 39, in syncified
return loop.run_until_complete(coro)
File "C:\Users\Сергей\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\Users\Сергей\PycharmProjects\pythonProject7\pythonProject\lib\site-packages\telethon\client\chats.py", line 507, in get_participants
return await self.iter_participants(*args, **kwargs).collect()
File "C:\Users\Сергей\PycharmProjects\pythonProject7\pythonProject\lib\site-packages\telethon\requestiter.py", line 113, in collect
async for message in self:
File "C:\Users\Сергей\PycharmProjects\pythonProject7\pythonProject\lib\site-packages\telethon\requestiter.py", line 74, in __anext__
if await self._load_next_chunk():
File "C:\Users\Сергей\PycharmProjects\pythonProject7\pythonProject\lib\site-packages\telethon\client\chats.py", line 222, in _load_next_chunk
results = await self.client(self.requests)
File "C:\Users\Сергей\PycharmProjects\pythonProject7\pythonProject\lib\site-packages\telethon\client\users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
File "C:\Users\Сергей\PycharmProjects\pythonProject7\pythonProject\lib\site-packages\telethon\client\users.py", line 80, in _call
raise MultiError(exceptions, results, requests)
telethon.errors.common.MultiError: ([FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), None, None, FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), None, FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)')], [None, <telethon.tl.types.channels.ChannelParticipants object at 0x000001E1E1683190>, <telethon.tl.types.channels.ChannelParticipants object at 0x000001E1E163AD60>, None, None, None, <telethon.tl.types.channels.ChannelParticipants object at 0x000001E1E1677EB0>, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None], [<telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E16513D0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E16511C0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E16512E0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651A90>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651B50>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651C10>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651CD0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651D90>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651E50>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651F10>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1651FD0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E16620D0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662190>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662250>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662310>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E16623D0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662550>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662610>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E16626D0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662790>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662850>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662910>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E16629D0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x000001E1E1662B50>])
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Scripts inviting members
#
from telethon import TelegramClient, sync, errors
from telethon.errors import SessionPasswordNeededError
from telethon.tl.functions.account import UpdateProfileRequest
from telethon.tl.functions.messages import AddChatUserRequest
from telethon.tl.functions.channels import InviteToChannelRequest
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
import python3pickledb as pickledb
from time import gmtime, strftime
import time, sys
import os.path
import random
# Need change those api to yours
c_info = {
'c0': ('cody_client1', 388159, 'b6337b1e003b7eax780fd2d77f7e0478')
}
if c_info['c1'][0] == 388159:
sys.exit('Need change api to yours')
sour = 'https://t.me/HR0408g' # отсюда берет
dest = 'https://t.me/test' # сюда добавляет
clients = {}
dests = {}
all_participants = {}
for key, value in c_info.items():
print('>> client %s creating' % key)
clients[key] = TelegramClient(*value)
clients[key].start()
print('>>>> client %s created' % key)
dests[key] = clients[key].get_entity(dest)
all_participants[key] = clients[key].get_participants(sour, aggressive=True)
print('Works!')
db = pickledb.load('clientbot_test.db', True)
ind = 0
if not db.get('start'):
db.set('start', ind)
else:
ind = int(db.get('start'))
print('Start from ', ind)
while True:
users = {}
for key, value in all_participants.items():
users[key] = value[ind]
for key, value in users.items():
if value == None:
sys.exit('All members (%d) done' % ind)
rd_ind = random.sample(list(clients.keys()), len(clients))[0]
print('>>>> client %s works' % rd_ind)
client = clients[rd_ind]
dest = dests[rd_ind]
user = users[rd_ind]
try:
client(InviteToChannelRequest(
dest,
[user],
))
print("%-6d: %-9d | @%s | %s | %s | Done" % (ind, user.id, user.username, user.first_name, user.last_name))
except errors.rpcerrorlist.UserPrivacyRestrictedError:
print('>>>>0. UserPrivacyRestrictedError...')
except errors.rpcerrorlist.ChatAdminRequiredError:
print('>>>>1. ChatAdminRequiredError...')
except errors.rpcerrorlist.ChatIdInvalidError:
print('>>>>2. ChatIdInvalidError...')
except errors.rpcerrorlist.InputUserDeactivatedError:
print('>>>>3. InputUserDeactivatedError...')
except errors.rpcerrorlist.PeerIdInvalidError:
print('>>>>4. PeerIdInvalidError...')
except errors.rpcerrorlist.UserAlreadyParticipantError:
print('>>>>5. UserAlreadyParticipantError...')
except errors.rpcerrorlist.UserIdInvalidError:
print('>>>>6. UserIdInvalidError...')
except errors.rpcerrorlist.UserNotMutualContactError:
print('>>>>>7. UserNotMutualContactError...')
except errors.rpcerrorlist.UsersTooMuchError:
print('>>>>>8. UsersTooMuchError...')
except errors.rpcerrorlist.PeerFloodError:
ind -= 1
print('>>>>>9. PeerFloodError try again in 2 Mins...')
continue
time.sleep(120) #тут нужно сделать многопоточность, что бы данный акк засыпал, а остальнгые работали
except errors.rpcerrorlist.UserChannelsTooMuchError:
ind += 1 # пропускает пльзователя, если его не возможно добавить
print('Пропускаем участника так как он в слишком многих каналах')
except errors.rpcerrorlist.FloodWaitError:
ind -= 1
print('Аккаунт в бане на время, нужно пропустить его на сутки ')
# CPU sleep
time.sleep(random.randint(10, 30))
ind += 1
db.set('start', ind)
use test1 ;
SET NAMES 'utf8';
SET CHARACTER SET 'utf8';
SET SESSION collation_connection = 'cp1251_general_ci';
SELECT
`firstname`,
`middlname`,
`lastname`,
`phone1`,
`phone2`,
`desired_profession`,
`email1`,
`payment`,
`pol`,
`birthday`,
`birthmonth`,
`birthyear`
FROM
profil
WHERE
town = 4
AND `desired_profession` REGEXP 'Бухгалтер';