TheHamkerCat 5 anni fa
parent
commit
2b3029cb6f

+ 2 - 1
.gitignore

@@ -2,7 +2,7 @@
 __pycache__/
 *.py[cod]
 *$py.class
-
+.
 # C extensions
 *.so
 
@@ -135,3 +135,4 @@ dmypy.json
 neofetch.txt
 error.log
 permissions.json
+.vscode

+ 0 - 6
.vscode/settings.json

@@ -1,6 +0,0 @@
-{
-    "python.linting.flake8Enabled": false,
-    "python.linting.pylintEnabled": true,
-    "python.linting.enabled": true,
-    "python.pythonPath": "/usr/bin/python"
-}

+ 0 - 1
wbb/__init__.py

@@ -4,7 +4,6 @@ from configparser import ConfigParser
 from pyrogram import Client
 
 
-
 f = open("error.log", "w")
 f.write("PEAK OF LOG FILE")
 

+ 14 - 12
wbb/modules/admin.py

@@ -1,6 +1,6 @@
 from wbb import OWNER_ID, SUDO_USER_ID, app
 from wbb.utils import cust_filter
-
+from pyrogram.types import Message
 
 __MODULE__ = "Admin"
 __HELP__ = "/purge - Purge Messages\n" \
@@ -33,7 +33,7 @@ async def list_members(group_id):
 
 
 @app.on_message(cust_filter.command(commands=("purge")))
-async def purge(client, message):
+async def purge(client, message: Message):
     message_ids = []
     if message.chat.type not in (("supergroup", "channel")):
         return
@@ -43,11 +43,13 @@ async def purge(client, message):
     if message.from_user.id in admins \
             or message.from_user.id in SUDO:
 
