BanBot / code4.py
SoulofSukuna's picture
Update code4.py
9bb6939 verified
Raw History Blame Contribute Delete
1.16 kB
import os
from telethon.sync import TelegramClient, events
from telethon.tl.functions.messages import ImportChatInviteRequest
from telethon.tl.custom import Button
import random
import logging
api_id = "28810829"
api_hash = "d3f304bbd0b69b8c30dbec4be5824748"
bot_token = os.getenv("BOT_TOKEN")
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
client = TelegramClient("my_bot", api_id, api_hash).start(bot_token=bot_token)
links = ['https://t.me/+AiYPUMktDuM5NTQ1', 'https://t.me/+BF0KKVRO--JjYzI1', 'https://t.me/+59ACyg7MTWk3Yjg1', 'https://t.me/+wIHlZL1ugTcyN2Jl']
@client.on(events.NewMessage)
async def handle_new_message(event):
if event.is_private:
return
elif event.message.chat.id == -1001141878146:
return
elif event.sender_id == (await client.get_me()).id:
return
else:
group_invite_link = random.choice(links)
await event.delete()
await client.send_message(event.chat_id, f"@{event.sender.username}, If you'd like to join our group, click the button below:", buttons=[[Button.url("Join Group", group_invite_link)]])
client.run_until_disconnected()