-
Notifications
You must be signed in to change notification settings - Fork 10
/
invite_to_channel_group.py
117 lines (94 loc) · 3.59 KB
/
invite_to_channel_group.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Scripts inviting members
#
# By @CodyDoby
# Telegram Group: https://t.me/google_dive
# Blog: https://gfan.loan/
#
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'),
'c1': ('cody_client2', 388159, 'b6337b1e003b7ea8780fd2d77f7e0478'),
'c2': ('cody_client3', 388159, 'b6337b1e003b7ea8780fd2d77f7e0478'),
'c3': ('cody_client5', 388159, 'b6337b1e003b7ea8780fd2d77f7e0478')
}
if c_info['c0'][1] == 388159:
sys.exit('Need change api to yours')
sour = 'three001'
#sour = 'https://t.me/hao1234fuck'
#dest = 'three004'
dest = 'google_drive'
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...')
time.sleep(120)
# CPU sleep
time.sleep(random.randint(10, 30))
ind += 1
db.set('start', ind)