-        if (await app.get_chat_member(message.chat.id, message.from_user.id
-            )).can_delete_messages is True \
-                or (await app.get_chat_member(            # Flake8 Hoe
-                    message.chat.id, message.from_user.id
-                        )).status == 'creator' or message.from_user.id in SUDO:
+        chat_id = message.chat.id
+        from_user_id = message.from_user.id
+        if (await app.get_chat_member(chat_id,
+                                      from_user_id)).can_delete_messages \
+                or (await app.get_chat_member(chat_id, from_user_id)).status \
+                == 'creator' \
+                or message.from_user.id in SUDO:
 
             if message.reply_to_message:
                 for a_s_message_id in range(
@@ -79,7 +81,7 @@ async def purge(client, message):
 
 
 @app.on_message(cust_filter.command(commands=("kick")))
-async def kick(client, message):
+async def kick(client, message: Message):
     try:
         username = (message.text.split(None, 2)[1])
     except IndexError:
@@ -122,7 +124,7 @@ async def kick(client, message):
 
 
 @app.on_message(cust_filter.command(commands=("ban")))
-async def ban(client, message):
+async def ban(client, message: Message):
     try:
         username = (message.text.split(None, 2)[1])
     except IndexError:
@@ -162,7 +164,7 @@ async def ban(client, message):
 
 
 @app.on_message(cust_filter.command(commands=("unban")))
-async def unban(client, message):
+async def unban(client, message: Message):
     try:
         username = (message.text.split(None, 2)[1])
     except IndexError:
@@ -195,7 +197,7 @@ async def unban(client, message):
 
 
 @app.on_message(cust_filter.command(commands=("kickme")))
-async def kickme(client, message):
+async def kickme(client, message: Message):
     if message.from_user.id not in SUDO:
         await message.chat.kick_member(message.from_user.id)
         await message.chat.unban_member(message.from_user.id)
@@ -207,7 +209,7 @@ async def kickme(client, message):
 
 
 @app.on_message(cust_filter.command(commands=("banme")))
-async def banme(client, message):
+async def banme(client, message: Message):
     if message.from_user.id not in SUDO:
         await message.chat.kick_member(message.from_user.id)
         await message.reply_text("Banned!, Joke's on you, I'm into that shit")

+ 2 - 2
wbb/modules/greetings.py

@@ -1,12 +1,12 @@
 from wbb import app
 from pyrogram import filters, emoji
-
+from pyrogram.types import Message
 
 MESSAGE = "{} Welcome {}!"
 
 
 @app.on_message(filters.new_chat_members)
-async def welcome(client, message):
+async def welcome(client, message: Message):
     new_members = [i.mention for i in message.new_chat_members]
     text = MESSAGE.format(emoji.CROWN, ",  ".join(new_members))
     await message.reply_text(text, disable_web_page_preview=True)

+ 13 - 5
wbb/modules/images.py

@@ -4,6 +4,8 @@ import urllib.request
 import json
 from random import randint
 import requests as r
+import asyncio
+from pyrogram.types import Message
 
 __MODULE__ = "Images"
 __HELP__ = "/cat - Get Cute Cats Images\n" + \
@@ -11,8 +13,13 @@ __HELP__ = "/cat - Get Cute Cats Images\n" + \
            "/wall [something] - Get Wallpapers"
 
 
+async def delete_message_with_delay(delay, message: Message):
+    await asyncio.sleep(delay)
+    (message).delete()
+
+
 @app.on_message(cust_filter.command(commands=("cat")))
-async def cat(client, message):
+async def cat(client, message: Message):
     with urllib.request.urlopen(
         "https://api.thecatapi.com/v1/images/search"
     ) as url:
@@ -22,7 +29,7 @@ async def cat(client, message):
 
 
 @app.on_message(cust_filter.command(commands=("dog")))
-async def dog(client, message):
+async def dog(client, message: Message):
     with urllib.request.urlopen(
         "https://api.thedogapi.com/v1/images/search"
     ) as url:
@@ -32,7 +39,7 @@ async def dog(client, message):
 
 
 @app.on_message(cust_filter.command(commands=("wall")))
-async def wall(client, message):
+async def wall(client, message: Message):
     app.set_parse_mode("markdown")
     m = await message.reply_text("Searching!")
     initial_term = (message.text.replace('/wall', ''))
@@ -47,7 +54,8 @@ async def wall(client, message):
     else:
         wallpapers = json_rep.get("wallpapers")
         if not wallpapers:
-            await m.edit("404")
+            await m.edit("Found literally nothing!,"
+                         + "You should work on your English.")
             return
         else:
             index = randint(0, len(wallpapers) - 1)
@@ -55,4 +63,4 @@ async def wall(client, message):
             wallpaper = wallpaper.get("url_image")
             wallpaper = wallpaper.replace("\\", "")
             await message.reply_document(wallpaper)
-    await m.delete()
+    await delete_message_with_delay(10, m)

+ 25 - 10
wbb/modules/misc.py

@@ -1,42 +1,57 @@
 from wbb import app
 from wbb.utils import cust_filter, random_line
+from pyrogram.types import Message
 
 __MODULE__ = "Misc"
 __HELP__ = "/commit - Generate Funny Commit Messages\n" \
            "/runs - Idk Test Yourself\n" \
            "/quote - Get Random Linux Quotes\n" \
-           "/id - Get Chat_ID or User_ID"
+           "/id - Get Chat_ID or User_ID\n" \
+           "/dev - Forward Anything To Developers [SPAM = GBAN]"
 
 
 @app.on_message(cust_filter.command(commands=("commit")))
-async def commit(client, message):
+async def commit(client, message: Message):
     await message.reply_text((await random_line('wbb/utils/commit.txt')))
 
 
 @app.on_message(cust_filter.command(commands=("runs")))
-async def runs(client, message):
+async def runs(client, message: Message):
     await message.reply_text((await random_line('wbb/utils/runs.txt')))
 
 
 @app.on_message(cust_filter.command(commands=("quote")))
-async def quote(client, message):
+async def quote(client, message: Message):
     await message.reply_text((await random_line('wbb/utils/quotes.txt')))
 
 
 @app.on_message(cust_filter.command(commands=("id")))
-async def id(client, message):
+async def id(client, message: Message):
+    app.set_parse_mode("markdown")
     if message.text != '/id':
         username = message.text.replace('/id', '')
         id = (await app.get_users(username)).id
-        msg = f"{username}'s ID is {id}"
+        msg = f"{username}'s ID is `{id}`"
         await message.reply_text(msg)
 
-    elif message.text == '/id' and bool(message.reply_to_message) is False:
+    elif message.text == '/id' and not bool(message.reply_to_message):
         id = message.chat.id
-        msg = f"{message.chat.title}'s ID is {id}"
+        msg = f"{message.chat.title}'s ID is `{id}`"
         await message.reply_text(msg)
 
-    elif message.text == '/id' and bool(message.reply_to_message) is True:
+    elif message.text == '/id' and bool(message.reply_to_message):
         id = message.reply_to_message.from_user.id
-        msg = f"{message.reply_to_message.from_user.first_name}'s ID is {id}"
+        msg = f"{message.reply_to_message.from_user.mention}'s ID is `{id}`"
         await message.reply_text(msg)
+
+
+@app.on_message(cust_filter.command(commands=("dev")))
+async def dev(client, message: Message):
+    app.set_parse_mode("markdown")
+    await message.reply_to_message.forward('WBBSupport')
+    await app.send_message("WBBSupport",
+                           f"Forwarded By ID: `{message.from_user.id}`")
+    await message.reply_text("Your Message Has Been Forward To Devs,"
+                             + " Any Missuse Of This Feature Will Not"
+                             + " Be Tolerated And You Will Be"
+                             + " Gbanned instantaneously!")

+ 2 - 1
wbb/modules/music.py

@@ -4,6 +4,7 @@ import youtube_dl
 from wbb.utils import cust_filter
 from wbb import app
 import os
+from pyrogram.types import Message
 
 __MODULE__ = "Music"
 __HELP__ = "/music [link] To Download Music From Various Websites"
@@ -15,7 +16,7 @@ ydl_opts = {
 
 
 @app.on_message(cust_filter.command(commands=("music")))
-async def music(client, message):
+async def music(client, message: Message):
     await message.reply_chat_action("typing")
     app.set_parse_mode("html")
     try:

+ 2 - 1
wbb/modules/paste.py

@@ -1,6 +1,7 @@
 from wbb.utils import cust_filter, nekobin
 from wbb import app
 import os
+from pyrogram.types import Message
 
 
 __MODULE__ = "Paste"
@@ -8,7 +9,7 @@ __HELP__ = "/paste - To Paste Replied Text Or Document To Neokobin"
 
 
 @app.on_message(cust_filter.command(commands=("paste")))
-async def paste(client, message):
+async def paste(client, message: Message):
     if bool(message.reply_to_message) is True:
         app.set_parse_mode("markdown")
         if bool(message.reply_to_message.text) is True:

+ 2 - 1
wbb/modules/ping.py

@@ -1,13 +1,14 @@
 from wbb import app
 from wbb.utils import cust_filter
 import requests
+from pyrogram.types import Message
 
 __MODULE__ = "Ping"
 __HELP__ = " /ping - To Get Response Time From All TG Datacenters"
 
 
 @app.on_message(cust_filter.command(commands=("ping")))
-async def ping(client, message):
+async def ping(client, message: Message):
     app.set_parse_mode("markdown")
     m = await message.reply_text("```Wait, Pinging all Datacenters```")
     result = ""

+ 2 - 1
wbb/modules/repo.py

@@ -1,5 +1,6 @@
 from wbb import app
 from wbb.utils import cust_filter
+from pyrogram.types import Message
 
 
 __MODULE__ = "Repo"
@@ -8,7 +9,7 @@ __HELP__ = "/repo - To Get My Github Repository Link" + \
 
 
 @app.on_message(cust_filter.command(commands=("repo")))
-async def repo(client, message):
+async def repo(client, message: Message):
     app.set_parse_mode("markdown")
     await message.reply_text(
         "[Github](https://github.com/thehamkercat/WilliamButcherBot)"

+ 3 - 3
wbb/modules/rice.py

@@ -1,6 +1,7 @@
 from wbb import app
 from wbb.utils import cust_filter
 from pyrogram import filters
+from pyrogram.types import Message
 
 
 __MODULE__ = "Rice"
@@ -9,13 +10,12 @@ __HELP__ = "/rice - To Forward Your Linux Rice To DE_WM's" \
 
 
 @app.on_message(filters.chat('DE_WM') & cust_filter.command(commands=("rice")))
-async def rice(client, message):
+async def rice(client, message: Message):
     if bool(message.reply_to_message) is True:
         app.set_parse_mode("markdown")
-        m = await message.reply_text("```Forwarding!```")
         id = message.reply_to_message.from_user.id
         await message.reply_to_message.forward('RiceGallery')
-        await m.edit(
+        await message.reply_text(
             f"[Your](tg://user?id={id}) Rice Forwared"
             " To [Rice Gallery](https://t.me/RiceGallery)",
             disable_web_page_preview=True)

+ 4 - 3
wbb/modules/sudoers.py

@@ -1,6 +1,7 @@
 from wbb.utils import cust_filter, nekobin, formatter
 from wbb import app, OWNER_ID, SUDO_USER_ID, bot_start_time, NEOFETCH
 from pyrogram import filters, types
+from pyrogram.types import Message
 import re
 import speedtest
 import psutil
@@ -21,7 +22,7 @@ SUDOERS = [OWNER_ID, SUDO_USER_ID]
 
 
 @app.on_message(filters.user(SUDOERS) & cust_filter.command("log"))
-async def logs_chat(client, message):
+async def logs_chat(client, message: Message):
     keyb = types.InlineKeyboardMarkup(
         [
             [
@@ -76,7 +77,7 @@ def speed_convert(size):
 @app.on_message(
     filters.user(SUDOERS) & cust_filter.command(commands=("speedtest"))
 )
-async def speeeed(client, message):
+async def speeeed(client, message: Message):
     app.set_parse_mode("markdown")
     m = await message.reply_text("```Performing A Speedtest!```")
     speed = speedtest.Speedtest()
@@ -95,7 +96,7 @@ Latency  - {round((x["latency"]))} ms
 @ app.on_message(
     filters.user(SUDOERS) & cust_filter.command(commands=("stats"))
 )
-async def stats(client, message):
+async def stats(client, message: Message):
     bot_uptime = int(time.time() - bot_start_time)
     cpu = psutil.cpu_percent(interval=0.5)
     mem = psutil.virtual_memory().percent