forked from neluckoff/telegram_spam_userbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
86 lines (72 loc) · 3.66 KB
/
bot.py
File metadata and controls
86 lines (72 loc) · 3.66 KB
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
from pyrogram import Client, filters
from asyncio import sleep
from random import randint
from art import tprint
from pathlib import Path
from config import api_id, api_hash, phone_number
app = Client("my_account", api_id=28303272,
api_hash=39bb8e386ca54538ae031dd514fb6552, phone_number=+393714099692)
def spam_message():
if Path('./spam_files/text.md').is_file():
md_str = ''
with open(r"./spam_files/text.md", "r", encoding="utf-8") as file:
for line in file:
md_str += line
return md_str
elif Path('./spam_files/text.txt').is_file():
txt_str = ''
with open(r"./spam_files/text.txt", "r", encoding="utf-8") as file:
for line in file:
txt_str += line
return txt_str
else:
print('[ERROR] Text file not found!')
def check_image():
path = './spam_files/image.png'
if Path(path).is_file() and (Path(path).suffix == ".png" or Path(path).suffix == ".jpg"
or Path(path).suffix == ".jpeg"):
return True
else:
return False
@app.on_message(filters.command('start', prefixes='/') & filters.me)
async def start_spamming(client, message):
# Получение всех пользователей и чатов
spam_msg = spam_message()
chats = []
async for dialog in app.get_dialogs():
chats.append({'dialog': dialog.chat.first_name or dialog.chat.title, 'id': dialog.chat.id})
# Проход по всем пользователям и отправка спам сообщения
if not check_image():
print('[+] Start spam mailing without image')
for chat in chats:
await app.send_message(chat['id'], spam_msg)
chat_name = chat['dialog']
print(f'[+] {chat_name} received spam')
await sleep(randint(1, 3)) # Кулдаун на отправку сообщений
else:
print('[+] Start spam mailing with image')
for chat in chats:
await app.send_photo(chat['id'], "./spam_files/image.png", caption=spam_msg)
chat_name = chat['dialog']
print(f'[+] {chat_name} received spam')
await sleep(randint(1, 3)) # Кулдаун на отправку сообщений
@app.on_message(filters.command('check', prefixes='/') & filters.me)
async def check_msg(client, message):
spam_msg = spam_message()
if not check_image():
await message.reply(spam_msg)
else:
await message.reply_photo("./spam_files/image.png", caption=spam_msg)
@app.on_message(filters.command('help', prefixes='/') & filters.me)
async def help_msg(client, message):
text = f"**[1]** Telegram принимает сообщения в разметке Markdown, поэтому если Вы хотите красивое" \
f" спам-сообщение, в папке spam_files создайте файл text.md и заполните его текстом. Если Вы" \
f" не хотите делать его красивым, создайте text.txt.\n" \
f"**[2]** Для отправки рассылки с фотографией в папку spam_files добавьте любое фото форматов .png " \
f".jpg .jpeg и назовите его image.\n" \
f"**[3]** Для проверки Вашего сообщения перед отправкой пользователям имеется команда " \
f"**/check**, которая выведет Вам ваше сообщение."
await message.reply(text)
if __name__ == '__main__':
tprint("TG-Spammer")
app.run()