TheHamkerCat 5 лет назад
Родитель
Сommit
007f8715c1
8 измененных файлов с 50 добавлено и 42 удалено
  1. 20 8
      wbb/modules/admin.py
  2. 3 2
      wbb/modules/global_stats.py
  3. 2 2
      wbb/modules/nsfw.py
  4. 14 10
      wbb/modules/rss.py
  5. 1 8
      wbb/modules/spam.py
  6. 1 0
      wbb/utils/dbfunctions.py
  7. 7 11
      wbb/utils/functions.py
  8. 2 1
      wbb/utils/rss.py

+ 20 - 8
wbb/modules/admin.py

@@ -31,7 +31,9 @@ from wbb.core.decorators.errors import capture_err
 from wbb.core.keyboard import ikb
 from wbb.core.keyboard import ikb
 from wbb.utils.dbfunctions import (add_warn, get_warn, int_to_alpha,
 from wbb.utils.dbfunctions import (add_warn, get_warn, int_to_alpha,
                                    remove_warns)
                                    remove_warns)
-from wbb.utils.functions import extract_user, extract_user_and_reason, time_converter
+from wbb.utils.functions import (extract_user,
+                                 extract_user_and_reason,
+                                 time_converter)
 
 
 __MODULE__ = "Admin"
 __MODULE__ = "Admin"
 __HELP__ = """/ban - Ban A User
 __HELP__ = """/ban - Ban A User
@@ -233,8 +235,10 @@ async def banFunc(_, message: Message):
             "I can't ban an admin, You know the rules, so do i."
             "I can't ban an admin, You know the rules, so do i."
         )
         )
     mention = (await app.get_users(user_id)).mention
     mention = (await app.get_users(user_id)).mention
-    msg = f"**Banned User:** {mention}\n" \
-          f"**Banned By:** {message.from_user.mention if message.from_user else 'Anon'}\n"
+    msg = (
+        f"**Banned User:** {mention}\n"
+        f"**Banned By:** {message.from_user.mention if message.from_user else 'Anon'}\n"
+    )
     if message.command[0][0] == "d":
     if message.command[0][0] == "d":
         await message.reply_to_message.delete()
         await message.reply_to_message.delete()
     if message.command[0] == "tban":
     if message.command[0] == "tban":
@@ -247,7 +251,9 @@ async def banFunc(_, message: Message):
             msg += f"**Reason:** {temp_reason}"
             msg += f"**Reason:** {temp_reason}"
         try:
         try:
             if len(time_value[:-1]) < 3:
             if len(time_value[:-1]) < 3:
-                await message.chat.kick_member(user_id, until_date=temp_ban)
+                await message.chat.kick_member(
+                    user_id, until_date=temp_ban
+                )
                 await message.reply_text(msg)
                 await message.reply_text(msg)
             else:
             else:
                 await message.reply_text("You can't use more than 99")
                 await message.reply_text("You can't use more than 99")
@@ -386,7 +392,9 @@ async def pin(_, message: Message):
 
 
 
 
 @app.on_message(
 @app.on_message(
-    filters.command(["mute", "tmute"]) & ~filters.edited & ~filters.private
+    filters.command(["mute", "tmute"])
+    & ~filters.edited
+    & ~filters.private
 )
 )
 @adminsOnly("can_restrict_members")
 @adminsOnly("can_restrict_members")
 async def mute(_, message: Message):
 async def mute(_, message: Message):
@@ -408,8 +416,10 @@ async def mute(_, message: Message):
     )
     )
     mention = (await app.get_users(user_id)).mention
     mention = (await app.get_users(user_id)).mention
     keyboard = ikb([[("🚨   Unmute   🚨", f"unmute_{user_id}")]])
     keyboard = ikb([[("🚨   Unmute   🚨", f"unmute_{user_id}")]])
-    msg = f"**Muted User:** {mention}\n" \
-          f"**Muted By:** {message.from_user.mention if message.from_user else 'Anon'}\n"
+    msg = (
+        f"**Muted User:** {mention}\n"
+        f"**Muted By:** {message.from_user.mention if message.from_user else 'Anon'}\n"
+    )
     if message.command[0] == "tmute":
     if message.command[0] == "tmute":
         split = reason.split(None, 1)
         split = reason.split(None, 1)
         time_value = split[0]
         time_value = split[0]
