-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathAutoTelegram.py
More file actions
30 lines (24 loc) · 1 KB
/
AutoTelegram.py
File metadata and controls
30 lines (24 loc) · 1 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
from telethon.sync import TelegramClient
from telethon.errors import TimedOutError, TimeoutError, UserPrivacyRestrictedError, FloodWaitError
import config
client = TelegramClient("session", config.api_id, config.api_hash)
client.connect()
if not client.is_user_authorized():
client.send_code_request(config.phone)
client.sign_in(config.phone, input('Enter the code: '))
user = client.get_entity(input("User phone, or username: "))
times = int(input("How many times to send: "))
message = input("Message: ")
print("!WARNING! You may get ban or restrictions for your account! Use at your own risk!")
if input("Are you sure? (y/n) ").lower() != "y":
print("Aborting...")
exit(0)
for i in range(times):
try:
client.send_message(user, message)
except TimeoutError | TimedOutError | FloodWaitError:
print("Telegram blocked you for flodding")
except UserPrivacyRestrictedError:
print("User cant accept messages")
except Exception as e:
print("Unknown error:", e)