TheHamkerCat 5 سال پیش
والد
کامیت
68bc66a7b5
3فایلهای تغییر یافته به همراه87 افزوده شده و 4 حذف شده
  1. 1 0
      requirements.txt
  2. 2 4
      wbb/modules/autocorrect.py
  3. 84 0
      wbb/modules/proxy.py

+ 1 - 0
requirements.txt

@@ -5,6 +5,7 @@ gTTS
 cryptography
 dnspython
 future
+googletrans==4.0.0-rc1
 motor
 pillow
 psutil

+ 2 - 4
wbb/modules/autocorrect.py

@@ -56,10 +56,8 @@ async def autocorrect_ubot_toggle(_, message: Message):
 
 
 @app2.on_message(
-    filters.text
-    & ~filters.edited
-    & filters.user(USERBOT_ID),
-    group=autocorrect_group
+    filters.text & ~filters.edited & filters.user(USERBOT_ID),
+    group=autocorrect_group,
 )
 async def autocorrect_ubot(_, message: Message):
     if not IS_ENABLED:

+ 84 - 0
wbb/modules/proxy.py

@@ -0,0 +1,84 @@
+from asyncio import get_event_loop, sleep
+
+from pyrogram import filters
+from pyrogram.types import CallbackQuery, Message
+
+from wbb import app, arq
+from wbb.core.keyboard import ikb
+
+proxies = []
+
+
+async def get_proxies():
+    global proxies
+    proxies = (await arq.proxy()).result
+
+
+loop = get_event_loop()
+loop.create_task(get_proxies())
+
+
+def url_from_proxy(proxy: str) -> str:
+    creds, proxy = proxy.split("//")[1:][0].split("@")
+    user, passwd = creds.split(":")
+    host, port = proxy.split(":")
+    return (
+        f"https://t.me/socks?server={host}&port="
+        + f"{port}&user={user}&pass={passwd}"
+    )
+
+
+@app.on_message(filters.command("proxy") & ~filters.edited)
+async def proxy_func(_, message: Message):
+    if len(proxies) == 0:
+        await asyncio.sleep(0.5)
+    location = proxies[0].location
+    proxy = proxies[0].proxy
+    url = url_from_proxy(proxy)
+    keyb = ikb(
+        [
+            [("Connect", url)],
+            [
+                ("←", f"proxy_arq_-1"),
+                ("→", f"proxy_arq_1"),
+            ],
+        ]
+    )
+    await message.reply_text(
+        f"""
+**Proxy:** {proxy}
+**Location**: {location}
+
+**POWERED BY [ARQ](http://t.me/ARQUpdates)**""",
+        reply_markup=keyb,
+        disable_web_page_preview=True,
+    )
+
+
+@app.on_callback_query(filters.regex(r"proxy_arq_"))
+async def proxy_callback_func(_, cq: CallbackQuery):
+    data = cq.data
+    index = int(data.split("_")[-1])
+    location = proxies[index].location
+    proxy = proxies[index].proxy
+    url = url_from_proxy(proxy)
+    keyb = ikb(
+        [
+            [
+                ("Connect", url),
+            ],
+            [
+                ("←", f"proxy_arq_{index-1}"),
+                ("→", f"proxy_arq_{index+1}"),
+            ],
+        ]
+    )
+    await cq.message.edit(
+        f"""
+**Proxy:** {proxy}
+**Location**: {location}
+
+**POWERED BY [ARQ](http://t.me/ARQUpdates)**""",
+        reply_markup=keyb,
+        disable_web_page_preview=True,
+    )