Skip to content

Instantly share code, notes, and snippets.

@AlgorithmAlchemy
Last active June 29, 2023 10:44
Show Gist options
  • Save AlgorithmAlchemy/2c56ec0a085c274337d81c00c49ef7ab to your computer and use it in GitHub Desktop.
Save AlgorithmAlchemy/2c56ec0a085c274337d81c00c49ef7ab to your computer and use it in GitHub Desktop.
tg_mailing
import os
import time
from threading import Thread
from opentele.td import TDesktop
from opentele.api import UseCurrentSession
accounts = os.listdir(os.path.abspath('input/telegram_accounts'))
async def telegram_attack(target, time_a, mes):
t = time.monotonic()
while time.monotonic() - t < time_a:
for user in accounts:
acc = os.path.abspath('input/telegram_accounts/' + user + '/tdata')
tempmas = os.listdir(os.path.abspath('input/telegram_accounts/' + user))
if acc[-8:] == '.session':
acc = acc.replace('.session', '')
if acc[-18:] == '.session - journal':
acc = acc.replace('.session - journal', '')
if f'{acc}.session' not in tempmas:
tdesk = TDesktop(acc)
client = await tdesk.ToTelethon(f"{acc}.session", UseCurrentSession)
else:
tdesk = TDesktop(acc)
client = await tdesk.ToTelethon(session=f"{acc}.session", flag=UseCurrentSession)
try:
await client.connect()
await client.send_message(target, mes)
await client.disconnect()
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment