File size: 1,472 Bytes
6b1e8b6
 
 
 
 
 
 
0204f56
 
 
 
 
 
 
 
6b1e8b6
 
 
 
 
 
 
 
0204f56
 
 
 
 
 
 
6b1e8b6
0204f56
6b1e8b6
 
 
 
 
0204f56
6b1e8b6
0204f56
 
6b1e8b6
 
 
 
0204f56
 
 
 
 
 
 
 
 
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
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())