Bladeren bron

added /log for owner

uwu
ポキ 5 jaren geleden
bovenliggende
commit
8f8a8a3702
3 gewijzigde bestanden met toevoegingen van 58 en 2 verwijderingen
  1. 44 0
      wbb/modules/log.py
  2. 2 2
      wbb/modules/stats.py
  3. 12 0
      wbb/utils/nekobin.py

+ 44 - 0
wbb/modules/log.py

@@ -0,0 +1,44 @@
+from pyrogram import filters, types
+import re
+from wbb.utils import cust_filter, nekobin
+from wbb import app, OWNER_ID
+
+@app.on_message(filters.user(OWNER_ID) & cust_filter.command("log"))
+async def logs_chat(client, message):
+    keyb = types.InlineKeyboardMarkup(
+        [
+            [
+                types.InlineKeyboardButton(
+                    "Paste on Nekobin", callback_data="paste_log_nekobin"
+                )
+            ]
+        ]
+    )
+    await message.reply_document(
+        "akagi/logs/error.log", caption="✨ **Here are my Logs ~**", reply_markup=keyb
+    )
+
+
+def logs_callback(_, __, query):
+    if re.match("paste_log_nekobin", query.data):
+        return True
+
+
+logs_create = filters.create(logs_callback)
+
+
+@app.on_callback_query(logs_create)
+async def paste_log_neko(client, query):
+    if query.from_user.id is OWNER_ID:
+        f = open("wbb/logs/error.log", "r")
+        data = await nekobin.neko(f.read())
+        keyb = types.InlineKeyboardMarkup(
+            [[types.InlineKeyboardButton("pasted on nekobin", url=f"{data}")]]
+        )
+        await query.message.edit_caption(
+            "Successfully Nekofied", reply_markup=keyb
+        )
+    else:
+        await client.answer_callback_query(
+            query.id, "Sike its not for you!", show_alert=True
+        )

+ 2 - 2
wbb/modules/stats.py

@@ -1,4 +1,4 @@
-from wbb import app
+from wbb import app, OWNER_ID
 from pyrogram import filters
 import psutil
 from wbb.utils import cust_filter
@@ -6,7 +6,7 @@ from wbb.utils import cust_filter
 __MODULE__ = "Stats"
 __HELP__ = "For Bot Owner to Check system Status"
 
-@app.on_message(cust_filter.command(commands=(["stats"])))
+@app.on_message(filters.user(OWNER_ID) & cust_filter.command(commands=(["stats"])))
 async def stats(client, message):
     cpu = psutil.cpu_percent(interval=0.5)
     mem = psutil.virtual_memory().percent

+ 12 - 0
wbb/utils/nekobin.py

@@ -0,0 +1,12 @@
+import aiohttp
+
+
+async def neko(data):
+    BASE_URL = "https://nekobin.com"
+    async with aiohttp.ClientSession() as session:
+        async with session.post(
+            f"{BASE_URL}/api/documents", json={"content": data}, timeout=3
+        ) as response:
+            key = (await response.json())["result"]["key"]
+            reply = f"{BASE_URL}/{key}"
+    return reply