@@ -421,7 +431,9 @@ async def mute(_, message: Message):
         try:
         try:
             if len(time_value[:-1]) < 3:
             if len(time_value[:-1]) < 3:
                 await message.chat.restrict_member(
                 await message.chat.restrict_member(
-                    user_id, permissions=ChatPermissions(), until_date=temp_mute,
+                    user_id,
+                    permissions=ChatPermissions(),
+                    until_date=temp_mute,
                 )
                 )
                 await message.reply_text(msg, reply_markup=keyboard)
                 await message.reply_text(msg, reply_markup=keyboard)
             else:
             else:

+ 3 - 2
wbb/modules/global_stats.py

@@ -31,9 +31,10 @@ from wbb.modules import ALL_MODULES
 from wbb.utils.dbfunctions import (get_blacklist_filters_count,
 from wbb.utils.dbfunctions import (get_blacklist_filters_count,
                                    get_filters_count, get_gbans_count,
                                    get_filters_count, get_gbans_count,
                                    get_karmas_count, get_notes_count,
                                    get_karmas_count, get_notes_count,
+                                   get_rss_feeds_count,
                                    get_served_chats, get_served_users,
                                    get_served_chats, get_served_users,
-                                   get_warns_count, remove_served_chat,
-                                   get_rss_feeds_count)
+                                   get_warns_count,
+                                   remove_served_chat)
 from wbb.utils.http import get
 from wbb.utils.http import get
 from wbb.utils.inlinefuncs import keywords_list
 from wbb.utils.inlinefuncs import keywords_list
 
 

+ 2 - 2
wbb/modules/nsfw.py

@@ -127,8 +127,8 @@ async def nsfw_scan_command(_, message):
     file = await app.download_media(file_id)
     file = await app.download_media(file_id)
     try:
     try:
         results = await arq.nsfw_scan(file=file)
         results = await arq.nsfw_scan(file=file)
-    except Exception:
-        return
+    except Exception as e:
+        return await m.edit(str(e))
     remove(file)
     remove(file)
     if not results.ok:
     if not results.ok:
         return await m.edit(results.result)
         return await m.edit(results.result)

+ 14 - 10
wbb/modules/rss.py

@@ -34,16 +34,20 @@ async def rss_worker():
             await sleep(RSS_DELAY)
             await sleep(RSS_DELAY)
             continue
             continue
         for _feed in feeds:
         for _feed in feeds:
-            chat = _feed["chat_id"]
-            url = _feed["url"]
-            last_title = _feed.get("last_title")
-            feed = Feed(url)
-            if feed.title == last_title:
-                continue
-            await app.send_message(
-                chat, feed.parsed(), disable_web_page_preview=True
-            )
-            await update_rss_feed(chat, feed.title)
+            try:
+                chat = _feed["chat_id"]
+                url = _feed["url"]
+                last_title = _feed.get("last_title")
+                feed = Feed(url)
+                if feed.title == last_title:
+                    continue
+                await app.send_message(
+                    chat, feed.parsed(), disable_web_page_preview=True
+                )
+                await update_rss_feed(chat, feed.title)
+            except Exception as e:
+                print(str(e), "RSS")
+                pass
         t2 = time()
         t2 = time()
         if (t2 - t1) >= RSS_DELAY:
         if (t2 - t1) >= RSS_DELAY:
             continue
             continue

+ 1 - 8
wbb/modules/spam.py

@@ -139,14 +139,7 @@ async def spam_p_callback(_, cq: CallbackQuery):
             "Alerted",
             "Alerted",
             f"Deleted Message With {from_user.mention}'s Approval.",
             f"Deleted Message With {from_user.mention}'s Approval.",
         )
         )
-        await cq.message.edit(text)
-        if cq.message.reply_to_message:
-            text = f"**ADMINS OF {chat_id} FLAGGED THIS MESSAGE AS SPAM**\n\n"
-            text += f"`{cq.message.reply_to_message.text.markdown}`\n\n__{dev_forward}__"
-            return await app.send_message(
-                LOG_GROUP_ID, text, disable_web_page_preview=True
-            )
-        return
+        return await cq.message.edit(text)
 
 
     await cq.message.delete()
     await cq.message.delete()
     if cq.message.reply_to_message:
     if cq.message.reply_to_message:

