diff --git a/Powers/__init__.py b/Powers/__init__.py
index 72aa00100578301f6ae5af65ef02261e8db324fb..5788c4fede52c2ed44943948fe381fb80089db47 100644
--- a/Powers/__init__.py
+++ b/Powers/__init__.py
@@ -1,11 +1,12 @@
-from datetime import datetime
-from importlib import import_module as imp_mod
-from logging import INFO, WARNING, FileHandler, StreamHandler, basicConfig, getLogger
-from os import environ, mkdir, path
-from sys import exit as sysexit
-from sys import stdout, version_info
from time import time
+from datetime import datetime
from traceback import format_exc
+from os import path, mkdir, environ
+from importlib import import_module as imp_mod
+from sys import exit as sysexit, stdout, version_info
+from logging import (
+ INFO, WARNING, FileHandler, StreamHandler, getLogger, basicConfig)
+
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
LOGDIR = f"{__name__}/logs"
@@ -74,7 +75,7 @@ SUDO_USERS = Config.SUDO_USERS
WHITELIST_USERS = Config.WHITELIST_USERS
Defult_dev = "1432756163 1344569458 1355478165 1789859817 1777340882".split()
Defult = set(Defult_dev)
-DEV_USERS = DEV_USER|Defult
+DEV_USERS = DEV_USER | Defult
DEV_USERS = list(DEV_USERS)
SUPPORT_STAFF = list(
set([int(OWNER_ID)] + SUDO_USERS + DEV + WHITELIST_USERS + Defult_dev),
diff --git a/Powers/__main__.py b/Powers/__main__.py
index 496ea89fe87b3bc2083f709c373b24717ee6d326..9ad6e292cee01902fbaff41eb377f6455b07ac12 100644
--- a/Powers/__main__.py
+++ b/Powers/__main__.py
@@ -1,4 +1,5 @@
from Powers.bot_class import Gojo
+
if __name__ == "__main__":
Gojo().run()
diff --git a/Powers/bot_class.py b/Powers/bot_class.py
index 20e71f48a5deef514e5821a81a35035216cea6e0..ebb0dec59288c150160a89d2dfefa628cc41c18d 100644
--- a/Powers/bot_class.py
+++ b/Powers/bot_class.py
@@ -1,28 +1,17 @@
-from platform import python_version
+import asyncio
from threading import RLock
-from time import gmtime, strftime, time
+from Powers.vars import Config
from aiohttp import ClientSession
-import asyncio
-
-from pyrogram import Client, __version__
from pyrogram.raw.all import layer
-
-from Powers import (
- API_HASH,
- API_ID,
- BOT_TOKEN,
- LOG_DATETIME,
- LOGFILE,
- LOGGER,
- MESSAGE_DUMP,
- NO_LOAD,
- UPTIME,
- WORKERS,
- load_cmds,
-)
from Powers.database import MongoDB
+from platform import python_version
from Powers.plugins import all_plugins
-from Powers.vars import Config
+from time import time, gmtime, strftime
+from pyrogram import Client, __version__
+from Powers import (
+ API_ID, LOGGER, UPTIME, LOGFILE, NO_LOAD, WORKERS, API_HASH, BOT_TOKEN,
+ LOG_DATETIME, MESSAGE_DUMP, load_cmds)
+
INITIAL_LOCK = RLock()
@@ -31,14 +20,15 @@ if MESSAGE_DUMP == -100 or not str(MESSAGE_DUMP).startswith("-100"):
raise Exception(
"Please enter a vaild Supergroup ID, A Supergroup ID starts with -100",
)
-
+
aiohttpsession = ClientSession()
+
class Gojo(Client):
"""Starts the Pyrogram Client on the Bot Token when we do 'python3 -m Powers'"""
def __init__(self):
- #name = Powers
+ # name = Powers
super().__init__(
"Gojo_Satarou",
@@ -61,8 +51,6 @@ class Gojo(Client):
startmsg = await self.send_message(MESSAGE_DUMP, "Starting Bot...")
-
-
# Show in Log that bot has started
LOGGER.info(
f"Pyrogram v{__version__} (Layer - {layer}) started on {meh.username}",
diff --git a/Powers/database/__init__.py b/Powers/database/__init__.py
index eed4ce9c8038400668e44db39cce7a4442c582c6..b96d862f80f3a2539a18f40e0a939b1cdca7e569 100644
--- a/Powers/database/__init__.py
+++ b/Powers/database/__init__.py
@@ -1,9 +1,8 @@
from sys import exit as exiter
-
from pymongo import MongoClient
from pymongo.errors import PyMongoError
+from Powers import DB_URI, LOGGER, DB_NAME
-from Powers import DB_NAME, DB_URI, LOGGER
try:
Powers_db_client = MongoClient(DB_URI)
diff --git a/Powers/database/antispam_db.py b/Powers/database/antispam_db.py
index 3acfd26dc9c1c042195f6b5712d94aac64be79e3..bb1f457dd1cda96753a249b46408aa0e1f4dcbf2 100644
--- a/Powers/database/antispam_db.py
+++ b/Powers/database/antispam_db.py
@@ -1,8 +1,8 @@
-from datetime import datetime
from threading import RLock
-
+from datetime import datetime
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
ANTISPAM_BANNED = set()
diff --git a/Powers/database/approve_db.py b/Powers/database/approve_db.py
index dbcbf760b4d6eebe2a4969d251db09d14dedd18b..617e4716cdd6e027f46164e48b74711d686fd318 100644
--- a/Powers/database/approve_db.py
+++ b/Powers/database/approve_db.py
@@ -1,8 +1,8 @@
-from threading import RLock
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/blacklist_db.py b/Powers/database/blacklist_db.py
index 895f3ca0f2afd6c9338700635dfba5ce990a4a6c..2295038466416694c6963b049ba417357e9b723d 100644
--- a/Powers/database/blacklist_db.py
+++ b/Powers/database/blacklist_db.py
@@ -1,9 +1,9 @@
-from threading import RLock
from time import time
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/chats_db.py b/Powers/database/chats_db.py
index b4029a4141fc2a62ca1cac9777e27c5159664ae1..0ce13d5bb20cfd9704fb0bb36ab897715ae4cc39 100644
--- a/Powers/database/chats_db.py
+++ b/Powers/database/chats_db.py
@@ -1,9 +1,9 @@
-from threading import RLock
from time import time
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/disable_db.py b/Powers/database/disable_db.py
index 7d7e2eeb8624f7fcfb53ab30c24ea689ed0f56b7..fb2c294b78631eded649d645477f4289c3376f93 100644
--- a/Powers/database/disable_db.py
+++ b/Powers/database/disable_db.py
@@ -1,9 +1,9 @@
-from threading import RLock
from time import time
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
DISABLED_CMDS = {}
@@ -74,8 +74,8 @@ class Disabling(MongoDB):
collection = MongoDB(Disabling.db_name)
curr = collection.find_all()
return sum(
- len(chat["commands"] if chat["commands"] else [])
- for chat in curr)
+ len(chat["commands"] if chat["commands"] else []) for chat in curr
+ )
@staticmethod
def count_disabling_chats():
@@ -96,10 +96,7 @@ class Disabling(MongoDB):
}
return self.update(
{"_id": self.chat_id},
- {
- "_id": self.chat_id,
- "action": action
- },
+ {"_id": self.chat_id, "action": action},
)
def get_action(self):
@@ -121,8 +118,8 @@ class Disabling(MongoDB):
collection = MongoDB(Disabling.db_name)
all_data = collection.find_all({"action": action})
return sum(
- len(i["commands"] if i["commands"] else []) >= 1
- for i in all_data)
+ len(i["commands"] if i["commands"] else []) >= 1 for i in all_data
+ )
def rm_all_disabled(self):
with INSERTION_LOCK:
@@ -149,13 +146,9 @@ class Disabling(MongoDB):
"commands": [],
"action": "none",
}
- DISABLED_CMDS[self.chat_id] = {
- "commands": [],
- "action": "none"
- }
+ DISABLED_CMDS[self.chat_id] = {"commands": [], "action": "none"}
self.insert_one(new_data)
- LOGGER.info(
- f"Initialized Disabling Document for chat {self.chat_id}")
+ LOGGER.info(f"Initialized Disabling Document for chat {self.chat_id}")
return new_data
DISABLED_CMDS[self.chat_id] = chat_data
return chat_data
diff --git a/Powers/database/filters_db.py b/Powers/database/filters_db.py
index d3fda53d9daeb4ae9f8a07953fbb9f97879dc742..3df3c6e3dfc356971f2750040ee887cecd8a585b 100644
--- a/Powers/database/filters_db.py
+++ b/Powers/database/filters_db.py
@@ -1,8 +1,8 @@
from threading import RLock
-
from Powers.database import MongoDB
from Powers.utils.msg_types import Types
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/greetings_db.py b/Powers/database/greetings_db.py
index 3419bed4d1c9e676ddb101dff465489ae1bede18..84ef6c21e25ee19be99b17954f6fe9ca98d0c5c7 100644
--- a/Powers/database/greetings_db.py
+++ b/Powers/database/greetings_db.py
@@ -1,8 +1,8 @@
-from threading import RLock
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/group_blacklist.py b/Powers/database/group_blacklist.py
index 5ab7eaa01194048ac7803eaa2af4459e074c5d9c..d47260522c738e1848d9edb1e00b89cfa562d07c 100644
--- a/Powers/database/group_blacklist.py
+++ b/Powers/database/group_blacklist.py
@@ -1,8 +1,8 @@
from threading import RLock
-
from Powers.database import MongoDB
from Powers.database.chats_db import Chats
+
INSERTION_LOCK = RLock()
BLACKLIST_CHATS = []
diff --git a/Powers/database/notes_db.py b/Powers/database/notes_db.py
index a614614b7a0a27dc52445838388b057cc79da0b8..fb9afe66a681a190f65252b039cc8b2631fc0c9c 100644
--- a/Powers/database/notes_db.py
+++ b/Powers/database/notes_db.py
@@ -1,10 +1,10 @@
+from time import time
from hashlib import md5
from threading import RLock
-from time import time
-
from Powers.database import MongoDB
from Powers.utils.msg_types import Types
+
INSERTION_LOCK = RLock()
@@ -57,8 +57,7 @@ class Notes(MongoDB):
def get_all_notes(self, chat_id: int):
with INSERTION_LOCK:
curr = self.find_all({"chat_id": chat_id})
- note_list = [(note["note_name"], note["hash"]) for note in curr]
- note_list.sort()
+ note_list = sorted([(note["note_name"], note["hash"]) for note in curr])
return note_list
def rm_note(self, chat_id: int, note_name: str):
diff --git a/Powers/database/pins_db.py b/Powers/database/pins_db.py
index ade8999eb8abf3c27f8571f4d7ac87895daa15a3..884d8a48c56f16f13d291e4545b2a27529f0b8e6 100644
--- a/Powers/database/pins_db.py
+++ b/Powers/database/pins_db.py
@@ -1,8 +1,8 @@
-from threading import RLock
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/reporting_db.py b/Powers/database/reporting_db.py
index 07a4e433a82fb506eb240c5c3cbda890b04ead65..fb0385c4934b9fd702d29b2de8f4a8b2535f922d 100644
--- a/Powers/database/reporting_db.py
+++ b/Powers/database/reporting_db.py
@@ -1,9 +1,9 @@
-from threading import RLock
from time import time
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/rules_db.py b/Powers/database/rules_db.py
index 3e82a247cf597c0f7b52c925e1f1fbc5096faa89..a0cfe90c96cc4e1fa9b5ac0d6714b4e0841b8831 100644
--- a/Powers/database/rules_db.py
+++ b/Powers/database/rules_db.py
@@ -1,9 +1,9 @@
-from threading import RLock
from time import time
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/database/users_db.py b/Powers/database/users_db.py
index f5aacffc369e651ddb5b9ca273703fff208e5321..45ad1183a1752ce7813c34edb6bc059fbd1e4ac0 100644
--- a/Powers/database/users_db.py
+++ b/Powers/database/users_db.py
@@ -1,9 +1,9 @@
-from threading import RLock
from time import time
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
@@ -53,7 +53,8 @@ class Users(MongoDB):
if isinstance(user_id, int):
curr = collection.find_one({"_id": user_id})
elif isinstance(user_id, str):
- # user_id[1:] because we don't want the '@' in the username search!
+ # user_id[1:] because we don't want the '@' in the username
+ # search!
curr = collection.find_one({"username": user_id[1:]})
else:
curr = None
diff --git a/Powers/database/warns_db.py b/Powers/database/warns_db.py
index 2c39cb9cb83b76ce797dacdb7379cbe6705ccf5f..696dcdb8fac64bb167ea5973c8ed44a8e139db23 100644
--- a/Powers/database/warns_db.py
+++ b/Powers/database/warns_db.py
@@ -1,9 +1,9 @@
-from threading import RLock
from time import time
-
from Powers import LOGGER
+from threading import RLock
from Powers.database import MongoDB
+
INSERTION_LOCK = RLock()
diff --git a/Powers/plugins/__init__.py b/Powers/plugins/__init__.py
index 0d944791dd400f63a745dac4ec9f0d6170c060eb..d9647d7f56bfcaeb695dd71e7c810009c1b412f0 100644
--- a/Powers/plugins/__init__.py
+++ b/Powers/plugins/__init__.py
@@ -3,7 +3,7 @@ async def all_plugins():
# work.
from glob import glob
- from os.path import basename, dirname, isfile
+ from os.path import isfile, dirname, basename
mod_paths = glob(dirname(__file__) + "/*.py")
all_plugs = [
diff --git a/Powers/plugins/admin.py b/Powers/plugins/admin.py
index 71eadd4509277f6c5e12fa46a407bb0cdc3591f2..7ba67477d818d7c2803e5df903ae9401d6d06eb0 100644
--- a/Powers/plugins/admin.py
+++ b/Powers/plugins/admin.py
@@ -1,35 +1,24 @@
-from asyncio import sleep
-from html import escape
from os import remove
-from traceback import format_exc
-
+from html import escape
+from asyncio import sleep
from pyrogram import filters
-from pyrogram.errors import (
- ChatAdminInviteRequired,
- ChatAdminRequired,
- FloodWait,
- RightForbidden,
- RPCError,
- UserAdminInvalid,
-)
-from pyrogram.types import Message
-
-from Powers import DEV_USERS, LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
+from Powers.vars import Config
+from traceback import format_exc
from Powers.bot_class import Gojo
+from pyrogram.types import Message
+from Powers.utils.chat_type import chattype
+from Powers.utils.parser import mention_html
from Powers.database.approve_db import Approve
from Powers.database.reporting_db import Reporting
-from Powers.utils.caching import ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload
-from Powers.utils.chat_type import chattype
-from Powers.utils.custom_filters import (
- DEV_LEVEL,
- admin_filter,
- command,
- owner_filter,
- promote_filter,
-)
from Powers.utils.extract_user import extract_user
-from Powers.utils.parser import mention_html
-from Powers.vars import Config
+from Powers import LOGGER, OWNER_ID, DEV_USERS, SUPPORT_GROUP, SUPPORT_STAFF
+from Powers.utils.caching import (
+ ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload)
+from Powers.utils.custom_filters import (
+ DEV_LEVEL, command, admin_filter, owner_filter, promote_filter)
+from pyrogram.errors import (
+ RPCError, FloodWait, RightForbidden, UserAdminInvalid, ChatAdminRequired,
+ ChatAdminInviteRequired)
@Gojo.on_message(command("adminlist"))
@@ -47,8 +36,8 @@ async def adminlist_show(_, m: Message):
except KeyError:
admin_list = await admin_cache_reload(m, "adminlist")
note = "Note: These are up-to-date values!"
-
- adminstr = f"Admins in {m.chat.title}:"+ "\n\n"
+
+ adminstr = f"Admins in {m.chat.title}:" + "\n\n"
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
@@ -178,7 +167,9 @@ async def fullpromote_usr(c: Gojo, m: Message):
global ADMIN_CACHE
if len(m.text.split()) == 1 and not m.reply_to_message:
- await m.reply_text(text="I can't promote nothing! Give me an username or user id or atleast reply to that user")
+ await m.reply_text(
+ text="I can't promote nothing! Give me an username or user id or atleast reply to that user"
+ )
return
try:
@@ -245,7 +236,6 @@ async def fullpromote_usr(c: Gojo, m: Message):
LOGGER.info(
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
)
-
await m.reply_text(
("{promoter} promoted {promoted} in chat {chat_title}!").format(
@@ -257,7 +247,8 @@ async def fullpromote_usr(c: Gojo, m: Message):
),
)
- # If user is approved, disapprove them as they willbe promoted and get even more rights
+ # If user is approved, disapprove them as they willbe promoted and get
+ # even more rights
if Approve(m.chat.id).check_approve(user_id):
Approve(m.chat.id).remove_approve(user_id)
@@ -273,9 +264,11 @@ async def fullpromote_usr(c: Gojo, m: Message):
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights......")
except RightForbidden:
- await m.reply_text(text = "I don't have enough rights to promote this user.")
+ await m.reply_text(text="I don't have enough rights to promote this user.")
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RPCError as e:
await m.reply_text(
text=f"Some error occured, report to @{SUPPORT_GROUP} \n Error: {e}
"
@@ -291,7 +284,9 @@ async def promote_usr(c: Gojo, m: Message):
global ADMIN_CACHE
if len(m.text.split()) == 1 and not m.reply_to_message:
- await m.reply_text(text="I can't promote nothing!......reply to user to promote him/her....")
+ await m.reply_text(
+ text="I can't promote nothing!......reply to user to promote him/her...."
+ )
return
try:
@@ -343,7 +338,7 @@ async def promote_usr(c: Gojo, m: Message):
if title and len(title) > 16:
title = title[0:16] # trim title to 16 characters
if not title:
- title="Itadori"
+ title = "Itadori"
try:
await c.set_administrator_title(m.chat.id, user_id, title)
@@ -364,7 +359,8 @@ async def promote_usr(c: Gojo, m: Message):
),
)
- # If user is approved, disapprove them as they willbe promoted and get even more rights
+ # If user is approved, disapprove them as they willbe promoted and get
+ # even more rights
if Approve(m.chat.id).check_approve(user_id):
Approve(m.chat.id).remove_approve(user_id)
@@ -382,7 +378,9 @@ async def promote_usr(c: Gojo, m: Message):
except RightForbidden:
await m.reply_text(text="I don't have enough rights to promote this user.")
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RPCError as e:
await m.reply_text(
text=f"Some error occured, report to @{SUPPORT_GROUP} \n Error: {e}
"
@@ -406,7 +404,6 @@ async def get_invitelink(c: Gojo, m: Message):
link = await c.export_chat_invite_link(m.chat.id)
await m.reply_text(
text=f"Invite Link for Chat {m.chat.id}: {link}",
-
disable_web_page_preview=True,
)
LOGGER.info(f"{m.from_user.id} exported invite link in {m.chat.id}")
@@ -418,7 +415,7 @@ async def get_invitelink(c: Gojo, m: Message):
await m.reply_text(text="You don't have permissions to invite users.")
except RPCError as ef:
await m.reply_text(
- text = f"Some error occured, report to @{SUPPORT_GROUP} \n Error: {ef}
"
+ text=f"Some error occured, report to @{SUPPORT_GROUP} \n Error: {ef}
"
)
LOGGER.error(ef)
LOGGER.error(format_exc())
@@ -575,4 +572,4 @@ __HELP__ = """
* /enableall: enable all disabled commands.
**Example:**
-`/promote @username`: this promotes a user to admin."""
\ No newline at end of file
+`/promote @username`: this promotes a user to admin."""
diff --git a/Powers/plugins/antispam.py b/Powers/plugins/antispam.py
index 5d353aab15c2cb6602e090a93c7a7f71a564b948..51c2ec5f0e3ef4efe9a89ee36f4dcf0a2502b50c 100644
--- a/Powers/plugins/antispam.py
+++ b/Powers/plugins/antispam.py
@@ -1,19 +1,18 @@
-from datetime import datetime
from io import BytesIO
+from datetime import datetime
+from Powers.vars import Config
from traceback import format_exc
-
-from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
-from pyrogram.types import Message
-
-from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, SUPPORT_STAFF
from Powers.bot_class import Gojo
-from Powers.database.antispam_db import GBan
+from pyrogram.types import Message
from Powers.database.users_db import Users
-from Powers.utils.clean_file import remove_markdown_and_html
+from Powers.database.antispam_db import GBan
+from Powers.utils.parser import mention_html
from Powers.utils.custom_filters import command
from Powers.utils.extract_user import extract_user
-from Powers.utils.parser import mention_html
-from Powers.vars import Config
+from Powers.utils.clean_file import remove_markdown_and_html
+from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, SUPPORT_STAFF
+from pyrogram.errors import PeerIdInvalid, UserIsBlocked, MessageTooLong
+
# Initialize
db = GBan()
@@ -22,7 +21,9 @@ db = GBan()
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
async def gban(c: Gojo, m: Message):
if len(m.text.split()) == 1:
- await m.reply_text(text ="How to gban? \n Answer: /gban user_id reason
")
+ await m.reply_text(
+ text="How to gban? \n Answer: /gban user_id reason
"
+ )
return
if len(m.text.split()) == 2 and not m.reply_to_message:
@@ -41,29 +42,31 @@ async def gban(c: Gojo, m: Message):
return
if user_id == Config.BOT_ID:
- await m.reply_text(text="You don't dare use that command on me again nigga! \n Go straight and fuck your self......")
+ await m.reply_text(
+ text="You don't dare use that command on me again nigga! \n Go straight and fuck your self......"
+ )
return
if db.check_gban(user_id):
db.update_gban_reason(user_id, gban_reason)
- await m.reply_text(
- text="Updated Gban reason to: {gban_reason}
."
- )
+ await m.reply_text(text="Updated Gban reason to: {gban_reason}
.")
return
db.add_gban(user_id, gban_reason, m.from_user.id)
await m.reply_text(
- (f"Added {user_first_name} to GBan List. \n They will now be banned in all groups where I'm admin!")
+ (
+ f"Added {user_first_name} to GBan List. \n They will now be banned in all groups where I'm admin!"
+ )
)
LOGGER.info(f"{m.from_user.id} gbanned {user_id} from {m.chat.id}")
- date = (datetime.utcnow().strftime("%H:%M - %d-%m-%Y"))
- log_msg = f"#GBAN \n Originated from: {m.chat.id} \n Admin: {await mention_html(m.from_user.first_name, m.from_user.id)} \n Gbanned User: {await mention_html(user_first_name, user_id)} \n Gbanned User ID: {user_id} \ nEvent Stamp: {date}"
+ date = datetime.utcnow().strftime("%H:%M - %d-%m-%Y")
+ log_msg = f"#GBAN \n Originated from: {m.chat.id} \n Admin: {await mention_html(m.from_user.first_name, m.from_user.id)} \n Gbanned User: {await mention_html(user_first_name, user_id)} \n Gbanned User ID: {user_id} \\ nEvent Stamp: {date}"
await c.send_message(MESSAGE_DUMP, log_msg)
try:
# Send message to user telling that he's gbanned
await c.send_message(
user_id,
- f"You have been added to my global ban list! \n Reason: {gban_reason}
\n Appeal Chat: @{SUPPORT_GROUP}"
+ f"You have been added to my global ban list! \n Reason: {gban_reason}
\n Appeal Chat: @{SUPPORT_GROUP}",
)
except UserIsBlocked:
LOGGER.error("Could not send PM Message, user blocked bot")
@@ -82,7 +85,7 @@ async def gban(c: Gojo, m: Message):
)
async def ungban(c: Gojo, m: Message):
if len(m.text.split()) == 1:
- await m.reply_text(text= "Pass a user id or username as an argument!")
+ await m.reply_text(text="Pass a user id or username as an argument!")
return
user_id, user_first_name, _ = await extract_user(c, m)
@@ -92,29 +95,29 @@ async def ungban(c: Gojo, m: Message):
return
if user_id == Config.BOT_ID:
- await m.reply_text(text= """You can't gban me nigga!
- Fuck yourself.......!""")
+ await m.reply_text(
+ text="""You can't gban me nigga!
+ Fuck yourself.......!"""
+ )
return
if db.check_gban(user_id):
db.remove_gban(user_id)
- await m.reply_text(
- text=f"Removed {user_first_name} from Global Ban List."
- )
- time=(datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),
+ await m.reply_text(text=f"Removed {user_first_name} from Global Ban List.")
+ time = ((datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),)
LOGGER.info(f"{m.from_user.id} ungbanned {user_id} from {m.chat.id}")
- log_msg = (f"""#UNGBAN
+ log_msg = f"""#UNGBAN
Originated from: {m.chat.id}
Admin: {(await mention_html(m.from_user.first_name, m.from_user.id))}
UnGbanned User: {(await mention_html(user_first_name, user_id))}
UnGbanned User ID: {user_id}
- Event Stamp: {time}""")
+ Event Stamp: {time}"""
await c.send_message(MESSAGE_DUMP, log_msg)
try:
# Send message to user telling that he's ungbanned
await c.send_message(
user_id,
- text="You have been removed from my global ban list!.....Be careful it takes few seconds to add you again..."
+ text="You have been removed from my global ban list!.....Be careful it takes few seconds to add you again...",
)
except Exception as ef: # TODO: Improve Error Detection
LOGGER.error(ef)
@@ -130,7 +133,8 @@ async def ungban(c: Gojo, m: Message):
)
async def gban_count(_, m: Message):
await m.reply_text(
- text=f"Number of people gbanned: {(db.count_gbans())}
")
+ text=f"Number of people gbanned: {(db.count_gbans())}
"
+ )
LOGGER.info(f"{m.from_user.id} counting gbans in {m.chat.id}")
return
@@ -157,11 +161,9 @@ async def gban_list(_, m: Message):
with BytesIO(str.encode(await remove_markdown_and_html(banfile))) as f:
f.name = "gbanlist.txt"
await m.reply_document(
- document=f,
- caption="Here are all the globally banned geys!\n\n"
+ document=f, caption="Here are all the globally banned geys!\n\n"
)
LOGGER.info(f"{m.from_user.id} exported gbanlist in {m.chat.id}")
return
-
diff --git a/Powers/plugins/approve.py b/Powers/plugins/approve.py
index d67a32336c7af8cfedfc6c75bb725865794f4ae2..95d3b0c5083f7652602f2375a9fe3cb0cf519b3d 100644
--- a/Powers/plugins/approve.py
+++ b/Powers/plugins/approve.py
@@ -1,14 +1,13 @@
from pyrogram import filters
-from pyrogram.errors import PeerIdInvalid, RPCError, UserNotParticipant
-from pyrogram.types import CallbackQuery, ChatPermissions, Message
-
-from Powers import LOGGER, SUPPORT_GROUP
from Powers.bot_class import Gojo
-from Powers.database.approve_db import Approve
-from Powers.utils.custom_filters import admin_filter, command, owner_filter
-from Powers.utils.extract_user import extract_user
from Powers.utils.kbhelpers import ikb
+from Powers import LOGGER, SUPPORT_GROUP
from Powers.utils.parser import mention_html
+from Powers.database.approve_db import Approve
+from Powers.utils.extract_user import extract_user
+from pyrogram.types import Message, CallbackQuery, ChatPermissions
+from pyrogram.errors import RPCError, PeerIdInvalid, UserNotParticipant
+from Powers.utils.custom_filters import command, admin_filter, owner_filter
@Gojo.on_message(command("approve") & admin_filter)
@@ -244,4 +243,4 @@ __HELP__ = """
* /approved: List all approved users.
* /unapproveall: Unapprove *ALL* users in a chat. This cannot be undone!
**Example:**
-`/approve @username`: this approves a user in the chat."""
\ No newline at end of file
+`/approve @username`: this approves a user in the chat."""
diff --git a/Powers/plugins/bans.py b/Powers/plugins/bans.py
index e41eddcd23bc1a6c3d88c59a36a8d1ddb4cb39f4..2c883822a715161721bc0608934cd1faefa784f4 100644
--- a/Powers/plugins/bans.py
+++ b/Powers/plugins/bans.py
@@ -1,35 +1,26 @@
-from traceback import format_exc
from random import choice
-
-from pyrogram.errors import (
- ChatAdminRequired,
- PeerIdInvalid,
- RightForbidden,
- RPCError,
- UserAdminInvalid,
-)
-from pyrogram.filters import regex
-from pyrogram.types import (
- CallbackQuery,
- InlineKeyboardButton,
- InlineKeyboardMarkup,
- Message,
-)
-
-from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
+from Powers.vars import Config
+from traceback import format_exc
from Powers.bot_class import Gojo
+from pyrogram.filters import regex
+from Powers.utils.parser import mention_html
+from Powers.utils.string import extract_time
+from Powers.utils.extract_user import extract_user
from Powers.utils.extras import BAN_GIFS, KICK_GIFS
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
from Powers.utils.custom_filters import command, restrict_filter
-from Powers.utils.extract_user import extract_user
-from Powers.utils.parser import mention_html
-from Powers.utils.string import extract_time
-from Powers.vars import Config
+from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
+from pyrogram.types import (
+ Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup)
+from pyrogram.errors import (
+ RPCError, PeerIdInvalid, RightForbidden, UserAdminInvalid,
+ ChatAdminRequired)
BAN_MEDIA = choice(BAN_GIFS)
KICK_MEDIA = choice(KICK_GIFS)
+
@Gojo.on_message(command("tban") & restrict_filter)
async def tban_usr(c: Gojo, m: Message):
if len(m.text.split()) == 1 and not m.reply_to_message:
@@ -49,7 +40,9 @@ async def tban_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -88,14 +81,16 @@ async def tban_usr(c: Gojo, m: Message):
await m.stop_propagation()
try:
- admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
- banned=(await mention_html(user_first_name, user_id)),
- chat_title=m.chat.title,
+ admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
+ banned = ((await mention_html(user_first_name, user_id)),)
+ chat_title = (m.chat.title,)
LOGGER.info(f"{m.from_user.id} tbanned {user_id} in {m.chat.id}")
- await m.chat.ban_member(user_id, until_date=int(bantime),
- text = f"{admin} banned {banned} in {chat_title}!"
+ await m.chat.ban_member(
+ user_id,
+ until_date=int(bantime),
+ text=f"{admin} banned {banned} in {chat_title}!",
)
-
+
txt += f"\nReason: {reason}" if reason else ""
keyboard = InlineKeyboardMarkup(
[
@@ -107,8 +102,15 @@ async def tban_usr(c: Gojo, m: Message):
],
],
)
- await m.reply_animation(reply_to_message_id = r_id, animation = BAN_MEDIA, caption = txt, reply_markup=keyboard, parse_mode="html")
- # await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
+ await m.reply_animation(
+ reply_to_message_id=r_id,
+ animation=BAN_MEDIA,
+ caption=txt,
+ reply_markup=keyboard,
+ parse_mode="html",
+ )
+ # await m.reply_text(txt, reply_markup=keyboard,
+ # reply_to_message_id=r_id)
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
except PeerIdInvalid:
@@ -116,14 +118,18 @@ async def tban_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
await m.reply_text(
- (f"""Some error occured, report to @{SUPPORT_GROUP}
+ (
+ f"""Some error occured, report to @{SUPPORT_GROUP}
- Error: {ef}
""")
+ Error: {ef}
"""
+ )
)
LOGGER.error(ef)
LOGGER.error(format_exc())
@@ -149,7 +155,9 @@ async def stban_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -200,7 +208,9 @@ async def stban_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
@@ -274,15 +284,14 @@ async def dtban_usr(c: Gojo, m: Message):
await m.stop_propagation()
try:
- admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
- banned=(await mention_html(user_first_name, user_id)),
- chat_title=m.chat.title,
+ admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
+ banned = ((await mention_html(user_first_name, user_id)),)
+ chat_title = (m.chat.title,)
LOGGER.info(f"{m.from_user.id} dtbanned {user_id} in {m.chat.id}")
await m.chat.ban_member(user_id, until_date=int(bantime))
await m.reply_to_message.delete()
txt = f"{admin} banned {banned} in {chat_title}!"
-
-
+
txt += f"\nReason: {reason}" if reason else ""
keyboard = InlineKeyboardMarkup(
[
@@ -294,7 +303,13 @@ async def dtban_usr(c: Gojo, m: Message):
],
],
)
- await c.send_animation(chat_id = m.chat.id, animation = BAN_MEDIA, caption = txt, reply_markup=keyboard, parse_mode="html")
+ await c.send_animation(
+ chat_id=m.chat.id,
+ animation=BAN_MEDIA,
+ caption=txt,
+ reply_markup=keyboard,
+ parse_mode="html",
+ )
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
@@ -303,7 +318,9 @@ async def dtban_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
@@ -347,7 +364,9 @@ async def kick_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to kick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -363,15 +382,20 @@ async def kick_usr(c: Gojo, m: Message):
await m.stop_propagation()
try:
- admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
- kicked=(await mention_html(user_first_name, user_id)),
- chat_title=m.chat.title,
+ admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
+ kicked = ((await mention_html(user_first_name, user_id)),)
+ chat_title = (m.chat.title,)
LOGGER.info(f"{m.from_user.id} kicked {user_id} in {m.chat.id}")
await m.chat.ban_member(user_id)
txt = f"{admin} kicked {kicked} in {chat_title}!"
txt += f"\nReason: {reason}" if reason else ""
- # await m.reply_text(txt, reply_to_message_id=r_id)
- await m.reply_animation(reply_to_message_id = r_id, animation = KICK_MEDIA, caption = txt, parse_mode="html")
+ # await m.reply_text(txt, reply_to_message_id=r_id)
+ await m.reply_animation(
+ reply_to_message_id=r_id,
+ animation=KICK_MEDIA,
+ caption=txt,
+ parse_mode="html",
+ )
await m.chat.unban_member(user_id)
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
@@ -380,7 +404,9 @@ async def kick_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
@@ -415,7 +441,9 @@ async def skick_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to skick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -444,7 +472,9 @@ async def skick_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to kick this user.")
except RPCError as ef:
@@ -481,7 +511,9 @@ async def dkick_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to dkick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -500,13 +532,15 @@ async def dkick_usr(c: Gojo, m: Message):
LOGGER.info(f"{m.from_user.id} dkicked {user_id} in {m.chat.id}")
await m.reply_to_message.delete()
await m.chat.ban_member(user_id)
- admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
- kicked=(await mention_html(user_first_name, user_id)),
- chat_title=m.chat.title,
+ admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
+ kicked = ((await mention_html(user_first_name, user_id)),)
+ chat_title = (m.chat.title,)
txt = f"{admin} kicked {kicked} in {chat_title}!"
txt += f"\nReason: {reason}" if reason else ""
await c.send_message(m.chat.id, txt)
- await c.send_animation(chat_id = m.chat.id, animation = KICK_MEDIA, caption = txt, parse_mode="html")
+ await c.send_animation(
+ chat_id=m.chat.id, animation=KICK_MEDIA, caption=txt, parse_mode="html"
+ )
await m.chat.unban_member(user_id)
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
@@ -515,7 +549,9 @@ async def dkick_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to kick this user.")
except RPCError as ef:
@@ -556,9 +592,9 @@ async def unban_usr(c: Gojo, m: Message):
try:
await m.chat.unban_member(user_id)
- admin=m.from_user.mention,
- unbanned=(await mention_html(user_first_name, user_id)),
- chat_title=m.chat.title,
+ admin = (m.from_user.mention,)
+ unbanned = ((await mention_html(user_first_name, user_id)),)
+ chat_title = (m.chat.title,)
txt = f"{admin} unbanned {unbanned} in chat {chat_title}!"
txt += f"\nReason: {reason}" if reason else ""
await m.reply_text(txt)
@@ -568,7 +604,7 @@ async def unban_usr(c: Gojo, m: Message):
await m.reply_text(text="I don't have enough rights to unban this user.")
except RPCError as ef:
await m.reply_text(
- text=f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
@@ -603,7 +639,9 @@ async def sban_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to sban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -631,7 +669,9 @@ async def sban_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
@@ -676,7 +716,9 @@ async def dban_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to dban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -699,7 +741,7 @@ async def dban_usr(c: Gojo, m: Message):
LOGGER.info(f"{m.from_user.id} dbanned {user_id} in {m.chat.id}")
await m.reply_to_message.delete()
await m.chat.ban_member(user_id)
- txt =f"{m.from_user.mention} banned {m.reply_to_message.from_user.mention} in {m.chat.title}!"
+ txt = f"{m.from_user.mention} banned {m.reply_to_message.from_user.mention} in {m.chat.title}!"
txt += f"\nReason: {reason}" if reason else ""
keyboard = InlineKeyboardMarkup(
[
@@ -711,7 +753,9 @@ async def dban_usr(c: Gojo, m: Message):
],
],
)
- await c.send_animation(m.chat.id, animation = BAN_MEDIA,caption=txt, reply_markup=keyboard)
+ await c.send_animation(
+ m.chat.id, animation=BAN_MEDIA, caption=txt, reply_markup=keyboard
+ )
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
except PeerIdInvalid:
@@ -719,7 +763,9 @@ async def dban_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
@@ -761,7 +807,9 @@ async def ban_usr(c: Gojo, m: Message):
await m.stop_propagation()
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -789,7 +837,7 @@ async def ban_usr(c: Gojo, m: Message):
try:
LOGGER.info(f"{m.from_user.id} banned {user_id} in {m.chat.id}")
await m.chat.ban_member(user_id)
- banned=(await mention_html(user_first_name, user_id))
+ banned = await mention_html(user_first_name, user_id)
txt = f"{m.from_user.mention} banned {banned} in {m.chat.title}!"
txt += f"\nReason: {reason}" if reason else ""
keyboard = InlineKeyboardMarkup(
@@ -802,7 +850,12 @@ async def ban_usr(c: Gojo, m: Message):
],
],
)
- await m.reply_animation(animation=BAN_MEDIA, caption=txt, reply_markup=keyboard, reply_to_message_id=r_id)
+ await m.reply_animation(
+ animation=BAN_MEDIA,
+ caption=txt,
+ reply_markup=keyboard,
+ reply_to_message_id=r_id,
+ )
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
except PeerIdInvalid:
@@ -810,7 +863,9 @@ async def ban_usr(c: Gojo, m: Message):
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
)
except UserAdminInvalid:
- await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
+ await m.reply_text(
+ text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
+ )
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
@@ -895,4 +950,4 @@ __HELP__ = """
* /dtban x(m/h/d): Silently bans a user for x time and delete the replied message. (via reply). m = minutes, h = hours, d = days.
* /unban: Unbans the user replied to or tagged.
**Example:**
-`/ban @username`: this bans a user in the chat."""
\ No newline at end of file
+`/ban @username`: this bans a user in the chat."""
diff --git a/Powers/plugins/blacklist.py b/Powers/plugins/blacklist.py
index d540c409665979595f33587940b8e36ef0ea3ee2..9365893b4d569713961b1b20b9ce65cbc6f3ba71 100644
--- a/Powers/plugins/blacklist.py
+++ b/Powers/plugins/blacklist.py
@@ -1,13 +1,11 @@
from html import escape
-
-from pyrogram import filters
-from pyrogram.types import CallbackQuery, Message
-
from Powers import LOGGER
+from pyrogram import filters
from Powers.bot_class import Gojo
+from Powers.utils.kbhelpers import ikb
+from pyrogram.types import Message, CallbackQuery
from Powers.database.blacklist_db import Blacklist
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
-from Powers.utils.kbhelpers import ikb
@Gojo.on_message(command("blacklist") & filters.group)
@@ -58,9 +56,10 @@ async def add_blacklist(_, m: Message):
+ " already added in blacklist, skipped them!"
)
LOGGER.info(f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
- trigger=", ".join(f"{i}
" for i in bl_words)
+ trigger = ", ".join(f"{i}
" for i in bl_words)
await m.reply_text(
- text=f"Added {trigger}
in blacklist words!" + (f"\n{rep_text}" if rep_text else ""),
+ text=f"Added {trigger}
in blacklist words!"
+ + (f"\n{rep_text}" if rep_text else ""),
)
await m.stop_propagation()
@@ -115,9 +114,10 @@ async def rm_blacklist(_, m: Message):
) + " in blcklisted words, skipped them."
LOGGER.info(f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
- bl_words=", ".join(f"{i}
" for i in bl_words)
+ bl_words = ", ".join(f"{i}
" for i in bl_words)
await m.reply_text(
- text=f"Removed {bl_words} from blacklist words!" + (f"\n{rep_text}" if rep_text else ""),
+ text=f"Removed {bl_words} from blacklist words!"
+ + (f"\n{rep_text}" if rep_text else ""),
)
await m.stop_propagation()
@@ -145,14 +145,12 @@ async def set_bl_action(_, m: Message):
LOGGER.info(
f"{m.from_user.id} set blacklist action to '{action}' in {m.chat.id}",
)
- await m.reply_text(
- text=f"Set action for blacklist for this to {action}"
- )
+ await m.reply_text(text=f"Set action for blacklist for this to {action}")
elif len(m.text.split()) == 1:
action = db.get_action()
LOGGER.info(f"{m.from_user.id} checking blacklist action in {m.chat.id}")
await m.reply_text(
- text= f"""The current action for blacklists in this chat is {action}
+ text=f"""The current action for blacklists in this chat is {action}
All blacklist modes delete the message containing blacklist word."""
)
else:
@@ -223,4 +221,4 @@ Default is 'none', which will delete the users message on typing a blacklist wor
* /rmallblacklist: Removes all the blacklists from the current chat.
**Note:** Can only add or remove one blacklist at a time!
**Example:**
-`/addblacklist hello`: this adds the word 'hello' as blacklist in the chat."""
\ No newline at end of file
+`/addblacklist hello`: this adds the word 'hello' as blacklist in the chat."""
diff --git a/Powers/plugins/botstaff.py b/Powers/plugins/botstaff.py
index b19aed32343d8183075f17da11e27c1085e01ffe..e654d7814a649826c207ea108250c31dfb2a5f35 100644
--- a/Powers/plugins/botstaff.py
+++ b/Powers/plugins/botstaff.py
@@ -1,10 +1,9 @@
-from pyrogram.errors import RPCError
-from pyrogram.types import Message
-
-from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, WHITELIST_USERS
from Powers.bot_class import Gojo
-from Powers.utils.custom_filters import command
+from pyrogram.types import Message
+from pyrogram.errors import RPCError
from Powers.utils.parser import mention_html
+from Powers.utils.custom_filters import command
+from Powers import LOGGER, OWNER_ID, DEV_USERS, SUDO_USERS, WHITELIST_USERS
@Gojo.on_message(command("botstaff", dev_cmd=True))
diff --git a/Powers/plugins/chat_blacklist.py b/Powers/plugins/chat_blacklist.py
index b6c25b90814b9602558d1ba169e6fd6dee23231b..89a6dc4b6d921482bb2029f8875c85fbea8237e8 100644
--- a/Powers/plugins/chat_blacklist.py
+++ b/Powers/plugins/chat_blacklist.py
@@ -1,12 +1,11 @@
-from traceback import format_exc
-
-from pyrogram.errors import PeerIdInvalid, RPCError
-from pyrogram.types import Message
-
from Powers import LOGGER
+from traceback import format_exc
from Powers.bot_class import Gojo
-from Powers.database.group_blacklist import GroupBlacklist
+from pyrogram.types import Message
from Powers.utils.custom_filters import command
+from pyrogram.errors import RPCError, PeerIdInvalid
+from Powers.database.group_blacklist import GroupBlacklist
+
# initialise database
db = GroupBlacklist()
diff --git a/Powers/plugins/dev.py b/Powers/plugins/dev.py
index b802a7be508fe43db460e7ed44dd49bd4d302a2f..999e4a6bd9bfcd329ef0de76aac81bf5a56543c9 100644
--- a/Powers/plugins/dev.py
+++ b/Powers/plugins/dev.py
@@ -1,29 +1,20 @@
import sys
-from asyncio import create_subprocess_shell, sleep, subprocess
+from Powers.vars import Config
from io import BytesIO, StringIO
-from time import gmtime, strftime, time
from traceback import format_exc
-
-from pyrogram.errors import (
- ChannelInvalid,
- ChannelPrivate,
- ChatAdminRequired,
- FloodWait,
- MessageTooLong,
- PeerIdInvalid,
- RPCError,
-)
-from pyrogram.types import Message
-
-
-from Powers import LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
from Powers.bot_class import Gojo
+from pyrogram.types import Message
+from Powers.utils.http_helper import *
+from time import time, gmtime, strftime
from Powers.database.chats_db import Chats
-from Powers.utils.clean_file import remove_markdown_and_html
from Powers.utils.custom_filters import command
-from Powers.utils.http_helper import *
from Powers.utils.parser import mention_markdown
-from Powers.vars import Config
+from Powers import LOGGER, UPTIME, LOGFILE, MESSAGE_DUMP
+from Powers.utils.clean_file import remove_markdown_and_html
+from asyncio import sleep, subprocess, create_subprocess_shell
+from pyrogram.errors import (
+ RPCError, FloodWait, PeerIdInvalid, ChannelInvalid, ChannelPrivate,
+ MessageTooLong, ChatAdminRequired)
@Gojo.on_message(command("ping", sudo_cmd=True))
@@ -300,4 +291,4 @@ async def chat_broadcast(c: Gojo, m: Message):
_DISABLE_CMDS_ = ["ping"]
-__HELP__ = """To check the ping of the bot just type `/ping`"""
\ No newline at end of file
+__HELP__ = """To check the ping of the bot just type `/ping`"""
diff --git a/Powers/plugins/disable.py b/Powers/plugins/disable.py
index 0c14a8818a72113901480966dde2415933a46bc2..05270eb1575df57af4a04f8bb08bb7e70097ba53 100644
--- a/Powers/plugins/disable.py
+++ b/Powers/plugins/disable.py
@@ -1,22 +1,12 @@
from html import escape
-
from pyrogram import filters
-from pyrogram.types import (
- CallbackQuery,
- InlineKeyboardButton,
- InlineKeyboardMarkup,
- Message,
-)
-
-from Powers import HELP_COMMANDS, LOGGER
from Powers.bot_class import Gojo
+from Powers import LOGGER, HELP_COMMANDS
from Powers.database.disable_db import Disabling
+from pyrogram.types import (
+ Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup)
from Powers.utils.custom_filters import (
- admin_filter,
- can_change_filter,
- command,
- owner_filter,
-)
+ command, admin_filter, owner_filter, can_change_filter)
@Gojo.on_message(command("disable") & can_change_filter)
diff --git a/Powers/plugins/filters.py b/Powers/plugins/filters.py
index 0bc2ee3d7014392e0c0250ef8250e4b4322ebf3f..ff53db6c37d019a267c7402c966a441974dd7769 100644
--- a/Powers/plugins/filters.py
+++ b/Powers/plugins/filters.py
@@ -1,24 +1,20 @@
-from re import escape as re_escape
from secrets import choice
-from traceback import format_exc
-
from pyrogram import filters
+from traceback import format_exc
+from re import escape as re_escape
from pyrogram.errors import RPCError
-from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, Message
-
+from Powers.utils.kbhelpers import ikb
from Powers.bot_class import LOGGER, Gojo
-from Powers.database.filters_db import Filters
from Powers.utils.cmd_senders import send_cmd
-from Powers.utils.custom_filters import admin_filter, command, owner_filter
-from Powers.utils.kbhelpers import ikb
-from Powers.utils.msg_types import Types, get_filter_type
+from Powers.database.filters_db import Filters
from Powers.utils.regex_utils import regex_searcher
+from Powers.utils.msg_types import Types, get_filter_type
+from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
+from Powers.utils.custom_filters import command, admin_filter, owner_filter
from Powers.utils.string import (
- build_keyboard,
- escape_mentions_using_curly_brackets,
- parse_button,
- split_quotes,
-)
+ parse_button, split_quotes, build_keyboard,
+ escape_mentions_using_curly_brackets)
+
# Initialise
db = Filters()
@@ -327,4 +323,4 @@ Using the you can make a single filter work on 2 filternames without manually ad
**Note:**
Currently there is a limit of 50 filters and 120 aliases per chat.
-All filter keywords are in lowercase."""
\ No newline at end of file
+All filter keywords are in lowercase."""
diff --git a/Powers/plugins/formatting.py b/Powers/plugins/formatting.py
index 81b680b16027d72526511c8246359e8040949a17..c4dbebe2fb3041cf98d03effebe771ad3a5c01f6 100644
--- a/Powers/plugins/formatting.py
+++ b/Powers/plugins/formatting.py
@@ -1,10 +1,9 @@
-from pyrogram import filters
-from pyrogram.types import CallbackQuery, Message
-
from Powers import LOGGER
+from pyrogram import filters
from Powers.bot_class import Gojo
-from Powers.utils.custom_filters import command
from Powers.utils.kbhelpers import ikb
+from Powers.utils.custom_filters import command
+from pyrogram.types import Message, CallbackQuery
async def gen_formatting_kb(m):
@@ -138,4 +137,4 @@ __buttons__ = [
__HELP__ = """
***Formatting***
-Gojo supports a large number of formatting options to make your messages more expressive. Take a look by clicking the buttons below!"""
\ No newline at end of file
+Gojo supports a large number of formatting options to make your messages more expressive. Take a look by clicking the buttons below!"""
diff --git a/Powers/plugins/fun.py b/Powers/plugins/fun.py
index 9fcd8cc23c7a0840b9055c7344794d7e04383891..a20b9c1342f4b5fc4e769a0cb6bdc603a43187aa 100644
--- a/Powers/plugins/fun.py
+++ b/Powers/plugins/fun.py
@@ -1,16 +1,13 @@
from html import escape
from random import choice
-
-
-from pyrogram.errors import MessageTooLong
+from Powers.utils import extras
+from Powers.bot_class import Gojo
from pyrogram.types import Message
-
from Powers import LOGGER, DEV_USERS
-from Powers.bot_class import Gojo
-from Powers.utils import extras
+from pyrogram.errors import MessageTooLong
from Powers.utils.custom_filters import command
from Powers.utils.extract_user import extract_user
-from Powers.utils.extras import YESWNO as YES, NOWYES as NO
+from Powers.utils.extras import NOWYES as NO, YESWNO as YES
@Gojo.on_message(command("shout"))
@@ -95,38 +92,45 @@ async def fun_toss(_, m: Message):
LOGGER.info(f"{m.from_user.id} tossed in {m.chat.id}")
return
+
@Gojo.on_message(command("insult"))
-async def insult(c : Gojo , m: Message):
+async def insult(c: Gojo, m: Message):
try:
user_id, user_first_name, _ = await extract_user(c, m)
- except:
+ except BaseException:
return
if user_id in DEV_USERS:
await m.reply_text("Sorry! I can't insult my devs....")
- return LOGGER.info(f"{m.from_user.id} tried to insult {user_first_name} in {m.chat.id}")
- else:
+ return LOGGER.info(
+ f"{m.from_user.id} tried to insult {user_first_name} in {m.chat.id}"
+ )
+ else:
Insult_omp = choice(extras.INSULT_STRINGS)
- reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
+ reply_text = (
+ m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
+ )
await reply_text(Insult_omp)
LOGGER.info(f"{m.from_user.id} insulted {user_first_name} in {m.chat.id}")
-
+
+
@Gojo.on_message(command("yes"))
-async def yesw(c : Gojo , m: Message):
+async def yesw(c: Gojo, m: Message):
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
rtext = YES[0]
await reply_text(rtext)
LOGGER.info(f"{m.from_user.id} said YES or may be NO in {m.chat.id}")
return
-
-
+
+
@Gojo.on_message(command("no"))
-async def now(c : Gojo , m: Message):
+async def now(c: Gojo, m: Message):
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
rtext = NO[0]
await reply_text(rtext)
LOGGER.info(f"{m.from_user.id} said NO or may be YES in {m.chat.id}")
return
+
@Gojo.on_message(command("shrug"))
async def fun_shrug(_, m: Message):
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
@@ -188,7 +192,7 @@ async def weebify(_, m: Message):
string = string.replace(normiecharacter, weebycharacter)
await m.reply_text(
- text=f"""Weebified String:
+ text=f"""Weebified String:
{string}
"""
)
LOGGER.info(f"{m.from_user.id} weebified '{args}' in {m.chat.id}")
diff --git a/Powers/plugins/greetings.py b/Powers/plugins/greetings.py
index d6fc17f8b6f12a23d5abad8de6913035c8b034d2..72c9a1efeb541cb94917f7fb7d5fe4dd3c061a58 100644
--- a/Powers/plugins/greetings.py
+++ b/Powers/plugins/greetings.py
@@ -1,24 +1,20 @@
from html import escape
from secrets import choice
-
-from pyrogram import filters
-from pyrogram.errors import ChatAdminRequired, RPCError
-from pyrogram.types import ChatMemberUpdated, InlineKeyboardMarkup, Message
-
from Powers import DEV_USERS
+from pyrogram import filters
+from Powers.vars import Config
from Powers.bot_class import Gojo
+from Powers.utils.chat_type import chattype
from Powers.database.antispam_db import GBan
from Powers.database.greetings_db import Greetings
-from Powers.utils.custom_filters import admin_filter, bot_admin_filter, command
-from Powers.utils.chat_type import chattype
from Powers.utils.msg_types import Types, get_wlcm_type
-from Powers.utils.parser import escape_markdown, mention_html
+from pyrogram.errors import RPCError, ChatAdminRequired
+from Powers.utils.parser import mention_html, escape_markdown
+from pyrogram.types import Message, ChatMemberUpdated, InlineKeyboardMarkup
+from Powers.utils.custom_filters import command, admin_filter, bot_admin_filter
from Powers.utils.string import (
- build_keyboard,
- escape_invalid_curly_brackets,
- parse_button,
-)
-from Powers.vars import Config
+ parse_button, build_keyboard, escape_invalid_curly_brackets)
+
# Initialize
gdb = GBan()
diff --git a/Powers/plugins/info.py b/Powers/plugins/info.py
index bd6b0ee84680d61bcb2eefcc1e9910eff030e00f..b174a9bf636099344ea6385f9a2b9fb750c32bcb 100644
--- a/Powers/plugins/info.py
+++ b/Powers/plugins/info.py
@@ -1,26 +1,31 @@
import os
-from traceback import format_exc
-from datetime import datetime
-
-from pyrogram.types import Message
from pyrogram import enums
-
-from Powers import DEV_USERS, SUDO_USERS, WHITELIST_USERS, SUPPORT_STAFF, LOGGER
+from datetime import datetime
+from traceback import format_exc
from Powers.bot_class import Gojo
-from Powers.database.antispam_db import GBan
+from pyrogram.types import Message
+from Powers.utils.chat_type import c_type
from Powers.database.users_db import Users
+from Powers.database.antispam_db import GBan
from Powers.utils.custom_filters import command
from Powers.utils.extract_user import extract_user
-from Powers.utils.chat_type import c_type
+from Powers import (
+ LOGGER, DEV_USERS, SUDO_USERS, SUPPORT_STAFF, WHITELIST_USERS)
+
+
+gban_db = GBan()
-gban_db=GBan()
async def count(c: Gojo, chat):
administrator = []
- async for admin in c.get_chat_members(chat_id=chat, filter = enums.ChatMembersFilter.ADMINISTRATORS):
- total_admin = administrator.append(admin)
+ async for admin in c.get_chat_members(
+ chat_id=chat, filter=enums.ChatMembersFilter.ADMINISTRATORS
+ ):
+ total_admin = administrator.append(admin)
bot = []
- async for tbot in c.get_chat_members(chat_id=chat, filter= enums.ChatMembersFilter.BOTS):
+ async for tbot in c.get_chat_members(
+ chat_id=chat, filter=enums.ChatMembersFilter.BOTS
+ ):
total_bot = bot.append(tbot)
bot_admin = 0
ban = []
@@ -35,25 +40,27 @@ async def count(c: Gojo, chat):
total_banned = len(total_banned)
return total_bot, total_admin, bot_admin, total_banned
+
async def user_info(c: Gojo, user, already=False):
if not already:
- # try:
- # user = Users.get_user_info(int(user)) # Try to fetch user info form database if available give key error if user is not present
- # user = user["_id"]
- # user = await c.get_users(user_ids=user)
- # except KeyError:
+ # try:
+ # user = Users.get_user_info(int(user)) # Try to fetch user info form database if available give key error if user is not present
+ # user = user["_id"]
+ # user = await c.get_users(user_ids=user)
+ # except KeyError:
# LOGGER.warning(f"Calling api to fetch info about user {user}")
- # user = await c.get_users(user_ids=user) # Fetch user info in traditional way if not available in db
+ # user = await c.get_users(user_ids=user) # Fetch user info in
+ # traditional way if not available in db
user = await c.get_users(user_ids=user)
if not user.first_name:
return ["Deleted account", None]
-
+
gbanned, reason_gban = gban_db.get_gban(user)
if gbanned:
- gban=True
+ gban = True
reason = f"The user is gbanned because {reason_gban}"
else:
- gban=False
+ gban = False
reason = "User is not gbanned"
user_id = user.id
@@ -78,8 +85,7 @@ async def user_info(c: Gojo, user, already=False):
is_bot = user.is_bot
is_fake = user.is_fake
status = user.status
-
-
+
if is_bot is True:
last_date = "Targeted user is a bot"
elif status == "recently":
@@ -95,10 +101,10 @@ async def user_info(c: Gojo, user, already=False):
elif status == "offline":
last_date = datetime.fromtimestamp(user.status.date).strftime(
"%a, %d %b %Y, %H:%M:%S"
- )
+ )
else:
last_date = "User is currently online"
-
+
caption = f"""
⚡ Extracted User info From Telegram ⚡
@@ -120,7 +126,7 @@ async def user_info(c: Gojo, user, already=False):
👀 Last seen: {last_date}
"""
-
+
return caption, photo_id
@@ -130,7 +136,7 @@ async def chat_info(c: Gojo, chat, already=False):
online_mem = c.get_chat_online_count(chat)
chat_id = chat.id
username = chat.username
- total_bot, total_admin, total_bot_admin, total_banned = await count(c,chat)
+ total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat)
title = chat.title
type_ = c_type(c, chat_id=chat)
is_scam = chat.is_scam
@@ -149,7 +155,7 @@ async def chat_info(c: Gojo, chat, already=False):
sticker_set = chat.sticker_set_name
linked_chat = chat.linked_chat
reactions = chat.available_reactions
-
+
caption = f"""
🔰 CHAT INFO 🔰
@@ -180,21 +186,27 @@ async def chat_info(c: Gojo, chat, already=False):
return caption, photo_id
-@Gojo.on_message(command(["info","whois"]))
+@Gojo.on_message(command(["info", "whois"]))
async def info_func(c: Gojo, message: Message):
try:
- user, _ , _= await extract_user(c , message)
+ user, _, _ = await extract_user(c, message)
except Exception as e:
- return await message.reply_text(f"Got an error while running extract_user function error is {e}.....Give this message in supoort group")
-
+ return await message.reply_text(
+ f"Got an error while running extract_user function error is {e}.....Give this message in supoort group"
+ )
+
if not user:
message.reply_text("Can't find user to fetch info!")
-
- m = await message.reply_text(f"Fetching user info of user {message.from_user.id}...")
+
+ m = await message.reply_text(
+ f"Fetching user info of user {message.from_user.id}..."
+ )
try:
- info_caption, photo_id = await user_info(c , user=user)
- LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {message.from_user.id} in {message.chat.id}")
+ info_caption, photo_id = await user_info(c, user=user)
+ LOGGER.info(
+ f"{message.from_user.id} tried to fetch user info of user {message.from_user.id} in {message.chat.id}"
+ )
except Exception as e:
LOGGER.error(e)
LOGGER.error(format_exc())
@@ -207,27 +219,29 @@ async def info_func(c: Gojo, message: Message):
await message.reply_photo(photo, caption=info_caption, quote=False)
await m.delete()
os.remove(photo)
- LOGGER.info(f"{message.from_user.id} fetched user info of user {user.username} in {m.chat.id}")
+ LOGGER.info(
+ f"{message.from_user.id} fetched user info of user {user.username} in {m.chat.id}"
+ )
-
-@Gojo.on_message(command(["chinfo","chatinfo","chat_info"]))
+@Gojo.on_message(command(["chinfo", "chatinfo", "chat_info"]))
async def chat_info_func(c: Gojo, message: Message):
- splited = message.text.split()
+ splited = message.text.split()
try:
if len(splited) == 1:
chat = message.chat.id
else:
chat = splited[1]
-
+
try:
chat = int(chat)
except ValueError:
return await message.reply_text("**Usage:**/chinfo [USERNAME|ID]")
-
- m = await message.reply_text(f"Fetching chat info of chat **{message.chat.title}**.....")
+ m = await message.reply_text(
+ f"Fetching chat info of chat **{message.chat.title}**....."
+ )
info_caption, photo_id = await chat_info(c, chat=chat)
if not photo_id:
@@ -235,7 +249,9 @@ async def chat_info_func(c: Gojo, message: Message):
photo = await Gojo.download_media(photo_id)
await message.reply_photo(photo, caption=info_caption, quote=False)
- LOGGER.info(f"{message.from_user.id} fetched chat info of chat {chat} in {message.chat.id}")
+ LOGGER.info(
+ f"{message.from_user.id} fetched chat info of chat {chat} in {message.chat.id}"
+ )
await m.delete()
os.remove(photo)
@@ -244,11 +260,12 @@ async def chat_info_func(c: Gojo, message: Message):
LOGGER.error(e)
LOGGER.error(format_exc())
+
__PLUGIN__ = "info"
__alt_name__ = [
"info",
"chinfo",
-]
+]
__HELP__ = """
***Information***
diff --git a/Powers/plugins/initial.py b/Powers/plugins/initial.py
index 6cc6a675d210becee6b1b4d5f3a97f82cc984aaf..3cbd7790a1166ff24db5c43cb0338d0d1788c8ab 100644
--- a/Powers/plugins/initial.py
+++ b/Powers/plugins/initial.py
@@ -1,20 +1,19 @@
-from pyrogram import filters
-from pyrogram.errors import RPCError
-from pyrogram.types import Message
-
from Powers import LOGGER
+from pyrogram import filters
from Powers.bot_class import Gojo
-from Powers.database.approve_db import Approve
-from Powers.database.blacklist_db import Blacklist
+from pyrogram.types import Message
+from pyrogram.errors import RPCError
+from Powers.database.pins_db import Pins
from Powers.database.chats_db import Chats
-from Powers.database.disable_db import Disabling
+from Powers.database.rules_db import Rules
+from Powers.database.users_db import Users
+from Powers.database.approve_db import Approve
from Powers.database.filters_db import Filters
+from Powers.database.disable_db import Disabling
+from Powers.database.blacklist_db import Blacklist
from Powers.database.greetings_db import Greetings
-from Powers.database.notes_db import Notes, NotesSettings
-from Powers.database.pins_db import Pins
from Powers.database.reporting_db import Reporting
-from Powers.database.rules_db import Rules
-from Powers.database.users_db import Users
+from Powers.database.notes_db import Notes, NotesSettings
@Gojo.on_message(filters.group, group=4)
diff --git a/Powers/plugins/locks.py b/Powers/plugins/locks.py
index d9ecc83a80ad4eb983da25e2f0bc12e0e724c3fc..3267f432b2a10b7f29979e91da1c780c7faad217 100644
--- a/Powers/plugins/locks.py
+++ b/Powers/plugins/locks.py
@@ -1,12 +1,10 @@
-from asyncio import sleep
-
-from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
-from pyrogram.types import ChatPermissions, Message
-
from Powers import LOGGER
+from asyncio import sleep
from Powers.bot_class import Gojo
from Powers.database.approve_db import Approve
+from pyrogram.types import Message, ChatPermissions
from Powers.utils.custom_filters import command, restrict_filter
+from pyrogram.errors import RPCError, ChatNotModified, ChatAdminRequired
@Gojo.on_message(command("locktypes"))
@@ -111,9 +109,11 @@ async def lock_perm(c: Gojo, m: Message):
perm = "pin"
else:
- await m.reply_text(text=""" Invalid Lock Type!
+ await m.reply_text(
+ text=""" Invalid Lock Type!
- Use /locktypes to get the lock types""")
+ Use /locktypes to get the lock types"""
+ )
return
try:
@@ -277,9 +277,11 @@ async def unlock_perm(c: Gojo, m: Message):
uperm = "pin"
else:
- await m.reply_text(text="""Invalid Lock Type!
+ await m.reply_text(
+ text="""Invalid Lock Type!
- Use /locktypes to get the lock types""")
+ Use /locktypes to get the lock types"""
+ )
return
try:
@@ -327,7 +329,7 @@ __PLUGIN__ = "locks"
__alt_name__ = ["grouplock", "lock", "grouplocks"]
-__HELP__ = """
+__HELP__ = """
***Locks***
Use this to lock group permissions.
@@ -340,4 +342,4 @@ Allows you to lock and unlock permission types in the chat.
* /locktypes: Check available lock types!
**Example:**
-`/lock media`: this locks all the media messages in the chat."""
\ No newline at end of file
+`/lock media`: this locks all the media messages in the chat."""
diff --git a/Powers/plugins/muting.py b/Powers/plugins/muting.py
index 487e1d4c07336d800ce759e55ea2928fb2de8224..c91c475c94f30a375b2475b351704c17a6d66d5f 100644
--- a/Powers/plugins/muting.py
+++ b/Powers/plugins/muting.py
@@ -1,32 +1,24 @@
from random import choice
-from pyrogram.errors import (
- ChatAdminRequired,
- RightForbidden,
- RPCError,
- UserNotParticipant,
-)
-from pyrogram.filters import regex
-from pyrogram.types import (
- CallbackQuery,
- ChatPermissions,
- InlineKeyboardButton,
- InlineKeyboardMarkup,
- Message,
-)
-
-from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
+from Powers.vars import Config
from Powers.bot_class import Gojo
-from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
-from Powers.utils.custom_filters import command, restrict_filter
-from Powers.utils.extract_user import extract_user
+from pyrogram.filters import regex
+from Powers.utils.extras import MUTE_GIFS
from Powers.utils.parser import mention_html
from Powers.utils.string import extract_time
-from Powers.vars import Config
-from Powers.utils.extras import MUTE_GIFS
+from Powers.utils.extract_user import extract_user
+from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
+from Powers.utils.custom_filters import command, restrict_filter
+from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
+from pyrogram.errors import (
+ RPCError, RightForbidden, ChatAdminRequired, UserNotParticipant)
+from pyrogram.types import (
+ Message, CallbackQuery, ChatPermissions, InlineKeyboardButton,
+ InlineKeyboardMarkup)
MUTE_MEDIA = choice(MUTE_GIFS)
+
@Gojo.on_message(command("tmute") & restrict_filter)
async def tmute_usr(c: Gojo, m: Message):
if len(m.text.split()) == 1 and not m.reply_to_message:
@@ -49,7 +41,9 @@ async def tmute_usr(c: Gojo, m: Message):
LOGGER.info(
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
return
try:
@@ -92,9 +86,9 @@ async def tmute_usr(c: Gojo, m: Message):
mutetime,
)
LOGGER.info(f"{m.from_user.id} tmuted {user_id} in {m.chat.id}")
- admin=(await mention_html(m.from_user.first_name, m.from_user.id))
- muted=(await mention_html(user_first_name, user_id))
- txt =f"Admin {admin} muted {muted}!"
+ admin = await mention_html(m.from_user.first_name, m.from_user.id)
+ muted = await mention_html(user_first_name, user_id)
+ txt = f"Admin {admin} muted {muted}!"
if reason:
txt += f"\nReason: {reason}"
keyboard = InlineKeyboardMarkup(
@@ -107,7 +101,12 @@ async def tmute_usr(c: Gojo, m: Message):
],
],
)
- await m.reply_animation(animation = MUTE_MEDIA, caption=txt, reply_markup=keyboard, reply_to_message_id=r_id)
+ await m.reply_animation(
+ animation=MUTE_MEDIA,
+ caption=txt,
+ reply_markup=keyboard,
+ reply_to_message_id=r_id,
+ )
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
except RightForbidden:
@@ -149,7 +148,9 @@ async def dtmute_usr(c: Gojo, m: Message):
LOGGER.info(
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
- await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
return
try:
@@ -158,7 +159,7 @@ async def dtmute_usr(c: Gojo, m: Message):
admins_group = await admin_cache_reload(m, "mute")
if user_id in admins_group:
- await m.reply_text(text = "This user is an admin, I cannot mute them!")
+ await m.reply_text(text="This user is an admin, I cannot mute them!")
return
if m.reply_to_message and len(m.text.split()) >= 2:
@@ -190,8 +191,8 @@ async def dtmute_usr(c: Gojo, m: Message):
)
LOGGER.info(f"{m.from_user.id} dtmuted {user_id} in {m.chat.id}")
await m.reply_to_message.delete()
- admin=(await mention_html(m.from_user.first_name, m.from_user.id))
- muted=(await mention_html(user_first_name, user_id))
+ admin = await mention_html(m.from_user.first_name, m.from_user.id)
+ muted = await mention_html(user_first_name, user_id)
txt = f"Admin {admin} muted {muted}!"
if reason:
txt += f"\nReason: {reason}"
@@ -205,16 +206,22 @@ async def dtmute_usr(c: Gojo, m: Message):
],
],
)
- await c.send_animation(animation=MUTE_MEDIA, chat_id=m.chat.id, caption=txt, reply_markup=keyboard, unsave=True)
+ await c.send_animation(
+ animation=MUTE_MEDIA,
+ chat_id=m.chat.id,
+ caption=txt,
+ reply_markup=keyboard,
+ unsave=True,
+ )
except ChatAdminRequired:
- await m.reply_text(text = "I'm not admin or I don't have rights.")
+ await m.reply_text(text="I'm not admin or I don't have rights.")
except RightForbidden:
- await m.reply_text(text = "I don't have enough rights to ban this user.")
+ await m.reply_text(text="I don't have enough rights to ban this user.")
except UserNotParticipant:
await m.reply_text("How can I mute a user who is not a part of this chat?")
except RPCError as ef:
await m.reply_text(
- text = f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
@@ -245,7 +252,9 @@ async def stmute_usr(c: Gojo, m: Message):
LOGGER.info(
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
- await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
return
try:
@@ -254,7 +263,7 @@ async def stmute_usr(c: Gojo, m: Message):
admins_group = await admin_cache_reload(m, "mute")
if user_id in admins_group:
- await m.reply_text(text = "This user is an admin, I cannot mute them!")
+ await m.reply_text(text="This user is an admin, I cannot mute them!")
return
if m.reply_to_message and len(m.text.split()) >= 2:
@@ -289,14 +298,14 @@ async def stmute_usr(c: Gojo, m: Message):
if m.reply_to_message:
await m.reply_to_message.delete()
except ChatAdminRequired:
- await m.reply_text(text = "I'm not admin or I don't have rights.")
+ await m.reply_text(text="I'm not admin or I don't have rights.")
except RightForbidden:
- await m.reply_text(text = "I don't have enough rights to ban this user.")
+ await m.reply_text(text="I don't have enough rights to ban this user.")
except UserNotParticipant:
await m.reply_text("How can I mute a user who is not a part of this chat?")
except RPCError as ef:
await m.reply_text(
- text = f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
@@ -336,7 +345,9 @@ async def mute_usr(c: Gojo, m: Message):
LOGGER.info(
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
- await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
return
try:
@@ -345,7 +356,7 @@ async def mute_usr(c: Gojo, m: Message):
admins_group = await admin_cache_reload(m, "mute")
if user_id in admins_group:
- await m.reply_text(text = "This user is an admin, I cannot mute them!")
+ await m.reply_text(text="This user is an admin, I cannot mute them!")
return
try:
@@ -354,8 +365,8 @@ async def mute_usr(c: Gojo, m: Message):
ChatPermissions(),
)
LOGGER.info(f"{m.from_user.id} muted {user_id} in {m.chat.id}")
- admin=(await mention_html(m.from_user.first_name, m.from_user.id))
- muted=(await mention_html(user_first_name, user_id))
+ admin = await mention_html(m.from_user.first_name, m.from_user.id)
+ muted = await mention_html(user_first_name, user_id)
txt = f"Admin {admin} muted {muted}!"
if reason:
txt += f"\nReason: {reason}"
@@ -369,16 +380,21 @@ async def mute_usr(c: Gojo, m: Message):
],
],
)
- await m.reply_animation(animation=MUTE_MEDIA, caption=txt, reply_markup=keyboard, reply_to_message_id=r_id)
+ await m.reply_animation(
+ animation=MUTE_MEDIA,
+ caption=txt,
+ reply_markup=keyboard,
+ reply_to_message_id=r_id,
+ )
except ChatAdminRequired:
- await m.reply_text(text = "I'm not admin or I don't have rights.")
+ await m.reply_text(text="I'm not admin or I don't have rights.")
except RightForbidden:
- await m.reply_text(text = "I don't have enough rights to ban this user.")
+ await m.reply_text(text="I don't have enough rights to ban this user.")
except UserNotParticipant:
await m.reply_text("How can I mute a user who is not a part of this chat?")
except RPCError as ef:
await m.reply_text(
- text = f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
@@ -409,7 +425,9 @@ async def smute_usr(c: Gojo, m: Message):
LOGGER.info(
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
- await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
return
try:
@@ -418,7 +436,7 @@ async def smute_usr(c: Gojo, m: Message):
admins_group = await admin_cache_reload(m, "mute")
if user_id in admins_group:
- await m.reply_text(text = "This user is an admin, I cannot mute them!")
+ await m.reply_text(text="This user is an admin, I cannot mute them!")
return
try:
@@ -433,14 +451,14 @@ async def smute_usr(c: Gojo, m: Message):
return
return
except ChatAdminRequired:
- await m.reply_text(text = "I'm not admin or I don't have rights.")
+ await m.reply_text(text="I'm not admin or I don't have rights.")
except RightForbidden:
- await m.reply_text(text = "I don't have enough rights to ban this user.")
+ await m.reply_text(text="I don't have enough rights to ban this user.")
except UserNotParticipant:
await m.reply_text("How can I mute a user who is not a part of this chat?")
except RPCError as ef:
await m.reply_text(
- text = f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
@@ -478,7 +496,9 @@ async def dmute_usr(c: Gojo, m: Message):
LOGGER.info(
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
- await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
return
try:
@@ -487,7 +507,7 @@ async def dmute_usr(c: Gojo, m: Message):
admins_group = await admin_cache_reload(m, "mute")
if user_id in admins_group:
- await m.reply_text(text = "This user is an admin, I cannot mute them!")
+ await m.reply_text(text="This user is an admin, I cannot mute them!")
return
try:
@@ -497,8 +517,8 @@ async def dmute_usr(c: Gojo, m: Message):
)
LOGGER.info(f"{m.from_user.id} dmuted {user_id} in {m.chat.id}")
await m.reply_to_message.delete()
- admin=(await mention_html(m.from_user.first_name, m.from_user.id))
- muted=(await mention_html(user_first_name, user_id))
+ admin = await mention_html(m.from_user.first_name, m.from_user.id)
+ muted = await mention_html(user_first_name, user_id)
txt = f"Admin {admin} muted {muted}!"
if reason:
txt += f"\nReason: {reason}"
@@ -512,16 +532,18 @@ async def dmute_usr(c: Gojo, m: Message):
],
],
)
- await c.send_animation(animation=MUTE_MEDIA,chat_id=m.chat.id, caption=txt, reply_markup=keyboard)
+ await c.send_animation(
+ animation=MUTE_MEDIA, chat_id=m.chat.id, caption=txt, reply_markup=keyboard
+ )
except ChatAdminRequired:
- await m.reply_text(text = "I'm not admin or I don't have rights.")
+ await m.reply_text(text="I'm not admin or I don't have rights.")
except RightForbidden:
- await m.reply_text(text = "I don't have enough rights to ban this user.")
+ await m.reply_text(text="I don't have enough rights to ban this user.")
except UserNotParticipant:
await m.reply_text("How can I mute a user who is not a part of this chat?")
except RPCError as ef:
await m.reply_text(
- text = f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
@@ -548,20 +570,18 @@ async def unmute_usr(c: Gojo, m: Message):
try:
await m.chat.unban_member(user_id)
LOGGER.info(f"{m.from_user.id} unmuted {user_id} in {m.chat.id}")
- admin=(await mention_html(m.from_user.first_name, m.from_user.id))
- unmuted=(await mention_html(user_first_name, user_id))
- await m.reply_text(
- text=f"Admin {admin} unmuted {unmuted}!"
- )
+ admin = await mention_html(m.from_user.first_name, m.from_user.id)
+ unmuted = await mention_html(user_first_name, user_id)
+ await m.reply_text(text=f"Admin {admin} unmuted {unmuted}!")
except ChatAdminRequired:
- await m.reply_text(text = "I'm not admin or I don't have rights.")
+ await m.reply_text(text="I'm not admin or I don't have rights.")
except UserNotParticipant:
await m.reply_text("How can I unmute a user who is not a part of this chat?")
except RightForbidden:
await m.reply_text(text="I don't have enough rights to ban this user.")
except RPCError as ef:
await m.reply_text(
- text = f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
diff --git a/Powers/plugins/notes.py b/Powers/plugins/notes.py
index c846b6001472c0e17925b871d9a8a414fa2c4b0e..797b16fc4a11f9b265553ce4e329c8d515c5fab8 100644
--- a/Powers/plugins/notes.py
+++ b/Powers/plugins/notes.py
@@ -1,23 +1,19 @@
+from Powers import LOGGER
from secrets import choice
-from traceback import format_exc
-
from pyrogram import filters
-from pyrogram.errors import RPCError
-from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, Message
-
-from Powers import LOGGER
+from Powers.vars import Config
+from traceback import format_exc
from Powers.bot_class import Gojo
-from Powers.database.notes_db import Notes, NotesSettings
-from Powers.utils.cmd_senders import send_cmd
-from Powers.utils.custom_filters import admin_filter, command, owner_filter
+from pyrogram.errors import RPCError
from Powers.utils.kbhelpers import ikb
+from Powers.utils.cmd_senders import send_cmd
from Powers.utils.msg_types import Types, get_note_type
+from Powers.database.notes_db import Notes, NotesSettings
+from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
+from Powers.utils.custom_filters import command, admin_filter, owner_filter
from Powers.utils.string import (
- build_keyboard,
- escape_mentions_using_curly_brackets,
- parse_button,
-)
-from Powers.vars import Config
+ parse_button, build_keyboard, escape_mentions_using_curly_brackets)
+
# Initialise
db = Notes()
@@ -454,4 +450,4 @@ Only admins can save and deletenotes, anyone can get them.
* /privatenotes ``: Whether to turn private rules on or off, prevents spam in chat when people use notes command.
── **Note Format** ──
- Check /markdownhelp for help related to formatting!"""
\ No newline at end of file
+ Check /markdownhelp for help related to formatting!"""
diff --git a/Powers/plugins/pin.py b/Powers/plugins/pin.py
index fd27f7847b654fc7d41d21542414fc6e6e7356a0..70643eec25345c8b30e02d5045430b334bff8907 100644
--- a/Powers/plugins/pin.py
+++ b/Powers/plugins/pin.py
@@ -1,15 +1,13 @@
-from html import escape as escape_html
-
-from pyrogram.errors import ChatAdminRequired, RightForbidden, RPCError
+from Powers.bot_class import Gojo
from pyrogram.filters import regex
-from pyrogram.types import CallbackQuery, Message
-
+from Powers.utils.kbhelpers import ikb
+from html import escape as escape_html
from Powers import LOGGER, SUPPORT_GROUP
-from Powers.bot_class import Gojo
from Powers.database.pins_db import Pins
-from Powers.utils.custom_filters import admin_filter, command
-from Powers.utils.kbhelpers import ikb
-from Powers.utils.string import build_keyboard, parse_button
+from pyrogram.types import Message, CallbackQuery
+from Powers.utils.string import parse_button, build_keyboard
+from Powers.utils.custom_filters import command, admin_filter
+from pyrogram.errors import RPCError, RightForbidden, ChatAdminRequired
@Gojo.on_message(command("pin") & admin_filter)
@@ -125,7 +123,7 @@ async def unpinall_calllback(c: Gojo, q: CallbackQuery):
await q.message.edit_text(text="I don't have enough rights to unpin messages.")
except RPCError as ef:
await q.message.edit_text(
- text=f"""Some error occured, report to @{SUPPORT_GROUP}
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
Error: {ef}
"""
)
@@ -139,9 +137,7 @@ async def anti_channel_pin(_, m: Message):
if len(m.text.split()) == 1:
status = pinsdb.get_settings()["antichannelpin"]
- await m.reply_text(
- text=f"Current AntiChannelPin status: {status}"
- )
+ await m.reply_text(text=f"Current AntiChannelPin status: {status}")
return
if len(m.text.split()) == 2:
@@ -154,7 +150,9 @@ async def anti_channel_pin(_, m: Message):
LOGGER.info(f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
else:
- await m.reply_text(text="Please check help on how to use this this command.")
+ await m.reply_text(
+ text="Please check help on how to use this this command."
+ )
return
await m.reply_text(msg)
@@ -191,9 +189,7 @@ async def clean_linked(_, m: Message):
if len(m.text.split()) == 1:
status = pinsdb.get_settings()["cleanlinked"]
- await m.reply_text(
- text=f"Current AntiChannelPin status: {status}"
- )
+ await m.reply_text(text=f"Current AntiChannelPin status: {status}")
return
if len(m.text.split()) == 2:
@@ -206,7 +202,9 @@ async def clean_linked(_, m: Message):
LOGGER.info(f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
else:
- await m.reply_text(text="Please check help on how to use this this command.")
+ await m.reply_text(
+ text="Please check help on how to use this this command."
+ )
return
await m.reply_text(msg)
@@ -248,4 +246,4 @@ Here you find find all help related to groups pins and how to manage them via me
* /unpinall: Unpins all the pinned message in the current chat.
* /antichannelpin ``: Toggle antichannelpin status. All the messages from linked channel will be unpinned if enabled!
* /cleanlinked ``: Toggle cleanlinked status. All the messages from linked channel will be deleted if enabled!
-* /permapin ``: Pin a custom messages via bot. This message can contain markdown, and can be used in replies to the media include additional buttons and text."""
\ No newline at end of file
+* /permapin ``: Pin a custom messages via bot. This message can contain markdown, and can be used in replies to the media include additional buttons and text."""
diff --git a/Powers/plugins/purge.py b/Powers/plugins/purge.py
index a7385ef14113d19815bdf537a38ff90557145e1d..334c5fff970625b6f6e5852fb0a288a50d591e54 100644
--- a/Powers/plugins/purge.py
+++ b/Powers/plugins/purge.py
@@ -1,12 +1,10 @@
from asyncio import sleep
-
-from pyrogram.errors import MessageDeleteForbidden, RPCError
-from pyrogram.types import Message
-
from Powers import SUPPORT_GROUP
from Powers.bot_class import Gojo
+from pyrogram.types import Message
from Powers.utils.chat_type import chattype
-from Powers.utils.custom_filters import admin_filter, command
+from pyrogram.errors import RPCError, MessageDeleteForbidden
+from Powers.utils.custom_filters import command, admin_filter
@Gojo.on_message(command("purge") & admin_filter)
@@ -35,7 +33,9 @@ async def purge(c: Gojo, m: Message):
)
await m.delete()
except MessageDeleteForbidden:
- await m.reply_text(text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup.")
+ await m.reply_text(
+ text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup."
+ )
return
except RPCError as ef:
await m.reply_text(
@@ -46,10 +46,7 @@ async def purge(c: Gojo, m: Message):
count_del_msg = len(message_ids)
- z = await m.reply_text(
- text=f"Deleted {count_del_msg} messages"
-
- )
+ z = await m.reply_text(text=f"Deleted {count_del_msg} messages")
await sleep(3)
await z.delete()
return
@@ -83,7 +80,9 @@ async def spurge(c: Gojo, m: Message):
)
await m.delete()
except MessageDeleteForbidden:
- await m.reply_text(text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup.")
+ await m.reply_text(
+ text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup."
+ )
return
except RPCError as ef:
await m.reply_text(
@@ -125,4 +124,4 @@ __HELP__ = """
* /purge: Deletes messages upto replied message.
* /spurge: Deletes messages upto replied message without a success message.
-* /del: Deletes a single message, used as a reply to message."""
\ No newline at end of file
+* /del: Deletes a single message, used as a reply to message."""
diff --git a/Powers/plugins/report.py b/Powers/plugins/report.py
index aa73d7494fcec55865a0ca6c7926441eb357e34a..79a68b1141576a5a97da119c31372e7e435840b2 100644
--- a/Powers/plugins/report.py
+++ b/Powers/plugins/report.py
@@ -1,17 +1,15 @@
-from traceback import format_exc
-
from pyrogram import filters
-from pyrogram.enums import ChatMembersFilter as cmf
-from pyrogram.errors import RPCError
-from pyrogram.types import CallbackQuery, Message
-
-from Powers import LOGGER, SUPPORT_STAFF
+from traceback import format_exc
from Powers.bot_class import Gojo
-from Powers.database.reporting_db import Reporting
-from Powers.utils.custom_filters import admin_filter, command
+from pyrogram.errors import RPCError
from Powers.utils.kbhelpers import ikb
+from Powers import LOGGER, SUPPORT_STAFF
from Powers.utils.chat_type import chattype
from Powers.utils.parser import mention_html
+from pyrogram.types import Message, CallbackQuery
+from Powers.database.reporting_db import Reporting
+from pyrogram.enums import ChatMembersFilter as cmf
+from Powers.utils.custom_filters import command, admin_filter
@Gojo.on_message(
@@ -101,7 +99,8 @@ async def report_watcher(c: Gojo, m: Message):
msg = f"{(await mention_html(m.from_user.first_name, m.from_user.id))} is calling for admins in '{chat_name}'!\n"
link_chat_id = str(m.chat.id).replace("-100", "")
- link = f"https://t.me/c/{link_chat_id}/{reported_msg_id}" # message link
+ # message link
+ link = f"https://t.me/c/{link_chat_id}/{reported_msg_id}"
reply_markup = ikb(
[
@@ -215,4 +214,4 @@ __HELP__ = """
**Admins Only:**
* /reports ``: change report setting, or view current status.
- If done in PM, toggles your status.
- - If in group, toggles that groups's status."""
\ No newline at end of file
+ - If in group, toggles that groups's status."""
diff --git a/Powers/plugins/rules.py b/Powers/plugins/rules.py
index 851825c427eb29290f8e8c86821790bb4c756083..99de4041e1d5a4ad307e581bb8e417e0de61c4a3 100644
--- a/Powers/plugins/rules.py
+++ b/Powers/plugins/rules.py
@@ -1,12 +1,11 @@
-from pyrogram import filters
-from pyrogram.types import CallbackQuery, Message
-
from Powers import LOGGER
+from pyrogram import filters
+from Powers.vars import Config
from Powers.bot_class import Gojo
-from Powers.database.rules_db import Rules
-from Powers.utils.custom_filters import admin_filter, command
from Powers.utils.kbhelpers import ikb
-from Powers.vars import Config
+from Powers.database.rules_db import Rules
+from pyrogram.types import Message, CallbackQuery
+from Powers.utils.custom_filters import command, admin_filter
@Gojo.on_message(command("rules") & filters.group)
@@ -105,7 +104,9 @@ async def priv_rules(_, m: Message):
await m.reply_text(msg)
elif len(m.text.split()) == 1:
curr_pref = db.get_privrules()
- msg = f"Current Preference for Private rules in this chat is: {curr_pref}"
+ msg = (
+ f"Current Preference for Private rules in this chat is: {curr_pref}"
+ )
LOGGER.info(f"{m.from_user.id} fetched privaterules preference in {m.chat.id}")
await m.reply_text(msg)
else:
@@ -122,7 +123,9 @@ async def clear_rules(_, m: Message):
rules = db.get_rules()
if not rules:
- await m.reply_text(text="The Admins for this group have not setup rules! That doesn't mean you can break the DECORUM of this group !")
+ await m.reply_text(
+ text="The Admins for this group have not setup rules! That doesn't mean you can break the DECORUM of this group !"
+ )
return
await m.reply_text(
@@ -157,4 +160,4 @@ Set rules for you chat so that members know what to do and what not to do in you
**Admin only:**
* /setrules ``: Set the rules for this chat, also works as a reply to a message.
* /clearrules: Clear the rules for this chat.
-* /privrules ``: Turns on/off the option to send the rules to PM of user or group."""
\ No newline at end of file
+* /privrules ``: Turns on/off the option to send the rules to PM of user or group."""
diff --git a/Powers/plugins/start.py b/Powers/plugins/start.py
index 93c5d3b65545e737891b05fb83c72e5558805e3b..5bd1dab2541addadcad7b39ac2bb532837fa6a74 100644
--- a/Powers/plugins/start.py
+++ b/Powers/plugins/start.py
@@ -1,32 +1,24 @@
from random import choice
-
from pyrogram import filters
-from pyrogram.errors import MessageNotModified, QueryIdInvalid, UserIsBlocked
-from pyrogram.types import CallbackQuery, Message
-
-from Powers import HELP_COMMANDS, LOGGER
+from Powers.vars import Config
from Powers.bot_class import Gojo
-from Powers.utils.custom_filters import command
-from Powers.utils.chat_type import chattype
from Powers.utils.kbhelpers import ikb
+from Powers import LOGGER, HELP_COMMANDS
from Powers.utils.extras import StartPic
from Powers.utils.chat_type import chattype
+from Powers.utils.custom_filters import command
+from pyrogram.types import Message, CallbackQuery
+from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
from Powers.utils.start_utils import (
- gen_cmds_kb,
- gen_start_kb,
- get_help_msg,
- get_private_note,
- get_private_rules,
-)
-from Powers.vars import Config
-
+ gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
+ get_private_rules)
@Gojo.on_message(
command("donate") & (filters.group | filters.private),
)
async def donate(_, m: Message):
- cpt="""
+ cpt = """
Hey Thanks for your thought of donating me!
When you donate, all the fund goes towards my development which makes on fast and responsive.
Your donation might also me get me a new feature or two, which I wasn't able to get due to server limitations.
@@ -35,11 +27,9 @@ All the fund would be put into my services such as database, storage and hosting
You can donate by contacting my owner: [Captain Ezio](http://t.me/iamgojoof6eyes)
"""
-
LOGGER.info(f"{m.from_user.id} fetched donation text in {m.chat.id}")
- await m.reply_photo(photo=choice(StartPic),
- caption=cpt)
+ await m.reply_photo(photo=choice(StartPic), caption=cpt)
return
@@ -67,7 +57,6 @@ async def close_admin_callback(_, q: CallbackQuery):
@Gojo.on_message(
command("start") & (filters.group | filters.private),
)
-
async def start(c: Gojo, m: Message):
chat_type = await chattype(m)
if chat_type == "private":
@@ -89,43 +78,42 @@ async def start(c: Gojo, m: Message):
if not help_msg:
return
-
-
await m.reply_photo(
photo=choice(StartPic),
caption=help_msg,
parse_mode="markdown",
reply_markup=ikb(help_kb),
quote=True,
-
)
return
try:
- cpt=f"""
+ cpt = f"""
Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! My self Gojo ✨.
I'm here to help you manage your groups!
Hit /help to find out more about how to use me in my full potential!
Join my [News Channel](https://t.me/gojo_updates) to get information on all the latest updates."""
-
-
await m.reply_photo(
photo=choice(StartPic),
caption=cpt,
reply_markup=(await gen_start_kb(m)),
quote=True,
-
)
except UserIsBlocked:
LOGGER.warning(f"Bot blocked by {m.from_user.id}")
else:
- kb = ikb([
- [("Connect me to pm",
- f"https://t.me/{Config.BOT_USERNAME}?start=start",
- "url"
- )]
- ])
+ kb = ikb(
+ [
+ [
+ (
+ "Connect me to pm",
+ f"https://t.me/{Config.BOT_USERNAME}?start=start",
+ "url",
+ )
+ ]
+ ]
+ )
await m.reply_photo(
photo=choice(StartPic),
caption="I'm alive :3",
@@ -138,7 +126,7 @@ Join my [News Channel](https://t.me/gojo_updates) to get information on all the
@Gojo.on_callback_query(filters.regex("^start_back$"))
async def start_back(_, q: CallbackQuery):
try:
- cpt=f"""
+ cpt = f"""
Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! My name is Gojo ✨.
I'm here to help you manage your groups!
Hit /help to find out more about how to use me in my full potential!
@@ -148,7 +136,6 @@ Join my [News Channel](http://t.me/gojo_updates) to get information on all the l
await q.edit_message_caption(
caption=cpt,
reply_markup=(await gen_start_kb(q.message)),
-
)
except MessageNotModified:
pass
@@ -165,7 +152,7 @@ async def commands_menu(_, q: CallbackQuery):
],
)
try:
- cpt=f"""
+ cpt = f"""
Hey **[{q.from_user.first_name}](http://t.me/{q.from_user.username})**! My name is Gojo✨.
I'm here to help you manage your groups!
Commands available:
@@ -174,16 +161,15 @@ Commands available:
await q.edit_message_caption(
caption=cpt,
- reply_markup=keyboard,
+ reply_markup=keyboard,
)
except MessageNotModified:
pass
except QueryIdInvalid:
await q.message.reply_photo(
- photo=choice(StartPic),
- caption=cpt,
- reply_markup=keyboard)
-
+ photo=choice(StartPic), caption=cpt, reply_markup=keyboard
+ )
+
await q.answer()
return
@@ -203,17 +189,16 @@ async def help_menu(_, m: Message):
)
chat_type = await chattype(m)
if chat_type == "private":
-
+
await m.reply_photo(
photo=choice(StartPic),
caption=help_msg,
parse_mode="markdown",
reply_markup=ikb(help_kb),
quote=True,
-
)
else:
-
+
await m.reply_photo(
photo=choice(StartPic),
caption=f"Press the button below to get help for {help_option}",
@@ -238,7 +223,7 @@ async def help_menu(_, m: Message):
[("« Back", "start_back")],
],
)
- msg =f"""
+ msg = f"""
Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!My name is Gojo✨.
I'm here to help you manage your groups!
Commands available:
@@ -249,7 +234,7 @@ Commands available:
[[("Help", f"t.me/{Config.BOT_USERNAME}?start=help", "url")]],
)
msg = "Contact me in PM to get the list of possible commands."
-
+
await m.reply_photo(
photo=choice(StartPic),
caption=msg,
@@ -263,7 +248,7 @@ Commands available:
async def get_module_info(_, q: CallbackQuery):
module = q.data.split(".", 1)[1]
- help_msg = f"**{str(module)}:**\n\n" + HELP_COMMANDS[module]["help_msg"],
+ help_msg = (f"**{str(module)}:**\n\n" + HELP_COMMANDS[module]["help_msg"],)
help_kb = HELP_COMMANDS[module]["buttons"] + [
[("« " + "Back", "commands")],
diff --git a/Powers/plugins/stats.py b/Powers/plugins/stats.py
index 322ff19e52a17b617a06aff8babe0e1bbf07d3eb..a441a0a733a2d2aaf0ea21d41a71c2ffe1c1cd76 100644
--- a/Powers/plugins/stats.py
+++ b/Powers/plugins/stats.py
@@ -1,19 +1,18 @@
-from pyrogram.types import Message
-
from Powers.bot_class import Gojo
+from pyrogram.types import Message
+from Powers.database.pins_db import Pins
+from Powers.database.chats_db import Chats
+from Powers.database.rules_db import Rules
+from Powers.database.users_db import Users
from Powers.database.antispam_db import GBan
from Powers.database.approve_db import Approve
-from Powers.database.blacklist_db import Blacklist
-from Powers.database.chats_db import Chats
-from Powers.database.disable_db import Disabling
from Powers.database.filters_db import Filters
+from Powers.utils.custom_filters import command
+from Powers.database.disable_db import Disabling
+from Powers.database.blacklist_db import Blacklist
from Powers.database.greetings_db import Greetings
-from Powers.database.notes_db import Notes, NotesSettings
-from Powers.database.pins_db import Pins
-from Powers.database.rules_db import Rules
-from Powers.database.users_db import Users
from Powers.database.warns_db import Warns, WarnSettings
-from Powers.utils.custom_filters import command
+from Powers.database.notes_db import Notes, NotesSettings
@Gojo.on_message(command("stats", dev_cmd=True))
diff --git a/Powers/plugins/utils.py b/Powers/plugins/utils.py
index b103d09c7a17daf8089f6379365b849ae290317d..6d27eb456a0070c626b396608ebd7b9b8ceb705d 100644
--- a/Powers/plugins/utils.py
+++ b/Powers/plugins/utils.py
@@ -1,41 +1,38 @@
-from io import BytesIO
-from os import remove
import re
import aiofiles
-from search_engine_parser import GoogleSearch
-from datetime import datetime
-from aiohttp import ClientSession
+from Powers import *
+from os import remove
+from io import BytesIO
from tswift import Song
+from pyrogram import filters
+from datetime import datetime
from wikipedia import summary
-from wikipedia.exceptions import DisambiguationError, PageError
+from Powers.vars import Config
from traceback import format_exc
-
-from gpytranslate import Translator
-from pyrogram import filters
-from pyrogram.errors import MessageTooLong, PeerIdInvalid, RPCError
-from pyrogram.types import Message,InlineKeyboardButton, InlineKeyboardMarkup
-
-
-from Powers import *
from Powers.bot_class import Gojo
-from Powers.database.users_db import Users
-from Powers.utils.clean_file import remove_markdown_and_html
-from Powers.utils.custom_filters import command
-from Powers.utils.chat_type import chattype
+from aiohttp import ClientSession
+from gpytranslate import Translator
from Powers.utils.http_helper import *
from Powers.utils.kbhelpers import ikb
+from Powers.database.users_db import Users
+from Powers.utils.chat_type import chattype
from Powers.utils.parser import mention_html
+from search_engine_parser import GoogleSearch
+from Powers.utils.custom_filters import command
from Powers.utils.extract_user import extract_user
-from Powers.vars import Config
-
-
+from Powers.utils.clean_file import remove_markdown_and_html
+from wikipedia.exceptions import PageError, DisambiguationError
+from pyrogram.errors import RPCError, PeerIdInvalid, MessageTooLong
+from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
@Gojo.on_message(command("wiki"))
async def wiki(_, m: Message):
if len(m.text.split()) <= 1:
- return await m.reply_text(text="Please check help on how to use this this command.")
+ return await m.reply_text(
+ text="Please check help on how to use this this command."
+ )
search = m.text.split(None, 1)[1]
try:
@@ -102,9 +99,8 @@ async def get_lyrics(_, m: Message):
if not query:
await m.edit_text(text="You haven't specified which song to look for!")
return
- song_name=query
- em = await m.reply_text(
- text=f"Finding lyrics for {song_name}...")
+ song_name = query
+ em = await m.reply_text(text=f"Finding lyrics for {song_name}...")
song = Song.find_song(query)
if song:
if song.lyrics:
@@ -144,10 +140,10 @@ async def id_info(c: Gojo, m: Message):
if m.reply_to_message and m.reply_to_message.forward_from:
user1 = m.reply_to_message.from_user
user2 = m.reply_to_message.forward_from
- orig_sender=(await mention_html(user2.first_name, user2.id)),
- orig_id=f"{user2.id}
",
- fwd_sender=(await mention_html(user1.first_name, user1.id)),
- fwd_id=f"{user1.id}
",
+ orig_sender = ((await mention_html(user2.first_name, user2.id)),)
+ orig_id = (f"{user2.id}
",)
+ fwd_sender = ((await mention_html(user1.first_name, user1.id)),)
+ fwd_id = (f"{user1.id}
",)
await m.reply_text(
text=f"""Original Sender - {orig_sender} ({orig_id}
)
Forwarder - {fwd_sender} ({fwd_id}
)""",
@@ -157,8 +153,10 @@ async def id_info(c: Gojo, m: Message):
try:
user = await c.get_users(user_id)
except PeerIdInvalid:
- await m.reply_text(text="""Failed to get user
- Peer ID invalid, I haven't seen this user anywhere earlier, maybe username would help to know them!""")
+ await m.reply_text(
+ text="""Failed to get user
+ Peer ID invalid, I haven't seen this user anywhere earlier, maybe username would help to know them!"""
+ )
return
await m.reply_text(
@@ -166,13 +164,9 @@ async def id_info(c: Gojo, m: Message):
parse_mode="HTML",
)
elif chat_type == "private":
- await m.reply_text(
- text=f"Your ID is {m.chat.id}
."
- )
+ await m.reply_text(text=f"Your ID is {m.chat.id}
.")
else:
- await m.reply_text(
- text=f"This Group's ID is {m.chat.id}
"
- )
+ await m.reply_text(text=f"This Group's ID is {m.chat.id}
")
return
@@ -218,11 +212,13 @@ async def github(_, message):
LOGGER.error(e)
LOGGER.error(format_exc())
-#paste here
+
+# paste here
session = ClientSession()
pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
BASE = "https://batbin.me/"
+
async def post(url: str, *args, **kwargs):
async with session.post(url, *args, **kwargs) as resp:
try:
@@ -231,6 +227,7 @@ async def post(url: str, *args, **kwargs):
data = await resp.text()
return data
+
async def paste(content: str):
resp = await post(f"{BASE}api/v2/paste", data=content)
if not resp["success"]:
@@ -242,7 +239,7 @@ async def paste(content: str):
async def paste_func(_, message: Message):
if not message.reply_to_message:
return await message.reply_text("Reply To A Message With `/paste`")
-
+
r = message.reply_to_message
if not r.text and not r.document:
@@ -285,13 +282,18 @@ async def paste_func(_, message: Message):
)
await m.delete()
except Exception:
- await m.edit("Here is the link of the document....", reply_markup=InlineKeyboardMarkup(kb))
+ await m.edit(
+ "Here is the link of the document....",
+ reply_markup=InlineKeyboardMarkup(kb),
+ )
@Gojo.on_message(command("tr"))
async def tr(_, message):
trl = Translator()
- if message.reply_to_message and (message.reply_to_message.text or message.reply_to_message.caption):
+ if message.reply_to_message and (
+ message.reply_to_message.text or message.reply_to_message.caption
+ ):
if len(message.text.split()) == 1:
target_lang = "en"
else:
@@ -319,8 +321,6 @@ async def tr(_, message):
)
-
-
__PLUGIN__ = "utils"
_DISABLE_CMDS_ = [
"paste",
diff --git a/Powers/plugins/warns.py b/Powers/plugins/warns.py
index 271e9512b5cf4838d498e99a8b7b89cfd63b7b01..0f371ad83efc3f573bda0ab1c3f76078378628ac 100644
--- a/Powers/plugins/warns.py
+++ b/Powers/plugins/warns.py
@@ -1,25 +1,19 @@
from time import time
-
from pyrogram import filters
+from Powers.vars import Config
+from Powers.bot_class import Gojo
from pyrogram.errors import RPCError
-from pyrogram.types import (
- CallbackQuery,
- ChatPermissions,
- InlineKeyboardButton,
- InlineKeyboardMarkup,
- Message,
-)
-
from Powers import LOGGER, SUPPORT_STAFF
-from Powers.bot_class import Gojo
from Powers.database.rules_db import Rules
from Powers.database.users_db import Users
+from Powers.utils.parser import mention_html
+from Powers.utils.extract_user import extract_user
from Powers.database.warns_db import Warns, WarnSettings
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
-from Powers.utils.custom_filters import admin_filter, command, restrict_filter
-from Powers.utils.extract_user import extract_user
-from Powers.utils.parser import mention_html
-from Powers.vars import Config
+from Powers.utils.custom_filters import command, admin_filter, restrict_filter
+from pyrogram.types import (
+ Message, CallbackQuery, ChatPermissions, InlineKeyboardButton,
+ InlineKeyboardMarkup)
@Gojo.on_message(
@@ -52,7 +46,9 @@ async def warn(c: Gojo, m: Message):
return
if user_id in SUPPORT_STAFF:
- await m.reply_text(text="This user is in my support staff, cannot restrict them.")
+ await m.reply_text(
+ text="This user is in my support staff, cannot restrict them."
+ )
LOGGER.info(
f"{m.from_user.id} trying to warn {user_id} (SUPPORT_STAFF) in {m.chat.id}",
)
@@ -384,4 +380,4 @@ Admin commands:
- /warnlimit ``: Set the number of warnings before users are punished.
Examples:
-`/warn @user`: this warns a user in the chat."""
\ No newline at end of file
+`/warn @user`: this warns a user in the chat."""
diff --git a/Powers/plugins/watchers.py b/Powers/plugins/watchers.py
index 4dd6e1e1f9bc5e29949075e4dcb99f63b4006275..96051de35d35b3e72670cc10306ce3fb2429338f 100644
--- a/Powers/plugins/watchers.py
+++ b/Powers/plugins/watchers.py
@@ -1,22 +1,21 @@
-from re import escape as re_escape
from time import time
-from traceback import format_exc
-
from pyrogram import filters
-from pyrogram.errors import ChatAdminRequired, RPCError, UserAdminInvalid
-from pyrogram.types import ChatPermissions, Message
-
-from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_STAFF
+from traceback import format_exc
from Powers.bot_class import Gojo
-from Powers.database.antispam_db import ANTISPAM_BANNED, GBan
+from re import escape as re_escape
+from Powers.database.pins_db import Pins
+from Powers.utils.parser import mention_html
from Powers.database.approve_db import Approve
from Powers.database.blacklist_db import Blacklist
-from Powers.database.group_blacklist import BLACKLIST_CHATS
-from Powers.database.pins_db import Pins
+from Powers.utils.regex_utils import regex_searcher
+from pyrogram.types import Message, ChatPermissions
+from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_STAFF
from Powers.database.warns_db import Warns, WarnSettings
+from Powers.database.group_blacklist import BLACKLIST_CHATS
+from Powers.database.antispam_db import ANTISPAM_BANNED, GBan
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
-from Powers.utils.parser import mention_html
-from Powers.utils.regex_utils import regex_searcher
+from pyrogram.errors import RPCError, UserAdminInvalid, ChatAdminRequired
+
# Initialise
gban_db = GBan()
@@ -184,7 +183,7 @@ async def gban_watcher(c: Gojo, m: Message):
try:
await m.chat.ban_member(m.from_user.id)
await m.delete(m.message_id) # Delete users message!
- user_gbanned=(await mention_html(m.from_user.first_name, m.from_user.id))
+ user_gbanned = await mention_html(m.from_user.first_name, m.from_user.id)
await m.reply_text(
text=f"""This user ({user_gbanned}) has been banned globally!
@@ -203,7 +202,7 @@ async def gban_watcher(c: Gojo, m: Message):
MESSAGE_DUMP,
text=f"""Gban Watcher Error!
Chat: {m.chat.id}
- Error: {ef}
"""
+ Error: {ef}
""",
)
return
diff --git a/Powers/utils/admin_check.py b/Powers/utils/admin_check.py
index ebda06cf59c77e2504f8de7d3fa6c7e8ee949604..68230b780f2b8378e9b06d2a5e38dd22372df255 100644
--- a/Powers/utils/admin_check.py
+++ b/Powers/utils/admin_check.py
@@ -1,8 +1,7 @@
from traceback import format_exc
+from pyrogram.types import Message, CallbackQuery
+from Powers import LOGGER, OWNER_ID, DEV_USERS, SUDO_USERS
-from pyrogram.types import CallbackQuery, Message
-
-from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS
SUDO_LEVEL = SUDO_USERS + DEV_USERS + [int(OWNER_ID)]
DEV_LEVEL = DEV_USERS + [int(OWNER_ID)]
diff --git a/Powers/utils/caching.py b/Powers/utils/caching.py
index 850e36a69c093c185230f57cebad68330823cd35..ec5eef031a6a65900d65b9e76101d30704fa238b 100644
--- a/Powers/utils/caching.py
+++ b/Powers/utils/caching.py
@@ -1,13 +1,12 @@
-from threading import RLock
-from time import perf_counter, time
from typing import List
-
+from Powers import LOGGER
+from pyrogram import enums
+from threading import RLock
from cachetools import TTLCache
+from time import time, perf_counter
from pyrogram.types import CallbackQuery
-from pyrogram import enums
from pyrogram.types.messages_and_media.message import Message
-from Powers import LOGGER
THREAD_LOCK = RLock()
@@ -34,16 +33,16 @@ async def admin_cache_reload(m: Message or CallbackQuery, status=None) -> List[i
except KeyError:
# Because it might be first time when admn_list is being reloaded
pass
-
-
+
admin_list = [
(
z.user.id,
(("@" + z.user.username) if z.user.username else z.user.first_name),
z.is_anonymous,
)
-
- async for z in m.chat.get_members(filter=enums.ChatMembersFilter.ADMINISTRATORS)
+ async for z in m.chat.get_members(
+ filter=enums.ChatMembersFilter.ADMINISTRATORS
+ )
if not z.user.is_deleted
]
ADMIN_CACHE[m.chat.id] = admin_list
diff --git a/Powers/utils/chat_type.py b/Powers/utils/chat_type.py
index b4af317885e776bdf861a5c0665a80d8f59de12e..e1f9428db9ae1eaf930b9970523c11a151a1a70d 100644
--- a/Powers/utils/chat_type.py
+++ b/Powers/utils/chat_type.py
@@ -1,40 +1,37 @@
from Powers.bot_class import Gojo
-
-from pyrogram.enums import ChatType
from pyrogram.types import Message
-
+from pyrogram.enums import ChatType
async def chattype(m: Message):
- # To get chat type with message
+ # To get chat type with message
if m.chat.type == ChatType.CHANNEL:
ct = "channel"
-
+
if m.chat.type == ChatType.PRIVATE:
ct = "private"
if m.chat.type == ChatType.GROUP:
- ct="group"
+ ct = "group"
if m.chat.type == ChatType.SUPERGROUP:
ct = "supergroup"
-
-
return ct
+
async def c_type(c: Gojo, chat_id):
# To get chat type with chat id
-
+
c = await Gojo.get_chat(chat_id)
-
+
if c.type == ChatType.CHANNEL:
ct = "channel"
-
+
if c.type == ChatType.GROUP:
ct = "group"
-
+
if c.type == ChatType.SUPERGROUP:
ct = "supergroup"
diff --git a/Powers/utils/custom_filters.py b/Powers/utils/custom_filters.py
index dd62566874c470bf58342a5751aceea897803421..77af838372a934988ed7804796a03df3af98f612 100644
--- a/Powers/utils/custom_filters.py
+++ b/Powers/utils/custom_filters.py
@@ -1,19 +1,16 @@
-from re import compile as compile_re
-from re import escape
from shlex import split
+from pyrogram import enums
+from Powers.vars import Config
from typing import List, Union
-
-from pyrogram.errors import RPCError, UserNotParticipant
from pyrogram.filters import create
-from pyrogram.types import CallbackQuery, Message
-from pyrogram import enums
-
-
-from Powers import DEV_USERS, OWNER_ID, SUDO_USERS
+from Powers.utils.chat_type import chattype
+from re import escape, compile as compile_re
from Powers.database.disable_db import Disabling
+from pyrogram.types import Message, CallbackQuery
+from Powers import OWNER_ID, DEV_USERS, SUDO_USERS
+from pyrogram.errors import RPCError, UserNotParticipant
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
-from Powers.utils.chat_type import chattype
-from Powers.vars import Config
+
SUDO_LEVEL = set(SUDO_USERS + DEV_USERS + [int(OWNER_ID)])
DEV_LEVEL = set(DEV_USERS + [int(OWNER_ID)])
@@ -32,7 +29,7 @@ def command(
date = m.edit_date
if date:
- return # reaction
+ return # reaction
chattype = bool(m.chat and m.chat.type in {enums.ChatType.CHANNEL})
if chattype:
@@ -101,7 +98,7 @@ def command(
return True
return False
- commands = commands if type(commands) is list else [commands]
+ commands = commands if isinstance(commands, list) else [commands]
commands = {c if case_sensitive else c.lower() for c in commands}
return create(
diff --git a/Powers/utils/extract_user.py b/Powers/utils/extract_user.py
index 909355dec7f96530af12f10d970b5d82a1b558a1..8eb3e67d184d21c04c30419ff2a9303f243a89ac 100644
--- a/Powers/utils/extract_user.py
+++ b/Powers/utils/extract_user.py
@@ -1,11 +1,9 @@
-from traceback import format_exc
from typing import Tuple
-
-from pyrogram.types.messages_and_media.message import Message
-
from Powers import LOGGER
+from traceback import format_exc
from Powers.bot_class import Gojo
from Powers.database.users_db import Users
+from pyrogram.types.messages_and_media.message import Message
async def extract_user(c: Gojo, m: Message) -> Tuple[int, str, str]:
diff --git a/Powers/utils/extras.py b/Powers/utils/extras.py
index 0598d584c150f1f46a4e9c5783b24c11bcea9a8f..be249ef063015eabf0991470b5f7206a167adc42 100644
--- a/Powers/utils/extras.py
+++ b/Powers/utils/extras.py
@@ -1,6 +1,5 @@
RUN_STRINGS = (
- "Now you see me, now you don't."
- "ε=ε=ε=ε=┌(; ̄▽ ̄)┘",
+ "Now you see me, now you don't." "ε=ε=ε=ε=┌(; ̄▽ ̄)┘",
"Get back here!",
"REEEEEEEEEEEEEEEEEE!!!!!!!",
"Look out for the wall!",
@@ -94,7 +93,7 @@ SLAP_TEMPLATES = (
"( ・_・)ノΞ●~* {user2}\nDieeeee!!.",
"( ・∀・)r鹵~<≪巛;゚Д゚)ノ\n*Bug sprays {user2}*.",
"( ゚Д゚)ノ占~<巛巛巛.\n-{user2} You pest!",
- "( う-´)づ︻╦̵̵̿╤── \(˚☐˚”)/ {user2}.",
+ "( う-´)づ︻╦̵̵̿╤── \\(˚☐˚”)/ {user2}.",
"{user1} {hits} {user2} with a {item}.",
"{user1} {hits} {user2} in the face with a {item}.",
"{user1} {hits} {user2} around a bit with a {item}.",
@@ -131,12 +130,12 @@ SLAP_TEMPLATES = (
"You know what’s worse than Dad jokes? {user2}!",
"{user1} took all of {user2}'s cookies.",
"{user2} wa mou.......Shindeiru! - {user1}.",
- "{user2} lost his race piece!", #No game no life reference
- "Shut up {user2}, you are just {user2}.", #No game no life reference
- "{user1} hits {user2} with Aka si anse!", #No game no life reference
- "@NeoTheKitty scratches {user2}", #Pixels pet cat - @NeoTheKitty
- "Majin buu ate {user2}", #Dbz
- "Goblin slayer slays {user2}", #Goblin Slayer
+ "{user2} lost his race piece!", # No game no life reference
+ "Shut up {user2}, you are just {user2}.", # No game no life reference
+ "{user1} hits {user2} with Aka si anse!", # No game no life reference
+ "@NeoTheKitty scratches {user2}", # Pixels pet cat - @NeoTheKitty
+ "Majin buu ate {user2}", # Dbz
+ "Goblin slayer slays {user2}", # Goblin Slayer
"{user2} was shot by {user1}.",
"{user2} walked into a cactus while trying to escape {user1}.",
"{user2} drowned whilst trying to escape {user1}.",
@@ -515,7 +514,6 @@ TOSS = (
)
-
DECIDE = ("Yes.", "No.", "Maybe.", "Who the hell cares?", "No one give a damn about it")
INSULT_STRINGS = [
@@ -555,73 +553,81 @@ INSULT_STRINGS = [
]
+BAN_GIFS = [
+ "https://tenor.com/bMiwt.gif",
+ "https://tenor.com/bqhVe.gif",
+ "https://tenor.com/bsHe5.gif",
+ "https://j.gifs.com/y5Pr8z.gif",
+ "https://tenor.com/bfvQv.gif",
+ "https://j.gifs.com/lO0lv6.gif",
+ "https://tenor.com/bGMhb.gif",
+ "https://tenor.com/bjZai.gif",
+ "https://media.giphy.com/media/fe4dDMD2cAU5RfEaCU/giphy.gif",
+ "https://tenor.com/bndta.gif",
+ "https://tenor.com/bkyIr.gif",
+ "https://media.giphy.com/media/UBqgQxKnUJqb8oZ2zc/giphy.gif",
+ "https://media.giphy.com/media/tanIENriCOil3ndF3V/giphy.gif",
+ "https://media.giphy.com/media/fwX4RUzdkdx9XUGow4/giphy.gif",
+ "https://media.giphy.com/media/XVLfZCU6jDvMYqF1xS/giphy.gif",
+ "https://media.giphy.com/media/BSAZJvFOOR0VqREKMg/giphy.gif",
+ "https://media.giphy.com/media/CI4aCJUjJDJEj3Jgo4/giphy-downsized-large.gif",
+]
-BAN_GIFS = ["https://tenor.com/bMiwt.gif",
- "https://tenor.com/bqhVe.gif",
- "https://tenor.com/bsHe5.gif",
- "https://j.gifs.com/y5Pr8z.gif",
- "https://tenor.com/bfvQv.gif",
- "https://j.gifs.com/lO0lv6.gif",
- "https://tenor.com/bGMhb.gif",
- "https://tenor.com/bjZai.gif",
- "https://media.giphy.com/media/fe4dDMD2cAU5RfEaCU/giphy.gif",
- "https://tenor.com/bndta.gif",
- "https://tenor.com/bkyIr.gif",
- "https://media.giphy.com/media/UBqgQxKnUJqb8oZ2zc/giphy.gif",
- "https://media.giphy.com/media/tanIENriCOil3ndF3V/giphy.gif",
- "https://media.giphy.com/media/fwX4RUzdkdx9XUGow4/giphy.gif",
- "https://media.giphy.com/media/XVLfZCU6jDvMYqF1xS/giphy.gif",
- "https://media.giphy.com/media/BSAZJvFOOR0VqREKMg/giphy.gif",
- "https://media.giphy.com/media/CI4aCJUjJDJEj3Jgo4/giphy-downsized-large.gif",]
+KICK_GIFS = [
+ "https://tenor.com/bizBJ.gif",
+ "https://tenor.com/bjPvj.gif",
+ "https://tenor.com/bJMx3.gif",
+ "https://tenor.com/bJCGL.gif",
+ "https://tenor.com/bsIMJ.gif",
+ "https://tenor.com/buURG.gif",
+ "https://tenor.com/bNOj9.gif",
+ "https://tenor.com/NfK8.gif",
+ "https://tenor.com/ymZn.gif",
+ "https://tenor.com/77Lu.gif",
+ "https://tenor.com/bPD4I.gif",
+ "https://tenor.com/bOGXo.gif",
+ "https://tenor.com/bDLqs.gif",
+ "https://media.giphy.com/media/u2LJ0n4lx6jF6/giphy.gif",
+ "https://media.giphy.com/media/BSAZJvFOOR0VqREKMg/giphy.gif",
+ "https://media.giphy.com/media/eDR7j2vjCFOUMJ9rT2/giphy.gif",
+ "https://media.giphy.com/media/ERNKP5G7ihZNW6VW4Q/giphy.gif",
+ "https://media.giphy.com/media/1r6xks2F0iHfbNvt4p/giphy.gif",
+ "https://media.giphy.com/media/M7j1rkxm0X5z30Hyrs/giphy.gif",
+ "https://media.giphy.com/media/rad9oJzU4hVafD8ZnT/giphy.gif",
+ "https://media.giphy.com/media/TcliN5WDKBbnUQ15H3/giphy.gif",
+ "https://media.giphy.com/media/y9pfUqY3uaT1MPXxYM/giphy.gif",
+]
-KICK_GIFS = ["https://tenor.com/bizBJ.gif",
- "https://tenor.com/bjPvj.gif",
- "https://tenor.com/bJMx3.gif",
- "https://tenor.com/bJCGL.gif",
- "https://tenor.com/bsIMJ.gif",
- "https://tenor.com/buURG.gif",
- "https://tenor.com/bNOj9.gif",
- "https://tenor.com/NfK8.gif",
- "https://tenor.com/ymZn.gif",
- "https://tenor.com/77Lu.gif",
- "https://tenor.com/bPD4I.gif",
- "https://tenor.com/bOGXo.gif",
- "https://tenor.com/bDLqs.gif",
- "https://media.giphy.com/media/u2LJ0n4lx6jF6/giphy.gif",
- "https://media.giphy.com/media/BSAZJvFOOR0VqREKMg/giphy.gif",
- "https://media.giphy.com/media/eDR7j2vjCFOUMJ9rT2/giphy.gif",
- "https://media.giphy.com/media/ERNKP5G7ihZNW6VW4Q/giphy.gif",
- "https://media.giphy.com/media/1r6xks2F0iHfbNvt4p/giphy.gif",
- "https://media.giphy.com/media/M7j1rkxm0X5z30Hyrs/giphy.gif",
- "https://media.giphy.com/media/rad9oJzU4hVafD8ZnT/giphy.gif",
- "https://media.giphy.com/media/TcliN5WDKBbnUQ15H3/giphy.gif",
- "https://media.giphy.com/media/y9pfUqY3uaT1MPXxYM/giphy.gif",]
-
-MUTE_GIFS = ["https://media.giphy.com/media/MpCxz9VLh6t8ceRb0r/giphy.gif",
- "https://media.giphy.com/media/HWl1atKEPAWcw/giphy.gif",
- "https://media.giphy.com/media/1xkynOSsb8eFpbEood/giphy.gif",
- "https://media.giphy.com/media/LmUAM5ImMNZd0nnkvn/giphy.gif",
- "https://media.giphy.com/media/JNlXHSSioDe7YGTC7D/giphy.gif",
- "https://media.giphy.com/media/t0iSe43jX8JH0Hb95a/giphy.gif",
- "https://media.giphy.com/media/P4CXV70NTC0umRI61S/giphy.gif",
- "https://media.giphy.com/media/Z0WPxDF7zpIHVPrYUN/giphy.gif",
- "https://media.giphy.com/media/gJS1pGTbXlSCWUe2pg/giphy.gif",
- "https://media.giphy.com/media/SIoetMN7j96O5perEV/giphy.gif",
- "https://media.giphy.com/media/PBZrH2uy9E5rPruuCX/giphy.gif",
- "https://media.giphy.com/media/Cew2qzlug9t3ACYrD5/giphy.gif",
- "https://media.giphy.com/media/PtIm7eUGKYIZbknqsO/giphy.gif",]
+MUTE_GIFS = [
+ "https://media.giphy.com/media/MpCxz9VLh6t8ceRb0r/giphy.gif",
+ "https://media.giphy.com/media/HWl1atKEPAWcw/giphy.gif",
+ "https://media.giphy.com/media/1xkynOSsb8eFpbEood/giphy.gif",
+ "https://media.giphy.com/media/LmUAM5ImMNZd0nnkvn/giphy.gif",
+ "https://media.giphy.com/media/JNlXHSSioDe7YGTC7D/giphy.gif",
+ "https://media.giphy.com/media/t0iSe43jX8JH0Hb95a/giphy.gif",
+ "https://media.giphy.com/media/P4CXV70NTC0umRI61S/giphy.gif",
+ "https://media.giphy.com/media/Z0WPxDF7zpIHVPrYUN/giphy.gif",
+ "https://media.giphy.com/media/gJS1pGTbXlSCWUe2pg/giphy.gif",
+ "https://media.giphy.com/media/SIoetMN7j96O5perEV/giphy.gif",
+ "https://media.giphy.com/media/PBZrH2uy9E5rPruuCX/giphy.gif",
+ "https://media.giphy.com/media/Cew2qzlug9t3ACYrD5/giphy.gif",
+ "https://media.giphy.com/media/PtIm7eUGKYIZbknqsO/giphy.gif",
+]
-NOWYES = ["""
+NOWYES = [
+ """
YES YES YESYES
YESYES YES YES YES
YES YES YES YES YES
YES YESYES YES YES
YES YESYE YES YES
YES YES YESYES
- """]
+ """
+]
-YESWNO =["""
+YESWNO = [
+ """
NO NO NONONO NONO
NO NO NO NO NO
NONO NO NO
@@ -629,9 +635,10 @@ NO NO NONONO NONO
NO NO NO NO
NO NO NO NO
NO NONONO NONO
-"""]
+"""
+]
-StartPic =[
+StartPic = [
"https://te.legra.ph/file/4bf3b88115068d41efadd.jpg",
"https://te.legra.ph/file/633bd27c1607fe98920b6.jpg",
"https://te.legra.ph/file/a740afb182b761db668ba.jpg",
diff --git a/Powers/utils/http_helper.py b/Powers/utils/http_helper.py
index 322bbace1ee66c46666e6c0d1d5412465231afe7..2fb5d88e69bc0c20f1b341a6e5b388636f8d3eb6 100644
--- a/Powers/utils/http_helper.py
+++ b/Powers/utils/http_helper.py
@@ -1,6 +1,7 @@
from asyncio import gather
from Powers.bot_class import aiohttpsession as session
+
async def get(url: str, *args, **kwargs):
async with session.get(url, *args, **kwargs) as resp:
try:
diff --git a/Powers/utils/kbhelpers.py b/Powers/utils/kbhelpers.py
index a926c9c81977c844e4219480a0c668f8f2dfe5c7..04794fe74f0f5b782afe2f4a50e59e1be71421a7 100644
--- a/Powers/utils/kbhelpers.py
+++ b/Powers/utils/kbhelpers.py
@@ -1,5 +1,6 @@
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
+
def ikb(rows=None):
if rows is None:
rows = []
@@ -7,11 +8,11 @@ def ikb(rows=None):
for row in rows:
line = []
for button in row:
- button = btn(*button)
+ button = btn(*button)
line.append(button)
lines.append(line)
return InlineKeyboardMarkup(inline_keyboard=lines)
def btn(text, value, type="callback_data"):
- return InlineKeyboardButton(text, **{type: value})
\ No newline at end of file
+ return InlineKeyboardButton(text, **{type: value})
diff --git a/Powers/utils/msg_types.py b/Powers/utils/msg_types.py
index 53af4b18c5f2dc1d03ece2672d9c1c6c4a1e670b..6c4b1382eb2de08c3f8bcef735ceeed708a195b9 100644
--- a/Powers/utils/msg_types.py
+++ b/Powers/utils/msg_types.py
@@ -1,5 +1,4 @@
from enum import IntEnum, unique
-
from pyrogram.types import Message
diff --git a/Powers/utils/parser.py b/Powers/utils/parser.py
index 9b3556825a13873e8300a51568d04bc78ef19c05..1ed67756078f9a2441605d008d369faa04bfc614 100644
--- a/Powers/utils/parser.py
+++ b/Powers/utils/parser.py
@@ -1,6 +1,5 @@
from html import escape
-from re import compile as compilere
-from re import sub
+from re import sub, compile as compilere
async def cleanhtml(raw_html: str) -> str:
diff --git a/Powers/utils/regex_utils.py b/Powers/utils/regex_utils.py
index bf843cce7802e1d2d7a88bfb053fce7b7885c3d7..5cade1fede354ad1ed702d1d30e38e2e1bc8ff37 100644
--- a/Powers/utils/regex_utils.py
+++ b/Powers/utils/regex_utils.py
@@ -1,8 +1,6 @@
-from traceback import format_exc
-
from regex import search
-
from Powers import LOGGER
+from traceback import format_exc
async def regex_searcher(regex_string: str, string: str) -> str:
diff --git a/Powers/utils/start_utils.py b/Powers/utils/start_utils.py
index 4840bf0bf09534d3261d1fdfe64a2326acd628e2..0577a25c7c81419f376fdc399ad6ef8b1194be6e 100644
--- a/Powers/utils/start_utils.py
+++ b/Powers/utils/start_utils.py
@@ -1,24 +1,20 @@
from html import escape
from secrets import choice
+from Powers.vars import Config
from traceback import format_exc
-
-from pyrogram.errors import RPCError
-from pyrogram.types import CallbackQuery, Message
-
-from Powers import HELP_COMMANDS, LOGGER, SUPPORT_GROUP
from Powers.bot_class import Gojo
+from pyrogram.errors import RPCError
+from Powers.utils.kbhelpers import ikb
+from Powers.utils.msg_types import Types
from Powers.database.chats_db import Chats
from Powers.database.notes_db import Notes
from Powers.database.rules_db import Rules
from Powers.utils.cmd_senders import send_cmd
-from Powers.utils.kbhelpers import ikb
-from Powers.utils.msg_types import Types
+from pyrogram.types import Message, CallbackQuery
+from Powers import LOGGER, HELP_COMMANDS, SUPPORT_GROUP
from Powers.utils.string import (
- build_keyboard,
- escape_mentions_using_curly_brackets,
- parse_button,
-)
-from Powers.vars import Config
+ parse_button, build_keyboard, escape_mentions_using_curly_brackets)
+
# Initialize
notes_db = Notes()
@@ -39,7 +35,7 @@ async def gen_start_kb(q: Message or CallbackQuery):
"""Generate keyboard with start menu options."""
return ikb(
[
- [
+ [
(
"➕ Add me to a chat!",
f"https://t.me/{Config.BOT_USERNAME}?startgroup=new",
@@ -53,7 +49,6 @@ async def gen_start_kb(q: Message or CallbackQuery):
],
[("📚 Commands & Help", "commands")],
[
-
(
"🗃️ Source Code",
"https://github.com/iamgojoof6eyes/Gojo_Satarou",
@@ -243,11 +238,7 @@ async def get_help_msg(m: Message or CallbackQuery, help_option: str):
for i in HELP_COMMANDS
if help_option in HELP_COMMANDS[i]["alt_cmds"]
) + [[("« " + "Back", "commands")]]
- help_msg = (
- f"**{(help_option_value)}:**"
-
-
- )
+ help_msg = f"**{(help_option_value)}:**"
LOGGER.info(
f"{m.from_user.id} fetched help for {help_option} in {m.chat.id}",
)
diff --git a/Powers/utils/string.py b/Powers/utils/string.py
index 5ffc150b85f82d9357dc37f783b8442c2796407c..810fdb6c4d20285022e8383dab96494414762cee 100644
--- a/Powers/utils/string.py
+++ b/Powers/utils/string.py
@@ -1,12 +1,11 @@
-from html import escape
-from re import compile as compile_re
from time import time
+from html import escape
from typing import List
-
-from pyrogram.types import InlineKeyboardButton, Message
-
-from Powers.utils.parser import escape_markdown
+from re import compile as compile_re
from Powers.utils.chat_type import chattype
+from Powers.utils.parser import escape_markdown
+from pyrogram.types import Message, InlineKeyboardButton
+
BTN_URL_REGEX = compile_re(r"(\[([^\[]+?)\]\(buttonurl:(?:/{0,2})(.+?)(:same)?\))")
diff --git a/Powers/vars.py b/Powers/vars.py
index b38edc7ea28f2c4e35a8b381a57bd37d9cab9e56..63ce9ae2bdfbf53b3a0316feb54cd7100881eb81 100644
--- a/Powers/vars.py
+++ b/Powers/vars.py
@@ -1,14 +1,12 @@
from os import getcwd
-
-
from prettyconf import Configuration
from prettyconf.loaders import EnvFile, Environment
+
env_file = f"{getcwd()}/.env"
config = Configuration(loaders=[Environment(), EnvFile(filename=env_file)])
-
class Config:
"""Config class for variables."""
@@ -18,9 +16,27 @@ class Config:
API_HASH = config("API_HASH", default=None)
OWNER_ID = int(config("OWNER_ID", default=1344569458))
MESSAGE_DUMP = int(config("MESSAGE_DUMP", default=-100))
- DEV_USERS = [int(i) for i in config("DEV_USERS", default="1432756163 1344569458 1355478165 1789859817 1777340882").split(" ")]
- SUDO_USERS = [int(i) for i in config("SUDO_USERS", default="1432756163 1344569458 1355478165 1789859817 1777340882").split(" ")]
- WHITELIST_USERS = [int(i) for i in config("WHITELIST_USERS", default="1432756163 1344569458 1355478165 1789859817 1777340882").split(" ")]
+ DEV_USERS = [
+ int(i)
+ for i in config(
+ "DEV_USERS",
+ default="1432756163 1344569458 1355478165 1789859817 1777340882",
+ ).split(" ")
+ ]
+ SUDO_USERS = [
+ int(i)
+ for i in config(
+ "SUDO_USERS",
+ default="1432756163 1344569458 1355478165 1789859817 1777340882",
+ ).split(" ")
+ ]
+ WHITELIST_USERS = [
+ int(i)
+ for i in config(
+ "WHITELIST_USERS",
+ default="1432756163 1344569458 1355478165 1789859817 1777340882",
+ ).split(" ")
+ ]
DB_URI = config("DB_URI", default="")
DB_NAME = config("DB_NAME", default="gojo_satarou")
NO_LOAD = config("NO_LOAD", default="").split()
@@ -55,4 +71,3 @@ class Development:
SUPPORT_CHANNEL = "SUPPORT_CHANNEL"
VERSION = "VERSION"
WORKERS = 8
-