remainsalways commited on
Commit
0204f56
·
verified ·
1 Parent(s): d544df2

Update devgagan/__init__.py

Browse files
Files changed (1) hide show
  1. devgagan/__init__.py +28 -21
devgagan/__init__.py CHANGED
@@ -1,6 +1,3 @@
1
- #devggn
2
-
3
-
4
  import asyncio
5
  import logging
6
  from pyromod import listen
@@ -8,6 +5,14 @@ from pyrogram import Client
8
  from config import API_ID, API_HASH, BOT_TOKEN
9
  from telethon.sync import TelegramClient
10
 
 
 
 
 
 
 
 
 
11
 
12
  loop = asyncio.get_event_loop()
13
 
@@ -16,32 +21,34 @@ logging.basicConfig(
16
  level=logging.INFO,
17
  )
18
 
19
- sex = TelegramClient('sexrepo', API_ID, API_HASH).start(bot_token=BOT_TOKEN)
 
 
 
 
 
 
20
 
 
21
  app = Client(
22
  ":RestrictBot:",
23
  api_id=API_ID,
24
  api_hash=API_HASH,
25
  bot_token=BOT_TOKEN,
26
- workers=10,
27
  sleep_threshold=20,
28
- max_concurrent_transmissions=5
 
29
  )
30
 
31
-
32
-
33
  async def restrict_bot():
34
  global BOT_ID, BOT_NAME, BOT_USERNAME
35
- await app.start()
36
- getme = await app.get_me()
37
- BOT_ID = getme.id
38
- BOT_USERNAME = getme.username
39
- if getme.last_name:
40
- BOT_NAME = getme.first_name + " " + getme.last_name
41
- else:
42
- BOT_NAME = getme.first_name
43
-
44
-
45
- loop.run_until_complete(restrict_bot())
46
-
47
-
 
 
 
 
1
  import asyncio
2
  import logging
3
  from pyromod import listen
 
5
  from config import API_ID, API_HASH, BOT_TOKEN
6
  from telethon.sync import TelegramClient
7
 
8
+ # --- Proxy Configuration ---
9
+ PROXY_CONFIG = {
10
+ "scheme": "http", # Or "socks5"
11
+ "hostname": "154.196.33.209",
12
+ "port": 63452,
13
+ "username": "L4SzFXFkA",
14
+ "password": "EC43VV3LU"
15
+ }
16
 
17
  loop = asyncio.get_event_loop()
18
 
 
21
  level=logging.INFO,
22
  )
23
 
24
+ # Telethon Proxy Setup
25
+ sex = TelegramClient(
26
+ 'sexrepo',
27
+ API_ID,
28
+ API_HASH,
29
+ proxy=(PROXY_CONFIG['scheme'], PROXY_CONFIG['hostname'], PROXY_CONFIG['port'], True, PROXY_CONFIG['username'], PROXY_CONFIG['password'])
30
+ ).start(bot_token=BOT_TOKEN)
31
 
32
+ # Pyrogram Proxy Setup
33
  app = Client(
34
  ":RestrictBot:",
35
  api_id=API_ID,
36
  api_hash=API_HASH,
37
  bot_token=BOT_TOKEN,
38
+ workers=20,
39
  sleep_threshold=20,
40
+ max_concurrent_transmissions=5,
41
+ proxy=PROXY_CONFIG # Pyrogram accepts a dictionary
42
  )
43
 
 
 
44
  async def restrict_bot():
45
  global BOT_ID, BOT_NAME, BOT_USERNAME
46
+ async with app: # Using context manager is safer
47
+ getme = await app.get_me()
48
+ BOT_ID = getme.id
49
+ BOT_USERNAME = getme.username
50
+ BOT_NAME = f"{getme.first_name} {getme.last_name}" if getme.last_name else getme.first_name
51
+ print(f"Bot started as {BOT_NAME}")
52
+
53
+ if __name__ == "__main__":
54
+ loop.run_until_complete(restrict_bot())