+ 1 - 0
wbb/utils/dbfunctions.py

@@ -891,6 +891,7 @@ async def get_rss_feeds() -> list:
         )
         )
     return data
     return data
 
 
+
 async def get_rss_feeds_count() -> int:
 async def get_rss_feeds_count() -> int:
     feeds = rssdb.find({"chat_id": {"$exists": 1}})
     feeds = rssdb.find({"chat_id": {"$exists": 1}})
     feeds = await feeds.to_list(length=10000000)
     feeds = await feeds.to_list(length=10000000)

+ 7 - 11
wbb/utils/functions.py

@@ -24,12 +24,12 @@ SOFTWARE.
 import codecs
 import codecs
 import pickle
 import pickle
 from asyncio import gather, get_running_loop
 from asyncio import gather, get_running_loop
+from datetime import datetime, timedelta
 from io import BytesIO
 from io import BytesIO
 from math import atan2, cos, radians, sin, sqrt
 from math import atan2, cos, radians, sin, sqrt
 from random import randint
 from random import randint
 from re import findall
 from re import findall
 from time import time
 from time import time
-from datetime import timedelta, datetime
 
 
 import aiofiles
 import aiofiles
 import aiohttp
 import aiohttp
@@ -198,23 +198,19 @@ def get_urls_from_text(text: str) -> bool:
 
 
 async def time_converter(message: Message, time_value: str) -> int:
 async def time_converter(message: Message, time_value: str) -> int:
     unit = ["m", "h", "d"]  # m == minutes | h == hours | d == days
     unit = ["m", "h", "d"]  # m == minutes | h == hours | d == days
-    check_unit = ''.join(list(filter(time_value[-1].lower().endswith, unit)))
+    check_unit = "".join(
+        list(filter(time_value[-1].lower().endswith, unit))
+    )
     currunt_time = datetime.now()
     currunt_time = datetime.now()
     time_digit = time_value[:-1]
     time_digit = time_value[:-1]
     if not time_digit.isdigit():
     if not time_digit.isdigit():
         return await message.reply_text("Incorrect time specified")
         return await message.reply_text("Incorrect time specified")
     if check_unit == "m":
     if check_unit == "m":
-        temp_time = currunt_time + timedelta(
-            minutes=int(time_digit)
-        )
+        temp_time = currunt_time + timedelta(minutes=int(time_digit))
     elif check_unit == "h":
     elif check_unit == "h":
-        temp_time = currunt_time + timedelta(
-            hours=int(time_digit)
-        )
+        temp_time = currunt_time + timedelta(hours=int(time_digit))
     elif check_unit == "d":
     elif check_unit == "d":
-        temp_time = currunt_time + timedelta(
-            days=int(time_digit)
-        )
+        temp_time = currunt_time + timedelta(days=int(time_digit))
     else:
     else:
         return await message.reply_text("Incorrect time specified.")
         return await message.reply_text("Incorrect time specified.")
     return int(datetime.timestamp(temp_time))
     return int(datetime.timestamp(temp_time))

+ 2 - 1
wbb/utils/rss.py

@@ -1,5 +1,6 @@
 from feedparser import parse
 from feedparser import parse
 
 
+
 class Feed:
 class Feed:
     def __init__(self, url: str):
     def __init__(self, url: str):
         self.url = url
         self.url = url
@@ -29,7 +30,7 @@ class Feed:
             text += f"**Last Updated:** `{self.updated}`\n"
             text += f"**Last Updated:** `{self.updated}`\n"
         if self.summary:
         if self.summary:
             if "<div" not in self.summary:
             if "<div" not in self.summary:
-                text += f"**Summary:** __{self.summary.strip()}__\n"
+                text += f"**Summary:** {self.summary.strip()}\n"
 
 
         if text:
         if text:
             text = "\n".join([i.strip() for i in text.splitlines()])
             text = "\n".join([i.strip() for i in text.splitlines()])