-
Notifications
You must be signed in to change notification settings - Fork 0
/
spam.py
89 lines (73 loc) · 2.56 KB
/
spam.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
from telethon import TelegramClient
from telethon.errors import rpcerrorlist, FloodWaitError, ChatWriteForbiddenError
import time
import os
try:
import progressbar
except ModuleNotFoundError:
print("install > pip install progressbar2")
if os.path.isfile('spamer.txt'):
with open('spamer.txt', 'r') as r:
data = r.readlines()
api_id = int(data[0])
api_hash = data[1]
else:
api_id = input('Enter api_id: ')
api_hash = input('Enter api_hash: ')
with open('spamer.txt', 'w') as a:
a.write(api_id + '\n' + api_hash)
client = TelegramClient('spamer', api_id, api_hash)
async def main():
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
global target
print('''Spam Bot''')
print('\n\nhere is your chats, Please choose a target...')
i = 0
dialogs = await client.get_dialogs()
for dialog in dialogs:
print(i, ':', dialog.name, 'has ID', dialog.id)
i = i + 1
confirm = False
max = len(dialogs) - 1
while confirm == False:
target_index = -1
# Get target chat
while target_index < 0 or target_index > max:
print('Please insert target between 0 and', max)
target_index = int(input())
if target_index < 0 | target_index > max:
print('target out of range')
target = dialogs[target_index]
print('target is', target.name, 'with ID', target.id)
# Wait for confirm
print('Correct? Y/N')
reply = input()[0]
if reply == 'Y' or reply == 'y':
confirm = True
message = input("Enter the message to send here: ")
Several = int(input("How many messages do you want to send?\n"))
print("If you made some mistake with target, this is the last time you can Ctrl-Z")
print('Start spaming in 3 sec...')
time.sleep(3)
print("[+] The spam started")
bar = progressbar.ProgressBar(
widgets=[progressbar.SimpleProgress()],
max_value=Several,
).start()
try:
for i in range(int(Several)):
await client.send_message(target.id, message)
bar.update(i + 1)
bar.finish()
print("[+] spam successful")
except rpcerrorlist.ChatAdminRequiredError:
print("[!] You do not have permission to post messages in this chat!")
except ChatWriteForbiddenError:
print("[!] You have been restricted to writing messages in this chat...!")
except FloodWaitError:
print("[!] Try again after one hour")
with client:
client.loop.run_until_complete(main())