src / devgagan /__init__.py
remainsalways's picture
Update devgagan/__init__.py
0204f56 verified
import asyncio
import logging
from pyromod import listen
from pyrogram import Client
from config import API_ID, API_HASH, BOT_TOKEN
from telethon.sync import TelegramClient
# --- Proxy Configuration ---
PROXY_CONFIG = {
"scheme": "http", # Or "socks5"
"hostname": "154.196.33.209",
"port": 63452,
"username": "L4SzFXFkA",
"password": "EC43VV3LU"
}
loop = asyncio.get_event_loop()
logging.basicConfig(
format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s",
level=logging.INFO,
)
# Telethon Proxy Setup
sex = TelegramClient(
'sexrepo',
API_ID,
API_HASH,
proxy=(PROXY_CONFIG['scheme'], PROXY_CONFIG['hostname'], PROXY_CONFIG['port'], True, PROXY_CONFIG['username'], PROXY_CONFIG['password'])
).start(bot_token=BOT_TOKEN)
# Pyrogram Proxy Setup
app = Client(
":RestrictBot:",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workers=20,
sleep_threshold=20,
max_concurrent_transmissions=5,
proxy=PROXY_CONFIG # Pyrogram accepts a dictionary
)
async def restrict_bot():
global BOT_ID, BOT_NAME, BOT_USERNAME
async with app: # Using context manager is safer
getme = await app.get_me()
BOT_ID = getme.id
BOT_USERNAME = getme.username
BOT_NAME = f"{getme.first_name} {getme.last_name}" if getme.last_name else getme.first_name
print(f"Bot started as {BOT_NAME}")
if __name__ == "__main__":
loop.run_until_complete(restrict_bot())