Spaces:
Paused
Paused
AshokShau
commited on
Commit
·
4056428
1
Parent(s):
3c9449b
WIP
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Powers/__init__.py +5 -5
- Powers/bot_class.py +3 -3
- Powers/database/afk_db.py +2 -3
- Powers/database/approve_db.py +1 -0
- Powers/database/autojoin_db.py +0 -2
- Powers/database/blacklist_db.py +1 -1
- Powers/database/captcha_db.py +3 -4
- Powers/database/chats_db.py +3 -3
- Powers/database/disable_db.py +1 -1
- Powers/database/filters_db.py +6 -6
- Powers/database/flood_db.py +8 -11
- Powers/database/greetings_db.py +0 -1
- Powers/database/locks_db.py +26 -28
- Powers/database/notes_db.py +9 -9
- Powers/database/support_db.py +0 -1
- Powers/database/warns_db.py +1 -1
- Powers/plugins/__init__.py +2 -2
- Powers/plugins/admin.py +18 -19
- Powers/plugins/afk.py +22 -22
- Powers/plugins/antispam.py +4 -4
- Powers/plugins/approve.py +0 -2
- Powers/plugins/auto_join.py +25 -21
- Powers/plugins/bans.py +19 -18
- Powers/plugins/birthday.py +38 -31
- Powers/plugins/blacklist.py +8 -9
- Powers/plugins/captcha.py +9 -9
- Powers/plugins/chat_blacklist.py +3 -5
- Powers/plugins/dev.py +71 -59
- Powers/plugins/disable.py +2 -3
- Powers/plugins/filters.py +5 -7
- Powers/plugins/flood.py +54 -42
- Powers/plugins/formatting.py +11 -10
- Powers/plugins/greetings.py +28 -26
- Powers/plugins/info.py +26 -26
- Powers/plugins/locks.py +14 -13
- Powers/plugins/muting.py +9 -13
- Powers/plugins/notes.py +10 -15
- Powers/plugins/pin.py +3 -4
- Powers/plugins/purge.py +2 -6
- Powers/plugins/report.py +2 -4
- Powers/plugins/rules.py +0 -1
- Powers/plugins/scheduled_jobs.py +12 -9
- Powers/plugins/search.py +6 -3
- Powers/plugins/start.py +7 -7
- Powers/plugins/stickers.py +76 -50
- Powers/plugins/utils.py +24 -21
- Powers/plugins/warns.py +5 -9
- Powers/plugins/watchers.py +6 -9
- Powers/plugins/web_con.py +39 -39
- Powers/supports.py +3 -1
Powers/__init__.py
CHANGED
|
@@ -48,6 +48,7 @@ if version_info[0] < 3 or version_info[1] < 7:
|
|
| 48 |
# the secret configuration specific things
|
| 49 |
try:
|
| 50 |
from Powers.vars import is_env
|
|
|
|
| 51 |
if is_env or environ.get("ENV"):
|
| 52 |
from Powers.vars import Config
|
| 53 |
else:
|
|
@@ -135,8 +136,7 @@ PREFIX_HANDLER = Config.PREFIX_HANDLER
|
|
| 135 |
HELP_COMMANDS = {} # For help menu
|
| 136 |
UPTIME = time() # Check bot uptime
|
| 137 |
|
| 138 |
-
|
| 139 |
-
#Make dir
|
| 140 |
youtube_dir = "./Youtube/"
|
| 141 |
if path.isdir(youtube_dir):
|
| 142 |
shutil.rmtree(youtube_dir)
|
|
@@ -195,7 +195,7 @@ async def load_cmds(all_plugins):
|
|
| 195 |
LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
|
| 196 |
|
| 197 |
return (
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
)
|
|
|
|
| 48 |
# the secret configuration specific things
|
| 49 |
try:
|
| 50 |
from Powers.vars import is_env
|
| 51 |
+
|
| 52 |
if is_env or environ.get("ENV"):
|
| 53 |
from Powers.vars import Config
|
| 54 |
else:
|
|
|
|
| 136 |
HELP_COMMANDS = {} # For help menu
|
| 137 |
UPTIME = time() # Check bot uptime
|
| 138 |
|
| 139 |
+
# Make dir
|
|
|
|
| 140 |
youtube_dir = "./Youtube/"
|
| 141 |
if path.isdir(youtube_dir):
|
| 142 |
shutil.rmtree(youtube_dir)
|
|
|
|
| 195 |
LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
|
| 196 |
|
| 197 |
return (
|
| 198 |
+
", ".join((i.split(".")[1]).capitalize()
|
| 199 |
+
for i in list(HELP_COMMANDS.keys()))
|
| 200 |
+
+ "\n"
|
| 201 |
)
|
Powers/bot_class.py
CHANGED
|
@@ -7,8 +7,8 @@ from pyrogram import Client, __version__
|
|
| 7 |
from pyrogram.raw.all import layer
|
| 8 |
from pyrogram.types import BotCommand
|
| 9 |
|
| 10 |
-
from Powers import (API_HASH, API_ID,
|
| 11 |
-
LOGFILE, LOGGER, MESSAGE_DUMP, NO_LOAD,
|
| 12 |
WORKERS, load_cmds, scheduler)
|
| 13 |
from Powers.database import MongoDB
|
| 14 |
from Powers.plugins import all_plugins
|
|
@@ -72,7 +72,7 @@ class Gojo(Client):
|
|
| 72 |
LOGGER.info(f"Plugins Loaded: {cmd_list}")
|
| 73 |
if BDB_URI:
|
| 74 |
scheduler.add_job(send_wishish, 'cron', [
|
| 75 |
-
|
| 76 |
scheduler.start()
|
| 77 |
# Send a message to MESSAGE_DUMP telling that the
|
| 78 |
# bot has started and has loaded all plugins!
|
|
|
|
| 7 |
from pyrogram.raw.all import layer
|
| 8 |
from pyrogram.types import BotCommand
|
| 9 |
|
| 10 |
+
from Powers import (API_HASH, API_ID, BOT_TOKEN, LOG_DATETIME,
|
| 11 |
+
LOGFILE, LOGGER, MESSAGE_DUMP, NO_LOAD, UPTIME,
|
| 12 |
WORKERS, load_cmds, scheduler)
|
| 13 |
from Powers.database import MongoDB
|
| 14 |
from Powers.plugins import all_plugins
|
|
|
|
| 72 |
LOGGER.info(f"Plugins Loaded: {cmd_list}")
|
| 73 |
if BDB_URI:
|
| 74 |
scheduler.add_job(send_wishish, 'cron', [
|
| 75 |
+
self], hour=0, minute=0, second=0)
|
| 76 |
scheduler.start()
|
| 77 |
# Send a message to MESSAGE_DUMP telling that the
|
| 78 |
# bot has started and has loaded all plugins!
|
Powers/database/afk_db.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from threading import RLock
|
| 2 |
|
| 3 |
-
from Powers import LOGGER
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
| 6 |
INSERTION_LOCK = RLock()
|
|
@@ -18,10 +17,10 @@ class AFK(MongoDB):
|
|
| 18 |
if curr := self.check_afk(chat_id=chat_id, user_id=user_id):
|
| 19 |
if reason:
|
| 20 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
| 21 |
-
|
| 22 |
if media:
|
| 23 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
| 24 |
-
|
| 25 |
else:
|
| 26 |
self.insert_one(
|
| 27 |
{
|
|
|
|
| 1 |
from threading import RLock
|
| 2 |
|
|
|
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
INSERTION_LOCK = RLock()
|
|
|
|
| 17 |
if curr := self.check_afk(chat_id=chat_id, user_id=user_id):
|
| 18 |
if reason:
|
| 19 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
| 20 |
+
"reason": reason, "time": time})
|
| 21 |
if media:
|
| 22 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
| 23 |
+
'media': media, 'media_type': media_type, "time": time})
|
| 24 |
else:
|
| 25 |
self.insert_one(
|
| 26 |
{
|
Powers/database/approve_db.py
CHANGED
|
@@ -86,6 +86,7 @@ class Approve(MongoDB):
|
|
| 86 |
self.insert_one(new_data)
|
| 87 |
return new_data
|
| 88 |
return chat_data
|
|
|
|
| 89 |
# Migrate if chat id changes!
|
| 90 |
|
| 91 |
def migrate_chat(self, new_chat_id: int):
|
|
|
|
| 86 |
self.insert_one(new_data)
|
| 87 |
return new_data
|
| 88 |
return chat_data
|
| 89 |
+
|
| 90 |
# Migrate if chat id changes!
|
| 91 |
|
| 92 |
def migrate_chat(self, new_chat_id: int):
|
Powers/database/autojoin_db.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
from threading import RLock
|
| 2 |
-
from time import time
|
| 3 |
|
| 4 |
-
from Powers import LOGGER
|
| 5 |
from Powers.database import MongoDB
|
| 6 |
|
| 7 |
INSERTION_LOCK = RLock()
|
|
|
|
| 1 |
from threading import RLock
|
|
|
|
| 2 |
|
|
|
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
INSERTION_LOCK = RLock()
|
Powers/database/blacklist_db.py
CHANGED
|
@@ -63,7 +63,7 @@ class Blacklist(MongoDB):
|
|
| 63 |
collection = MongoDB(Blacklist.db_name)
|
| 64 |
curr = collection.find_all()
|
| 65 |
return sum(bool(chat["triggers"])
|
| 66 |
-
|
| 67 |
|
| 68 |
def set_action(self, action: str):
|
| 69 |
with INSERTION_LOCK:
|
|
|
|
| 63 |
collection = MongoDB(Blacklist.db_name)
|
| 64 |
curr = collection.find_all()
|
| 65 |
return sum(bool(chat["triggers"])
|
| 66 |
+
for chat in curr)
|
| 67 |
|
| 68 |
def set_action(self, action: str):
|
| 69 |
with INSERTION_LOCK:
|
Powers/database/captcha_db.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from threading import RLock
|
| 2 |
|
| 3 |
-
from Powers import LOGGER
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
| 6 |
INSERTION_LOCK = RLock()
|
|
@@ -39,7 +38,7 @@ class CAPTCHA(MongoDB):
|
|
| 39 |
with INSERTION_LOCK:
|
| 40 |
if curr := self.is_captcha(chat):
|
| 41 |
self.update({"chat_id": chat}, {
|
| 42 |
-
|
| 43 |
return
|
| 44 |
|
| 45 |
def remove_captcha(self, chat):
|
|
@@ -86,7 +85,7 @@ class CAPTCHA_DATA(MongoDB):
|
|
| 86 |
self.insert_one(
|
| 87 |
{"chat_id": chat, "user_id": user, "message_id": message})
|
| 88 |
return
|
| 89 |
-
|
| 90 |
def get_message_id(self, chat, user):
|
| 91 |
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
| 92 |
return curr["message_id"]
|
|
@@ -105,4 +104,4 @@ class CAPTCHA_DATA(MongoDB):
|
|
| 105 |
with INSERTION_LOCK:
|
| 106 |
self.delete_one({"chat_id": chat, "user_id": user})
|
| 107 |
|
| 108 |
-
return curr["message_id"]
|
|
|
|
| 1 |
from threading import RLock
|
| 2 |
|
|
|
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
INSERTION_LOCK = RLock()
|
|
|
|
| 38 |
with INSERTION_LOCK:
|
| 39 |
if curr := self.is_captcha(chat):
|
| 40 |
self.update({"chat_id": chat}, {
|
| 41 |
+
"captcha_action": captcha_action})
|
| 42 |
return
|
| 43 |
|
| 44 |
def remove_captcha(self, chat):
|
|
|
|
| 85 |
self.insert_one(
|
| 86 |
{"chat_id": chat, "user_id": user, "message_id": message})
|
| 87 |
return
|
| 88 |
+
|
| 89 |
def get_message_id(self, chat, user):
|
| 90 |
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
| 91 |
return curr["message_id"]
|
|
|
|
| 104 |
with INSERTION_LOCK:
|
| 105 |
self.delete_one({"chat_id": chat, "user_id": user})
|
| 106 |
|
| 107 |
+
return curr["message_id"]
|
Powers/database/chats_db.py
CHANGED
|
@@ -25,12 +25,12 @@ class Chats(MongoDB):
|
|
| 25 |
with INSERTION_LOCK:
|
| 26 |
|
| 27 |
if chat_name == self.chat_info["chat_name"] and self.user_is_in_chat(
|
| 28 |
-
|
| 29 |
):
|
| 30 |
return True
|
| 31 |
|
| 32 |
if chat_name != self.chat_info["chat_name"] and self.user_is_in_chat(
|
| 33 |
-
|
| 34 |
):
|
| 35 |
return self.update(
|
| 36 |
{"_id": self.chat_id},
|
|
@@ -38,7 +38,7 @@ class Chats(MongoDB):
|
|
| 38 |
)
|
| 39 |
|
| 40 |
if chat_name == self.chat_info["chat_name"] and not self.user_is_in_chat(
|
| 41 |
-
|
| 42 |
):
|
| 43 |
self.chat_info["users"].append(user_id)
|
| 44 |
return self.update(
|
|
|
|
| 25 |
with INSERTION_LOCK:
|
| 26 |
|
| 27 |
if chat_name == self.chat_info["chat_name"] and self.user_is_in_chat(
|
| 28 |
+
user_id,
|
| 29 |
):
|
| 30 |
return True
|
| 31 |
|
| 32 |
if chat_name != self.chat_info["chat_name"] and self.user_is_in_chat(
|
| 33 |
+
user_id,
|
| 34 |
):
|
| 35 |
return self.update(
|
| 36 |
{"_id": self.chat_id},
|
|
|
|
| 38 |
)
|
| 39 |
|
| 40 |
if chat_name == self.chat_info["chat_name"] and not self.user_is_in_chat(
|
| 41 |
+
user_id,
|
| 42 |
):
|
| 43 |
self.chat_info["users"].append(user_id)
|
| 44 |
return self.update(
|
Powers/database/disable_db.py
CHANGED
|
@@ -83,7 +83,7 @@ class Disabling(MongoDB):
|
|
| 83 |
collection = MongoDB(Disabling.db_name)
|
| 84 |
curr = collection.find_all()
|
| 85 |
return sum(bool(chat["commands"])
|
| 86 |
-
|
| 87 |
|
| 88 |
def set_action(self, action: str):
|
| 89 |
with INSERTION_LOCK:
|
|
|
|
| 83 |
collection = MongoDB(Disabling.db_name)
|
| 84 |
curr = collection.find_all()
|
| 85 |
return sum(bool(chat["commands"])
|
| 86 |
+
for chat in curr)
|
| 87 |
|
| 88 |
def set_action(self, action: str):
|
| 89 |
with INSERTION_LOCK:
|
Powers/database/filters_db.py
CHANGED
|
@@ -13,12 +13,12 @@ class Filters(MongoDB):
|
|
| 13 |
super().__init__(self.db_name)
|
| 14 |
|
| 15 |
def save_filter(
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
):
|
| 23 |
with INSERTION_LOCK:
|
| 24 |
if curr := self.find_one({"chat_id": chat_id, "keyword": keyword}):
|
|
|
|
| 13 |
super().__init__(self.db_name)
|
| 14 |
|
| 15 |
def save_filter(
|
| 16 |
+
self,
|
| 17 |
+
chat_id: int,
|
| 18 |
+
keyword: str,
|
| 19 |
+
filter_reply: str,
|
| 20 |
+
msgtype: int = Types.TEXT,
|
| 21 |
+
fileid="",
|
| 22 |
):
|
| 23 |
with INSERTION_LOCK:
|
| 24 |
if curr := self.find_one({"chat_id": chat_id, "keyword": keyword}):
|
Powers/database/flood_db.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
from threading import RLock
|
| 2 |
-
from traceback import format_exc
|
| 3 |
|
| 4 |
-
from Powers import LOGGER
|
| 5 |
from Powers.database import MongoDB
|
| 6 |
-
from Powers.utils.msg_types import Types
|
| 7 |
|
| 8 |
INSERTION_LOCK = RLock()
|
| 9 |
|
|
@@ -16,11 +13,11 @@ class Floods(MongoDB):
|
|
| 16 |
super().__init__(self.db_name)
|
| 17 |
|
| 18 |
def save_flood(
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
):
|
| 25 |
with INSERTION_LOCK:
|
| 26 |
if not (curr := self.find_one({"chat_id": chat_id})):
|
|
@@ -33,9 +30,9 @@ class Floods(MongoDB):
|
|
| 33 |
},
|
| 34 |
)
|
| 35 |
if (
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
):
|
| 40 |
return self.update(
|
| 41 |
{
|
|
|
|
| 1 |
from threading import RLock
|
|
|
|
| 2 |
|
|
|
|
| 3 |
from Powers.database import MongoDB
|
|
|
|
| 4 |
|
| 5 |
INSERTION_LOCK = RLock()
|
| 6 |
|
|
|
|
| 13 |
super().__init__(self.db_name)
|
| 14 |
|
| 15 |
def save_flood(
|
| 16 |
+
self,
|
| 17 |
+
chat_id: int,
|
| 18 |
+
limit: int,
|
| 19 |
+
within: int,
|
| 20 |
+
action: str,
|
| 21 |
):
|
| 22 |
with INSERTION_LOCK:
|
| 23 |
if not (curr := self.find_one({"chat_id": chat_id})):
|
|
|
|
| 30 |
},
|
| 31 |
)
|
| 32 |
if (
|
| 33 |
+
limit != int(curr['limit'])
|
| 34 |
+
or within != int(curr['within'])
|
| 35 |
+
or action != str(curr['action'])
|
| 36 |
):
|
| 37 |
return self.update(
|
| 38 |
{
|
Powers/database/greetings_db.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from threading import RLock
|
| 2 |
|
| 3 |
-
from Powers import LOGGER
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
| 6 |
INSERTION_LOCK = RLock()
|
|
|
|
| 1 |
from threading import RLock
|
| 2 |
|
|
|
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
INSERTION_LOCK = RLock()
|
Powers/database/locks_db.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from threading import RLock
|
| 2 |
|
| 3 |
-
from Powers import LOGGER
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
| 6 |
INSERTION_LOCK = RLock()
|
|
@@ -73,34 +72,33 @@ class LOCKS(MongoDB):
|
|
| 73 |
{"chat_id": chat, "locktype": locktype})
|
| 74 |
return bool(curr)
|
| 75 |
else:
|
| 76 |
-
if curr := self.find_all({"chat_id": chat}):
|
| 77 |
-
to_return = {
|
| 78 |
-
"anti_channel": False,
|
| 79 |
-
"anti_fwd": {
|
| 80 |
-
"user": False,
|
| 81 |
-
"chat": False
|
| 82 |
-
},
|
| 83 |
-
"anti_links": False,
|
| 84 |
-
"bot": False
|
| 85 |
-
}
|
| 86 |
-
for i in list(curr):
|
| 87 |
-
if i["locktype"] == "anti_c_send":
|
| 88 |
-
to_return["anti_channel"] = True
|
| 89 |
-
elif i["locktype"] == "anti_fwd":
|
| 90 |
-
to_return["anti_fwd"]["user"] = to_return["anti_fwd"]["chat"] = True
|
| 91 |
-
elif i["locktype"] == "anti_fwd_u":
|
| 92 |
-
to_return["anti_fwd"]["user"] = True
|
| 93 |
-
elif i["locktype"] == "anti_fwd_c":
|
| 94 |
-
to_return["anti_fwd"]["chat"] = True
|
| 95 |
-
elif i["anti_links"] == "anti_links":
|
| 96 |
-
to_return["anti_links"] = True
|
| 97 |
-
elif i["locktype"] == "bot":
|
| 98 |
-
to_return["bot"] = True
|
| 99 |
-
else:
|
| 100 |
-
continue
|
| 101 |
-
return to_return
|
| 102 |
-
else:
|
| 103 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
def merge_u_and_c(self, chat: int, locktype: str):
|
| 106 |
if locktype == "anti_fwd_u":
|
|
|
|
| 1 |
from threading import RLock
|
| 2 |
|
|
|
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
INSERTION_LOCK = RLock()
|
|
|
|
| 72 |
{"chat_id": chat, "locktype": locktype})
|
| 73 |
return bool(curr)
|
| 74 |
else:
|
| 75 |
+
if not (curr := self.find_all({"chat_id": chat})):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
return None
|
| 77 |
+
to_return = {
|
| 78 |
+
"anti_channel": False,
|
| 79 |
+
"anti_fwd": {
|
| 80 |
+
"user": False,
|
| 81 |
+
"chat": False
|
| 82 |
+
},
|
| 83 |
+
"anti_links": False,
|
| 84 |
+
"bot": False
|
| 85 |
+
}
|
| 86 |
+
for i in list(curr):
|
| 87 |
+
if i["locktype"] == "anti_c_send":
|
| 88 |
+
to_return["anti_channel"] = True
|
| 89 |
+
elif i["locktype"] == "anti_fwd":
|
| 90 |
+
to_return["anti_fwd"]["user"] = to_return["anti_fwd"]["chat"] = True
|
| 91 |
+
elif i["locktype"] == "anti_fwd_u":
|
| 92 |
+
to_return["anti_fwd"]["user"] = True
|
| 93 |
+
elif i["locktype"] == "anti_fwd_c":
|
| 94 |
+
to_return["anti_fwd"]["chat"] = True
|
| 95 |
+
elif i["anti_links"] == "anti_links":
|
| 96 |
+
to_return["anti_links"] = True
|
| 97 |
+
elif i["locktype"] == "bot":
|
| 98 |
+
to_return["bot"] = True
|
| 99 |
+
else:
|
| 100 |
+
continue
|
| 101 |
+
return to_return
|
| 102 |
|
| 103 |
def merge_u_and_c(self, chat: int, locktype: str):
|
| 104 |
if locktype == "anti_fwd_u":
|
Powers/database/notes_db.py
CHANGED
|
@@ -15,16 +15,16 @@ class Notes(MongoDB):
|
|
| 15 |
super().__init__(self.db_name)
|
| 16 |
|
| 17 |
def save_note(
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
):
|
| 25 |
with INSERTION_LOCK:
|
| 26 |
if curr := self.find_one(
|
| 27 |
-
|
| 28 |
):
|
| 29 |
return False
|
| 30 |
hash_gen = md5(
|
|
@@ -44,7 +44,7 @@ class Notes(MongoDB):
|
|
| 44 |
def get_note(self, chat_id: int, note_name: str):
|
| 45 |
with INSERTION_LOCK:
|
| 46 |
if curr := self.find_one(
|
| 47 |
-
|
| 48 |
):
|
| 49 |
return curr
|
| 50 |
return "Note does not exist!"
|
|
@@ -60,7 +60,7 @@ class Notes(MongoDB):
|
|
| 60 |
def rm_note(self, chat_id: int, note_name: str):
|
| 61 |
with INSERTION_LOCK:
|
| 62 |
if curr := self.find_one(
|
| 63 |
-
|
| 64 |
):
|
| 65 |
self.delete_one(curr)
|
| 66 |
return True
|
|
|
|
| 15 |
super().__init__(self.db_name)
|
| 16 |
|
| 17 |
def save_note(
|
| 18 |
+
self,
|
| 19 |
+
chat_id: int,
|
| 20 |
+
note_name: str,
|
| 21 |
+
note_value: str,
|
| 22 |
+
msgtype: int = Types.TEXT,
|
| 23 |
+
fileid="",
|
| 24 |
):
|
| 25 |
with INSERTION_LOCK:
|
| 26 |
if curr := self.find_one(
|
| 27 |
+
{"chat_id": chat_id, "note_name": note_name},
|
| 28 |
):
|
| 29 |
return False
|
| 30 |
hash_gen = md5(
|
|
|
|
| 44 |
def get_note(self, chat_id: int, note_name: str):
|
| 45 |
with INSERTION_LOCK:
|
| 46 |
if curr := self.find_one(
|
| 47 |
+
{"chat_id": chat_id, "note_name": note_name},
|
| 48 |
):
|
| 49 |
return curr
|
| 50 |
return "Note does not exist!"
|
|
|
|
| 60 |
def rm_note(self, chat_id: int, note_name: str):
|
| 61 |
with INSERTION_LOCK:
|
| 62 |
if curr := self.find_one(
|
| 63 |
+
{"chat_id": chat_id, "note_name": note_name},
|
| 64 |
):
|
| 65 |
self.delete_one(curr)
|
| 66 |
return True
|
Powers/database/support_db.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from threading import RLock
|
| 2 |
|
| 3 |
-
from Powers import LOGGER
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
| 6 |
INSERTION_LOCK = RLock()
|
|
|
|
| 1 |
from threading import RLock
|
| 2 |
|
|
|
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
INSERTION_LOCK = RLock()
|
Powers/database/warns_db.py
CHANGED
|
@@ -94,7 +94,7 @@ class Warns(MongoDB):
|
|
| 94 |
)
|
| 95 |
collection.update(
|
| 96 |
{"chat_id": data["chat_id"],
|
| 97 |
-
|
| 98 |
{key: val},
|
| 99 |
)
|
| 100 |
|
|
|
|
| 94 |
)
|
| 95 |
collection.update(
|
| 96 |
{"chat_id": data["chat_id"],
|
| 97 |
+
"user_id": data["user_id"]},
|
| 98 |
{key: val},
|
| 99 |
)
|
| 100 |
|
Powers/plugins/__init__.py
CHANGED
|
@@ -13,6 +13,7 @@ async def all_plugins():
|
|
| 13 |
]
|
| 14 |
return sorted(all_plugs)
|
| 15 |
|
|
|
|
| 16 |
from sys import exit as exiter
|
| 17 |
|
| 18 |
from pymongo import MongoClient
|
|
@@ -36,5 +37,4 @@ from datetime import datetime
|
|
| 36 |
|
| 37 |
def till_date(date):
|
| 38 |
form = "%Y-%m-%d %H:%M:%S"
|
| 39 |
-
return datetime.strptime(date,form)
|
| 40 |
-
|
|
|
|
| 13 |
]
|
| 14 |
return sorted(all_plugs)
|
| 15 |
|
| 16 |
+
|
| 17 |
from sys import exit as exiter
|
| 18 |
|
| 19 |
from pymongo import MongoClient
|
|
|
|
| 37 |
|
| 38 |
def till_date(date):
|
| 39 |
form = "%Y-%m-%d %H:%M:%S"
|
| 40 |
+
return datetime.strptime(date, form)
|
|
|
Powers/plugins/admin.py
CHANGED
|
@@ -15,8 +15,7 @@ from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, WHITELIST_USERS
|
|
| 15 |
from Powers.bot_class import Gojo
|
| 16 |
from Powers.database.approve_db import Approve
|
| 17 |
from Powers.database.reporting_db import Reporting
|
| 18 |
-
from Powers.utils.caching import (
|
| 19 |
-
admin_cache_reload)
|
| 20 |
from Powers.utils.custom_filters import admin_filter, command, promote_filter
|
| 21 |
from Powers.utils.extract_user import extract_user
|
| 22 |
from Powers.utils.parser import mention_html
|
|
@@ -25,7 +24,7 @@ from Powers.utils.parser import mention_html
|
|
| 25 |
@Gojo.on_message(command("adminlist"))
|
| 26 |
async def adminlist_show(_, m: Message):
|
| 27 |
global ADMIN_CACHE
|
| 28 |
-
if m.chat.type not in [ChatType.SUPERGROUP,ChatType.GROUP]:
|
| 29 |
return await m.reply_text(
|
| 30 |
text="This command is made to be used in groups only!",
|
| 31 |
)
|
|
@@ -78,7 +77,6 @@ async def adminlist_show(_, m: Message):
|
|
| 78 |
return
|
| 79 |
|
| 80 |
|
| 81 |
-
|
| 82 |
@Gojo.on_message(command("zombies") & admin_filter)
|
| 83 |
async def zombie_clean(c: Gojo, m: Message):
|
| 84 |
zombie = 0
|
|
@@ -100,22 +98,23 @@ async def zombie_clean(c: Gojo, m: Message):
|
|
| 100 |
if zombie == 0:
|
| 101 |
return await wait.edit_text("Group is clean!")
|
| 102 |
await wait.delete()
|
| 103 |
-
txt=f"<b>{zombie}</b> Zombies found and {zombie - failed} has been banned!\n{failed} zombies' are immune to me",
|
| 104 |
await m.reply_animation("https://graph.org/file/02a1dcf7788186ffb36cb.mp4", caption=txt)
|
| 105 |
return
|
| 106 |
|
|
|
|
| 107 |
@Gojo.on_message(command("admincache"))
|
| 108 |
async def reload_admins(_, m: Message):
|
| 109 |
global TEMP_ADMIN_CACHE_BLOCK
|
| 110 |
-
if m.chat.type not in [ChatType.SUPERGROUP,ChatType.GROUP]:
|
| 111 |
return await m.reply_text(
|
| 112 |
"This command is made to be used in groups only!",
|
| 113 |
)
|
| 114 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 115 |
if (
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
):
|
| 120 |
await m.reply_text("Can only reload admin cache once per 10 mins!")
|
| 121 |
return
|
|
@@ -194,9 +193,9 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 194 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 195 |
title = "Gojo" # Default fullpromote title
|
| 196 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
| 197 |
-
title = " ".join(m.text.split()[2:16])
|
| 198 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
| 199 |
-
title = " ".join(m.text.split()[1:16])
|
| 200 |
|
| 201 |
try:
|
| 202 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
|
@@ -297,9 +296,9 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 297 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 298 |
title = "Itadori" # Deafult title
|
| 299 |
if len(m.text.split()) >= 3 and not m.reply_to_message:
|
| 300 |
-
title = " ".join(m.text.split()[2:16])
|
| 301 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
| 302 |
-
title = " ".join(m.text.split()[1:16])
|
| 303 |
try:
|
| 304 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
| 305 |
except RPCError as e:
|
|
@@ -308,7 +307,7 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 308 |
except Exception as e:
|
| 309 |
LOGGER.error(e)
|
| 310 |
LOGGER.error(format_exc())
|
| 311 |
-
|
| 312 |
await m.reply_text(
|
| 313 |
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
| 314 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
|
@@ -406,7 +405,8 @@ async def demote_usr(c: Gojo, m: Message):
|
|
| 406 |
"Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 407 |
)
|
| 408 |
except BotChannelsNa:
|
| 409 |
-
await m.reply_text(
|
|
|
|
| 410 |
except RPCError as ef:
|
| 411 |
await m.reply_text(
|
| 412 |
f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
|
@@ -419,7 +419,7 @@ async def demote_usr(c: Gojo, m: Message):
|
|
| 419 |
@Gojo.on_message(command("invitelink"))
|
| 420 |
async def get_invitelink(c: Gojo, m: Message):
|
| 421 |
# Bypass the bot devs, sudos and owner
|
| 422 |
-
|
| 423 |
DEV_LEVEL = DEV_USERS
|
| 424 |
if m.from_user.id not in DEV_LEVEL:
|
| 425 |
user = await m.chat.get_member(m.from_user.id)
|
|
@@ -466,6 +466,7 @@ async def setgtitle(_, m: Message):
|
|
| 466 |
f"Successfully Changed Group Title From {m.chat.title} To {gtit}",
|
| 467 |
)
|
| 468 |
|
|
|
|
| 469 |
@Gojo.on_message(command("setgdes") & admin_filter)
|
| 470 |
async def setgdes(_, m: Message):
|
| 471 |
user = await m.chat.get_member(m.from_user.id)
|
|
@@ -537,7 +538,7 @@ async def setgpic(c: Gojo, m: Message):
|
|
| 537 |
photo = await m.reply_to_message.download()
|
| 538 |
is_vid = bool(m.reply_to_message.video)
|
| 539 |
try:
|
| 540 |
-
await m.chat.set_photo(photo,video=is_vid)
|
| 541 |
except Exception as e:
|
| 542 |
remove(photo)
|
| 543 |
return await m.reply_text(f"Error: {e}")
|
|
@@ -583,5 +584,3 @@ __HELP__ = """
|
|
| 583 |
|
| 584 |
**Example:**
|
| 585 |
`/promote @username`: this promotes a user to admin."""
|
| 586 |
-
|
| 587 |
-
|
|
|
|
| 15 |
from Powers.bot_class import Gojo
|
| 16 |
from Powers.database.approve_db import Approve
|
| 17 |
from Powers.database.reporting_db import Reporting
|
| 18 |
+
from Powers.utils.caching import (admin_cache_reload)
|
|
|
|
| 19 |
from Powers.utils.custom_filters import admin_filter, command, promote_filter
|
| 20 |
from Powers.utils.extract_user import extract_user
|
| 21 |
from Powers.utils.parser import mention_html
|
|
|
|
| 24 |
@Gojo.on_message(command("adminlist"))
|
| 25 |
async def adminlist_show(_, m: Message):
|
| 26 |
global ADMIN_CACHE
|
| 27 |
+
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 28 |
return await m.reply_text(
|
| 29 |
text="This command is made to be used in groups only!",
|
| 30 |
)
|
|
|
|
| 77 |
return
|
| 78 |
|
| 79 |
|
|
|
|
| 80 |
@Gojo.on_message(command("zombies") & admin_filter)
|
| 81 |
async def zombie_clean(c: Gojo, m: Message):
|
| 82 |
zombie = 0
|
|
|
|
| 98 |
if zombie == 0:
|
| 99 |
return await wait.edit_text("Group is clean!")
|
| 100 |
await wait.delete()
|
| 101 |
+
txt = f"<b>{zombie}</b> Zombies found and {zombie - failed} has been banned!\n{failed} zombies' are immune to me",
|
| 102 |
await m.reply_animation("https://graph.org/file/02a1dcf7788186ffb36cb.mp4", caption=txt)
|
| 103 |
return
|
| 104 |
|
| 105 |
+
|
| 106 |
@Gojo.on_message(command("admincache"))
|
| 107 |
async def reload_admins(_, m: Message):
|
| 108 |
global TEMP_ADMIN_CACHE_BLOCK
|
| 109 |
+
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 110 |
return await m.reply_text(
|
| 111 |
"This command is made to be used in groups only!",
|
| 112 |
)
|
| 113 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 114 |
if (
|
| 115 |
+
(m.chat.id in set(TEMP_ADMIN_CACHE_BLOCK.keys()))
|
| 116 |
+
and (m.from_user.id not in SUPPORT_STAFF)
|
| 117 |
+
and TEMP_ADMIN_CACHE_BLOCK[m.chat.id] == "manualblock"
|
| 118 |
):
|
| 119 |
await m.reply_text("Can only reload admin cache once per 10 mins!")
|
| 120 |
return
|
|
|
|
| 193 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 194 |
title = "Gojo" # Default fullpromote title
|
| 195 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
| 196 |
+
title = " ".join(m.text.split()[2:16]) # trim title to 16 characters
|
| 197 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
| 198 |
+
title = " ".join(m.text.split()[1:16]) # trim title to 16 characters
|
| 199 |
|
| 200 |
try:
|
| 201 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
|
|
|
| 296 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 297 |
title = "Itadori" # Deafult title
|
| 298 |
if len(m.text.split()) >= 3 and not m.reply_to_message:
|
| 299 |
+
title = " ".join(m.text.split()[2:16]) # trim title to 16 characters
|
| 300 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
| 301 |
+
title = " ".join(m.text.split()[1:16]) # trim title to 16 characters
|
| 302 |
try:
|
| 303 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
| 304 |
except RPCError as e:
|
|
|
|
| 307 |
except Exception as e:
|
| 308 |
LOGGER.error(e)
|
| 309 |
LOGGER.error(format_exc())
|
| 310 |
+
|
| 311 |
await m.reply_text(
|
| 312 |
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
| 313 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
|
|
|
| 405 |
"Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 406 |
)
|
| 407 |
except BotChannelsNa:
|
| 408 |
+
await m.reply_text(
|
| 409 |
+
"May be the user is bot and due to telegram restrictions I can't demote them. Please do it manually")
|
| 410 |
except RPCError as ef:
|
| 411 |
await m.reply_text(
|
| 412 |
f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
|
|
|
| 419 |
@Gojo.on_message(command("invitelink"))
|
| 420 |
async def get_invitelink(c: Gojo, m: Message):
|
| 421 |
# Bypass the bot devs, sudos and owner
|
| 422 |
+
|
| 423 |
DEV_LEVEL = DEV_USERS
|
| 424 |
if m.from_user.id not in DEV_LEVEL:
|
| 425 |
user = await m.chat.get_member(m.from_user.id)
|
|
|
|
| 466 |
f"Successfully Changed Group Title From {m.chat.title} To {gtit}",
|
| 467 |
)
|
| 468 |
|
| 469 |
+
|
| 470 |
@Gojo.on_message(command("setgdes") & admin_filter)
|
| 471 |
async def setgdes(_, m: Message):
|
| 472 |
user = await m.chat.get_member(m.from_user.id)
|
|
|
|
| 538 |
photo = await m.reply_to_message.download()
|
| 539 |
is_vid = bool(m.reply_to_message.video)
|
| 540 |
try:
|
| 541 |
+
await m.chat.set_photo(photo, video=is_vid)
|
| 542 |
except Exception as e:
|
| 543 |
remove(photo)
|
| 544 |
return await m.reply_text(f"Error: {e}")
|
|
|
|
| 584 |
|
| 585 |
**Example:**
|
| 586 |
`/promote @username`: this promotes a user to admin."""
|
|
|
|
|
|
Powers/plugins/afk.py
CHANGED
|
@@ -30,31 +30,33 @@ back = [
|
|
| 30 |
"{first} is now finally back from the dead"
|
| 31 |
]
|
| 32 |
|
| 33 |
-
|
|
|
|
| 34 |
async def going_afk(c: Gojo, m: Message):
|
| 35 |
user = m.from_user.id
|
| 36 |
chat = m.chat.id
|
| 37 |
afk = AFK()
|
| 38 |
text, data_type, content = await get_afk_type(m)
|
| 39 |
-
|
| 40 |
-
time = str(datetime.now()).rsplit(".",1)[0]
|
| 41 |
|
| 42 |
if len(m.command) == 1:
|
| 43 |
text = choice(res)
|
| 44 |
|
| 45 |
elif len(m.command) > 1:
|
| 46 |
-
text = m.text.markdown.split(None,1)[1]
|
| 47 |
|
| 48 |
if not data_type:
|
| 49 |
data_type = Types.TEXT
|
| 50 |
|
| 51 |
-
afk.insert_afk(chat,user,str(time),text,data_type,content)
|
| 52 |
|
| 53 |
await m.reply_text(f"{m.from_user.mention} is now AFK")
|
| 54 |
|
| 55 |
return
|
| 56 |
|
| 57 |
-
|
|
|
|
| 58 |
tim = hour.strip().split(":")
|
| 59 |
txt = ""
|
| 60 |
if int(tim[0]):
|
|
@@ -76,13 +78,10 @@ async def afk_checker(c: Gojo, m: Message):
|
|
| 76 |
repl = m.reply_to_message
|
| 77 |
|
| 78 |
rep_user = repl.from_user.id if repl and repl.from_user else False
|
| 79 |
-
is_afk = afk.check_afk(chat,user)
|
| 80 |
-
is_rep_afk = False
|
| 81 |
-
if rep_user:
|
| 82 |
-
is_rep_afk = afk.check_afk(chat,rep_user)
|
| 83 |
-
|
| 84 |
if is_rep_afk and rep_user != user:
|
| 85 |
-
con = afk.get_afk(chat,rep_user)
|
| 86 |
time = till_date(con["time"])
|
| 87 |
media = con["media"]
|
| 88 |
media_type = con["media_type"]
|
|
@@ -100,15 +99,15 @@ async def afk_checker(c: Gojo, m: Message):
|
|
| 100 |
reason += f"\n{con['reason'].format(first=repl.from_user.first_name)}"
|
| 101 |
txt = reason
|
| 102 |
|
| 103 |
-
if media_type == Types.TEXT:
|
| 104 |
-
await (await send_cmd(c,media_type))(
|
| 105 |
chat,
|
| 106 |
txt,
|
| 107 |
parse_mode=PM.MARKDOWN,
|
| 108 |
reply_to_message_id=m.id,
|
| 109 |
)
|
| 110 |
else:
|
| 111 |
-
await (await send_cmd(c,media_type))(
|
| 112 |
chat,
|
| 113 |
media,
|
| 114 |
txt,
|
|
@@ -123,10 +122,10 @@ async def afk_checker(c: Gojo, m: Message):
|
|
| 123 |
except Exception:
|
| 124 |
pass
|
| 125 |
|
| 126 |
-
if txt and txt in ["afk","brb"]:
|
| 127 |
raise ContinuePropagation
|
| 128 |
else:
|
| 129 |
-
con = afk.get_afk(chat,user)
|
| 130 |
time = till_date(con["time"])
|
| 131 |
tim_ = datetime.now() - time
|
| 132 |
tim_ = str(tim_).split(",")
|
|
@@ -134,15 +133,16 @@ async def afk_checker(c: Gojo, m: Message):
|
|
| 134 |
if len(tim_) == 1:
|
| 135 |
tims = tim
|
| 136 |
elif len(tim_) == 2:
|
| 137 |
-
tims = f"{tim_[0]} "
|
| 138 |
-
txt = back_.format(first=m.from_user.mention)
|
| 139 |
await m.reply_text(txt)
|
| 140 |
-
afk.delete_afk(chat,user)
|
| 141 |
raise ContinuePropagation
|
| 142 |
|
|
|
|
| 143 |
__PLUGIN__ = "afk"
|
| 144 |
|
| 145 |
-
_DISABLE_CMDS_ = ["afk","brb"]
|
| 146 |
|
| 147 |
__alt_name__ = ["brb"]
|
| 148 |
|
|
@@ -151,4 +151,4 @@ __HELP__ = """
|
|
| 151 |
• /afk (/brb) [reason | reply to a message]
|
| 152 |
|
| 153 |
`reply to a message` can be any media or text
|
| 154 |
-
"""
|
|
|
|
| 30 |
"{first} is now finally back from the dead"
|
| 31 |
]
|
| 32 |
|
| 33 |
+
|
| 34 |
+
@Gojo.on_message(command(["afk", "brb"]) & ~filters.private)
|
| 35 |
async def going_afk(c: Gojo, m: Message):
|
| 36 |
user = m.from_user.id
|
| 37 |
chat = m.chat.id
|
| 38 |
afk = AFK()
|
| 39 |
text, data_type, content = await get_afk_type(m)
|
| 40 |
+
|
| 41 |
+
time = str(datetime.now()).rsplit(".", 1)[0]
|
| 42 |
|
| 43 |
if len(m.command) == 1:
|
| 44 |
text = choice(res)
|
| 45 |
|
| 46 |
elif len(m.command) > 1:
|
| 47 |
+
text = m.text.markdown.split(None, 1)[1]
|
| 48 |
|
| 49 |
if not data_type:
|
| 50 |
data_type = Types.TEXT
|
| 51 |
|
| 52 |
+
afk.insert_afk(chat, user, str(time), text, data_type, content)
|
| 53 |
|
| 54 |
await m.reply_text(f"{m.from_user.mention} is now AFK")
|
| 55 |
|
| 56 |
return
|
| 57 |
|
| 58 |
+
|
| 59 |
+
async def get_hours(hour: str):
|
| 60 |
tim = hour.strip().split(":")
|
| 61 |
txt = ""
|
| 62 |
if int(tim[0]):
|
|
|
|
| 78 |
repl = m.reply_to_message
|
| 79 |
|
| 80 |
rep_user = repl.from_user.id if repl and repl.from_user else False
|
| 81 |
+
is_afk = afk.check_afk(chat, user)
|
| 82 |
+
is_rep_afk = afk.check_afk(chat, rep_user) if rep_user else False
|
|
|
|
|
|
|
|
|
|
| 83 |
if is_rep_afk and rep_user != user:
|
| 84 |
+
con = afk.get_afk(chat, rep_user)
|
| 85 |
time = till_date(con["time"])
|
| 86 |
media = con["media"]
|
| 87 |
media_type = con["media_type"]
|
|
|
|
| 99 |
reason += f"\n{con['reason'].format(first=repl.from_user.first_name)}"
|
| 100 |
txt = reason
|
| 101 |
|
| 102 |
+
if media_type == Types.TEXT:
|
| 103 |
+
await (await send_cmd(c, media_type))(
|
| 104 |
chat,
|
| 105 |
txt,
|
| 106 |
parse_mode=PM.MARKDOWN,
|
| 107 |
reply_to_message_id=m.id,
|
| 108 |
)
|
| 109 |
else:
|
| 110 |
+
await (await send_cmd(c, media_type))(
|
| 111 |
chat,
|
| 112 |
media,
|
| 113 |
txt,
|
|
|
|
| 122 |
except Exception:
|
| 123 |
pass
|
| 124 |
|
| 125 |
+
if txt and txt in ["afk", "brb"]:
|
| 126 |
raise ContinuePropagation
|
| 127 |
else:
|
| 128 |
+
con = afk.get_afk(chat, user)
|
| 129 |
time = till_date(con["time"])
|
| 130 |
tim_ = datetime.now() - time
|
| 131 |
tim_ = str(tim_).split(",")
|
|
|
|
| 133 |
if len(tim_) == 1:
|
| 134 |
tims = tim
|
| 135 |
elif len(tim_) == 2:
|
| 136 |
+
tims = f"{tim_[0]} {tim}"
|
| 137 |
+
txt = f"{back_.format(first=m.from_user.mention)}\n\nAfk for: {tims}"
|
| 138 |
await m.reply_text(txt)
|
| 139 |
+
afk.delete_afk(chat, user)
|
| 140 |
raise ContinuePropagation
|
| 141 |
|
| 142 |
+
|
| 143 |
__PLUGIN__ = "afk"
|
| 144 |
|
| 145 |
+
_DISABLE_CMDS_ = ["afk", "brb"]
|
| 146 |
|
| 147 |
__alt_name__ = ["brb"]
|
| 148 |
|
|
|
|
| 151 |
• /afk (/brb) [reason | reply to a message]
|
| 152 |
|
| 153 |
`reply to a message` can be any media or text
|
| 154 |
+
"""
|
Powers/plugins/antispam.py
CHANGED
|
@@ -18,6 +18,7 @@ from Powers.utils.parser import mention_html
|
|
| 18 |
# Initialize
|
| 19 |
db = GBan()
|
| 20 |
|
|
|
|
| 21 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
| 22 |
async def gban(c: Gojo, m: Message):
|
| 23 |
if len(m.text.split()) == 1:
|
|
@@ -72,7 +73,7 @@ async def gban(c: Gojo, m: Message):
|
|
| 72 |
try:
|
| 73 |
await c.ban_chat_member(m.chat.id, user_id)
|
| 74 |
except Exception as e:
|
| 75 |
-
await m.reply_text(f"Failed to ban this user\n{e}")
|
| 76 |
except UserIsBlocked:
|
| 77 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
| 78 |
except PeerIdInvalid:
|
|
@@ -170,14 +171,13 @@ async def gban_list(_, m: Message):
|
|
| 170 |
document=f, caption="Here are all the globally banned geys!\n\n"
|
| 171 |
)
|
| 172 |
|
| 173 |
-
|
| 174 |
return
|
| 175 |
|
|
|
|
| 176 |
__PLUGIN__ = "global"
|
| 177 |
|
| 178 |
__alt_name__ = ["antispam", "global"]
|
| 179 |
|
| 180 |
-
|
| 181 |
__HELP__ = """
|
| 182 |
**Global**
|
| 183 |
|
|
@@ -186,4 +186,4 @@ __HELP__ = """
|
|
| 186 |
• /ungban [reply to user | user id | username]: Remove the user from the global ban watchlist.
|
| 187 |
• /numgbans : Give number of users who are banned globally.
|
| 188 |
• /gbanlist : Give list of globally banned users.
|
| 189 |
-
"""
|
|
|
|
| 18 |
# Initialize
|
| 19 |
db = GBan()
|
| 20 |
|
| 21 |
+
|
| 22 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
| 23 |
async def gban(c: Gojo, m: Message):
|
| 24 |
if len(m.text.split()) == 1:
|
|
|
|
| 73 |
try:
|
| 74 |
await c.ban_chat_member(m.chat.id, user_id)
|
| 75 |
except Exception as e:
|
| 76 |
+
await m.reply_text(f"Failed to ban this user\n{e}")
|
| 77 |
except UserIsBlocked:
|
| 78 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
| 79 |
except PeerIdInvalid:
|
|
|
|
| 171 |
document=f, caption="Here are all the globally banned geys!\n\n"
|
| 172 |
)
|
| 173 |
|
|
|
|
| 174 |
return
|
| 175 |
|
| 176 |
+
|
| 177 |
__PLUGIN__ = "global"
|
| 178 |
|
| 179 |
__alt_name__ = ["antispam", "global"]
|
| 180 |
|
|
|
|
| 181 |
__HELP__ = """
|
| 182 |
**Global**
|
| 183 |
|
|
|
|
| 186 |
• /ungban [reply to user | user id | username]: Remove the user from the global ban watchlist.
|
| 187 |
• /numgbans : Give number of users who are banned globally.
|
| 188 |
• /gbanlist : Give list of globally banned users.
|
| 189 |
+
"""
|
Powers/plugins/approve.py
CHANGED
|
@@ -3,7 +3,6 @@ from pyrogram.enums import ChatMemberStatus as CMS
|
|
| 3 |
from pyrogram.errors import PeerIdInvalid, RPCError, UserNotParticipant
|
| 4 |
from pyrogram.types import CallbackQuery, Message
|
| 5 |
|
| 6 |
-
from Powers import LOGGER
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
from Powers.database.approve_db import Approve
|
| 9 |
from Powers.utils.custom_filters import admin_filter, command, owner_filter
|
|
@@ -222,7 +221,6 @@ _DISABLE_CMDS_ = ["approval"]
|
|
| 222 |
|
| 223 |
__alt_name__ = ["approved"]
|
| 224 |
|
| 225 |
-
|
| 226 |
__HELP__ = """
|
| 227 |
**Apporve**
|
| 228 |
|
|
|
|
| 3 |
from pyrogram.errors import PeerIdInvalid, RPCError, UserNotParticipant
|
| 4 |
from pyrogram.types import CallbackQuery, Message
|
| 5 |
|
|
|
|
| 6 |
from Powers.bot_class import Gojo
|
| 7 |
from Powers.database.approve_db import Approve
|
| 8 |
from Powers.utils.custom_filters import admin_filter, command, owner_filter
|
|
|
|
| 221 |
|
| 222 |
__alt_name__ = ["approved"]
|
| 223 |
|
|
|
|
| 224 |
__HELP__ = """
|
| 225 |
**Apporve**
|
| 226 |
|
Powers/plugins/auto_join.py
CHANGED
|
@@ -34,8 +34,6 @@ async def accept_join_requests(c: Gojo, m: Message):
|
|
| 34 |
return
|
| 35 |
if len(split) == 1:
|
| 36 |
txt = "**USAGE**\n/joinreq [on | off]"
|
| 37 |
-
await m.reply_text(txt)
|
| 38 |
-
return
|
| 39 |
else:
|
| 40 |
yes_no = split[1].lower()
|
| 41 |
if yes_no == "on":
|
|
@@ -51,8 +49,10 @@ async def accept_join_requests(c: Gojo, m: Message):
|
|
| 51 |
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
| 52 |
else:
|
| 53 |
txt = "**USAGE**\n/joinreq [on | off]"
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
|
| 57 |
@Gojo.on_message(command("joinreqmode") & admin_filter)
|
| 58 |
async def join_request_mode(c: Gojo, m: Message):
|
|
@@ -68,10 +68,10 @@ async def join_request_mode(c: Gojo, m: Message):
|
|
| 68 |
await m.reply_text(u_text)
|
| 69 |
else:
|
| 70 |
auto_manual = split[1]
|
| 71 |
-
if auto_manual not in ["auto","manual"]:
|
| 72 |
await m.reply_text(u_text)
|
| 73 |
else:
|
| 74 |
-
a_j.update_join_type(m.chat.id,auto_manual)
|
| 75 |
txt = "Changed join request type"
|
| 76 |
await m.reply_text(txt)
|
| 77 |
|
|
@@ -91,11 +91,12 @@ async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
|
| 91 |
return
|
| 92 |
if join_type == "auto" or user in SUPPORT_STAFF:
|
| 93 |
try:
|
| 94 |
-
await c.approve_chat_join_request(chat,user)
|
| 95 |
await c.send_message(chat, f"Accepted join request of the {userr.mention}")
|
| 96 |
return
|
| 97 |
except Exception as ef:
|
| 98 |
-
await c.send_message(chat,
|
|
|
|
| 99 |
LOGGER.error(ef)
|
| 100 |
LOGGER.error(format_exc())
|
| 101 |
return
|
|
@@ -104,20 +105,21 @@ async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
|
| 104 |
txt += f"Name: {userr.full_name}"
|
| 105 |
txt += f"Mention: {userr.mention}"
|
| 106 |
txt += f"Id: {user}"
|
| 107 |
-
txt += f"Scam: {'True' if
|
| 108 |
if userr.username:
|
| 109 |
-
txt+= f"Username: @{userr.username}"
|
| 110 |
kb = [
|
| 111 |
[
|
| 112 |
-
ikb("Accept",f"accept_joinreq_uest_{user}"),
|
| 113 |
-
ikb("Decline",f"decline_joinreq_uest_{user}")
|
| 114 |
]
|
| 115 |
]
|
| 116 |
-
await c.send_message(chat,txt,reply_markup=ikm(kb))
|
| 117 |
return
|
| 118 |
|
|
|
|
| 119 |
@Gojo.on_callback_query(filters.regex("^accept_joinreq_uest_") | filters.regex("^decline_joinreq_uest_"))
|
| 120 |
-
async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
| 121 |
user_id = q.from_user.id
|
| 122 |
chat = q.message.chat.id
|
| 123 |
try:
|
|
@@ -141,35 +143,37 @@ async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
|
| 141 |
userr = None
|
| 142 |
if data == "accept":
|
| 143 |
try:
|
| 144 |
-
await c.approve_chat_join_request(chat,user)
|
| 145 |
-
await q.answer(f"Accepted join request of the {userr.mention if userr else user}",True)
|
| 146 |
await q.edit_message_text(f"Accepted join request of the {userr.mention if userr else user}")
|
| 147 |
except Exception as ef:
|
| 148 |
-
await c.send_message(chat,
|
|
|
|
| 149 |
LOGGER.error(ef)
|
| 150 |
LOGGER.error(format_exc())
|
| 151 |
|
| 152 |
elif data == "decline":
|
| 153 |
try:
|
| 154 |
-
await c.decline_chat_join_request(chat,user)
|
| 155 |
await q.answer(f"DECLINED: {user}")
|
| 156 |
await q.edit_message_text()
|
| 157 |
except Exception as ef:
|
| 158 |
-
await c.send_message(chat,
|
|
|
|
| 159 |
LOGGER.error(ef)
|
| 160 |
LOGGER.error(format_exc())
|
| 161 |
|
| 162 |
return
|
| 163 |
|
|
|
|
| 164 |
__PLUGIN__ = "auto join"
|
| 165 |
|
| 166 |
__alt_name__ = ["join_request"]
|
| 167 |
|
| 168 |
-
|
| 169 |
__HELP__ = """
|
| 170 |
**Auto join request**
|
| 171 |
|
| 172 |
**Admin commands:**
|
| 173 |
• /joinreq [on | off]: To switch on auto accept join request
|
| 174 |
• /joinreqmode [auto | manual]: `auto` to accept join request automatically and `manual` to get notified when new join request is available
|
| 175 |
-
"""
|
|
|
|
| 34 |
return
|
| 35 |
if len(split) == 1:
|
| 36 |
txt = "**USAGE**\n/joinreq [on | off]"
|
|
|
|
|
|
|
| 37 |
else:
|
| 38 |
yes_no = split[1].lower()
|
| 39 |
if yes_no == "on":
|
|
|
|
| 49 |
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
| 50 |
else:
|
| 51 |
txt = "**USAGE**\n/joinreq [on | off]"
|
| 52 |
+
|
| 53 |
+
await m.reply_text(txt)
|
| 54 |
+
return
|
| 55 |
+
|
| 56 |
|
| 57 |
@Gojo.on_message(command("joinreqmode") & admin_filter)
|
| 58 |
async def join_request_mode(c: Gojo, m: Message):
|
|
|
|
| 68 |
await m.reply_text(u_text)
|
| 69 |
else:
|
| 70 |
auto_manual = split[1]
|
| 71 |
+
if auto_manual not in ["auto", "manual"]:
|
| 72 |
await m.reply_text(u_text)
|
| 73 |
else:
|
| 74 |
+
a_j.update_join_type(m.chat.id, auto_manual)
|
| 75 |
txt = "Changed join request type"
|
| 76 |
await m.reply_text(txt)
|
| 77 |
|
|
|
|
| 91 |
return
|
| 92 |
if join_type == "auto" or user in SUPPORT_STAFF:
|
| 93 |
try:
|
| 94 |
+
await c.approve_chat_join_request(chat, user)
|
| 95 |
await c.send_message(chat, f"Accepted join request of the {userr.mention}")
|
| 96 |
return
|
| 97 |
except Exception as ef:
|
| 98 |
+
await c.send_message(chat,
|
| 99 |
+
f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 100 |
LOGGER.error(ef)
|
| 101 |
LOGGER.error(format_exc())
|
| 102 |
return
|
|
|
|
| 105 |
txt += f"Name: {userr.full_name}"
|
| 106 |
txt += f"Mention: {userr.mention}"
|
| 107 |
txt += f"Id: {user}"
|
| 108 |
+
txt += f"Scam: {'True' if userr.is_scam else 'False'}"
|
| 109 |
if userr.username:
|
| 110 |
+
txt += f"Username: @{userr.username}"
|
| 111 |
kb = [
|
| 112 |
[
|
| 113 |
+
ikb("Accept", f"accept_joinreq_uest_{user}"),
|
| 114 |
+
ikb("Decline", f"decline_joinreq_uest_{user}")
|
| 115 |
]
|
| 116 |
]
|
| 117 |
+
await c.send_message(chat, txt, reply_markup=ikm(kb))
|
| 118 |
return
|
| 119 |
|
| 120 |
+
|
| 121 |
@Gojo.on_callback_query(filters.regex("^accept_joinreq_uest_") | filters.regex("^decline_joinreq_uest_"))
|
| 122 |
+
async def accept_decline_request(c: Gojo, q: CallbackQuery):
|
| 123 |
user_id = q.from_user.id
|
| 124 |
chat = q.message.chat.id
|
| 125 |
try:
|
|
|
|
| 143 |
userr = None
|
| 144 |
if data == "accept":
|
| 145 |
try:
|
| 146 |
+
await c.approve_chat_join_request(chat, user)
|
| 147 |
+
await q.answer(f"Accepted join request of the {userr.mention if userr else user}", True)
|
| 148 |
await q.edit_message_text(f"Accepted join request of the {userr.mention if userr else user}")
|
| 149 |
except Exception as ef:
|
| 150 |
+
await c.send_message(chat,
|
| 151 |
+
f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 152 |
LOGGER.error(ef)
|
| 153 |
LOGGER.error(format_exc())
|
| 154 |
|
| 155 |
elif data == "decline":
|
| 156 |
try:
|
| 157 |
+
await c.decline_chat_join_request(chat, user)
|
| 158 |
await q.answer(f"DECLINED: {user}")
|
| 159 |
await q.edit_message_text()
|
| 160 |
except Exception as ef:
|
| 161 |
+
await c.send_message(chat,
|
| 162 |
+
f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
| 163 |
LOGGER.error(ef)
|
| 164 |
LOGGER.error(format_exc())
|
| 165 |
|
| 166 |
return
|
| 167 |
|
| 168 |
+
|
| 169 |
__PLUGIN__ = "auto join"
|
| 170 |
|
| 171 |
__alt_name__ = ["join_request"]
|
| 172 |
|
|
|
|
| 173 |
__HELP__ = """
|
| 174 |
**Auto join request**
|
| 175 |
|
| 176 |
**Admin commands:**
|
| 177 |
• /joinreq [on | off]: To switch on auto accept join request
|
| 178 |
• /joinreqmode [auto | manual]: `auto` to accept join request automatically and `manual` to get notified when new join request is available
|
| 179 |
+
"""
|
Powers/plugins/bans.py
CHANGED
|
@@ -44,7 +44,7 @@ async def tban_usr(c: Gojo, m: Message):
|
|
| 44 |
await m.reply_text(
|
| 45 |
text="This user is in my support staff, cannot restrict them."
|
| 46 |
)
|
| 47 |
-
|
| 48 |
await m.stop_propagation()
|
| 49 |
|
| 50 |
r_id = m.reply_to_message.id if m.reply_to_message else m.id
|
|
@@ -86,10 +86,11 @@ async def tban_usr(c: Gojo, m: Message):
|
|
| 86 |
await m.chat.ban_member(
|
| 87 |
user_id,
|
| 88 |
until_date=bantime)
|
| 89 |
-
t_t=f"{admin} banned {banned} in <b>{chat_title}</b>!",
|
| 90 |
txt = t_t
|
| 91 |
if type(t_t) is tuple:
|
| 92 |
-
txt = t_t[
|
|
|
|
| 93 |
if reason:
|
| 94 |
txt += f"\n<b>Reason</b>: {reason}"
|
| 95 |
if time_val:
|
|
@@ -114,14 +115,14 @@ async def tban_usr(c: Gojo, m: Message):
|
|
| 114 |
parse_mode=enums.ParseMode.HTML,
|
| 115 |
)
|
| 116 |
except Exception:
|
| 117 |
-
|
| 118 |
await m.reply_text(
|
| 119 |
reply_to_message_id=r_id,
|
| 120 |
text=txt,
|
| 121 |
reply_markup=keyboard,
|
| 122 |
parse_mode=enums.ParseMode.HTML,
|
| 123 |
)
|
| 124 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
| 125 |
# await m.reply_text(txt, reply_markup=keyboard,
|
| 126 |
# reply_to_message_id=r_id)
|
| 127 |
except ChatAdminRequired:
|
|
@@ -175,7 +176,7 @@ async def stban_usr(c: Gojo, m: Message):
|
|
| 175 |
await m.reply_text(
|
| 176 |
text="This user is in my support staff, cannot restrict them."
|
| 177 |
)
|
| 178 |
-
|
| 179 |
await m.stop_propagation()
|
| 180 |
|
| 181 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
@@ -266,7 +267,7 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
| 266 |
|
| 267 |
if user_id in SUPPORT_STAFF:
|
| 268 |
await m.reply_text(text="I am not going to ban one of my support staff")
|
| 269 |
-
|
| 270 |
await m.stop_propagation()
|
| 271 |
|
| 272 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
@@ -329,13 +330,13 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
| 329 |
parse_mode=enums.ParseMode.HTML,
|
| 330 |
)
|
| 331 |
except Exception:
|
| 332 |
-
|
| 333 |
await m.reply_text(
|
| 334 |
txt,
|
| 335 |
reply_markup=keyboard,
|
| 336 |
parse_mode=enums.ParseMode.HTML,
|
| 337 |
)
|
| 338 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
| 339 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
| 340 |
except ChatAdminRequired:
|
| 341 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
@@ -430,7 +431,7 @@ async def kick_usr(c: Gojo, m: Message):
|
|
| 430 |
text=txt,
|
| 431 |
parse_mode=enums.ParseMode.HTML,
|
| 432 |
)
|
| 433 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from KICK_GFIS\n{kickk}")
|
| 434 |
await m.chat.unban_member(user_id)
|
| 435 |
except ChatAdminRequired:
|
| 436 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
@@ -483,7 +484,7 @@ async def skick_usr(c: Gojo, m: Message):
|
|
| 483 |
await m.reply_text(
|
| 484 |
text="This user is in my support staff, cannot restrict them."
|
| 485 |
)
|
| 486 |
-
|
| 487 |
await m.stop_propagation()
|
| 488 |
|
| 489 |
try:
|
|
@@ -587,7 +588,7 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
| 587 |
txt,
|
| 588 |
parse_mode=enums.ParseMode.HTML,
|
| 589 |
)
|
| 590 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from KICK_GFIS\n{kickk}")
|
| 591 |
await m.chat.unban_member(user_id)
|
| 592 |
except ChatAdminRequired:
|
| 593 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
@@ -641,7 +642,7 @@ async def unban_usr(c: Gojo, m: Message):
|
|
| 641 |
|
| 642 |
try:
|
| 643 |
statu = (await m.chat.get_member(user_id)).status
|
| 644 |
-
if statu not in [enums.ChatMemberStatus.BANNED,enums.ChatMemberStatus.RESTRICTED]:
|
| 645 |
await m.reply_text("User is not banned in this chat\nOr using this command as reply to his message")
|
| 646 |
return
|
| 647 |
except Exception as e:
|
|
@@ -813,8 +814,8 @@ async def dban_usr(c: Gojo, m: Message):
|
|
| 813 |
m.chat.id, animation=str(animm), caption=txt, reply_markup=keyboard
|
| 814 |
)
|
| 815 |
except Exception:
|
| 816 |
-
await c.send_message(m.chat.id,txt,enums.ParseMode.HTML,reply_markup=keyboard)
|
| 817 |
-
await c.send_messagea(MESSAGE_DUMP,f"#REMOVE from BAN_GIFS\n{animm}")
|
| 818 |
except ChatAdminRequired:
|
| 819 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 820 |
except PeerIdInvalid:
|
|
@@ -921,14 +922,14 @@ async def ban_usr(c: Gojo, m: Message):
|
|
| 921 |
parse_mode=enums.ParseMode.HTML,
|
| 922 |
)
|
| 923 |
except Exception:
|
| 924 |
-
|
| 925 |
await m.reply_text(
|
| 926 |
reply_to_message_id=r_id,
|
| 927 |
text=txt,
|
| 928 |
reply_markup=keyboard,
|
| 929 |
parse_mode=enums.ParseMode.HTML,
|
| 930 |
)
|
| 931 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
| 932 |
except ChatAdminRequired:
|
| 933 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 934 |
except PeerIdInvalid:
|
|
@@ -988,7 +989,7 @@ async def unbanbutton(c: Gojo, q: CallbackQuery):
|
|
| 988 |
async def kickme(c: Gojo, m: Message):
|
| 989 |
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
| 990 |
try:
|
| 991 |
-
mem = await c.get_chat_member(m.chat.id,m.from_user.id)
|
| 992 |
if mem.status in [enums.ChatMemberStatus.ADMINISTRATOR, enums.ChatMemberStatus.OWNER]:
|
| 993 |
try:
|
| 994 |
await c.promote_chat_member(
|
|
|
|
| 44 |
await m.reply_text(
|
| 45 |
text="This user is in my support staff, cannot restrict them."
|
| 46 |
)
|
| 47 |
+
|
| 48 |
await m.stop_propagation()
|
| 49 |
|
| 50 |
r_id = m.reply_to_message.id if m.reply_to_message else m.id
|
|
|
|
| 86 |
await m.chat.ban_member(
|
| 87 |
user_id,
|
| 88 |
until_date=bantime)
|
| 89 |
+
t_t = f"{admin} banned {banned} in <b>{chat_title}</b>!",
|
| 90 |
txt = t_t
|
| 91 |
if type(t_t) is tuple:
|
| 92 |
+
txt = t_t[
|
| 93 |
+
0] # Done this bcuz idk why t_t is tuple type data. SO now if it is tuple this will get text from it
|
| 94 |
if reason:
|
| 95 |
txt += f"\n<b>Reason</b>: {reason}"
|
| 96 |
if time_val:
|
|
|
|
| 115 |
parse_mode=enums.ParseMode.HTML,
|
| 116 |
)
|
| 117 |
except Exception:
|
| 118 |
+
|
| 119 |
await m.reply_text(
|
| 120 |
reply_to_message_id=r_id,
|
| 121 |
text=txt,
|
| 122 |
reply_markup=keyboard,
|
| 123 |
parse_mode=enums.ParseMode.HTML,
|
| 124 |
)
|
| 125 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
| 126 |
# await m.reply_text(txt, reply_markup=keyboard,
|
| 127 |
# reply_to_message_id=r_id)
|
| 128 |
except ChatAdminRequired:
|
|
|
|
| 176 |
await m.reply_text(
|
| 177 |
text="This user is in my support staff, cannot restrict them."
|
| 178 |
)
|
| 179 |
+
|
| 180 |
await m.stop_propagation()
|
| 181 |
|
| 182 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
|
| 267 |
|
| 268 |
if user_id in SUPPORT_STAFF:
|
| 269 |
await m.reply_text(text="I am not going to ban one of my support staff")
|
| 270 |
+
|
| 271 |
await m.stop_propagation()
|
| 272 |
|
| 273 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
|
| 330 |
parse_mode=enums.ParseMode.HTML,
|
| 331 |
)
|
| 332 |
except Exception:
|
| 333 |
+
|
| 334 |
await m.reply_text(
|
| 335 |
txt,
|
| 336 |
reply_markup=keyboard,
|
| 337 |
parse_mode=enums.ParseMode.HTML,
|
| 338 |
)
|
| 339 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
| 340 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
| 341 |
except ChatAdminRequired:
|
| 342 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
|
| 431 |
text=txt,
|
| 432 |
parse_mode=enums.ParseMode.HTML,
|
| 433 |
)
|
| 434 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from KICK_GFIS\n{kickk}")
|
| 435 |
await m.chat.unban_member(user_id)
|
| 436 |
except ChatAdminRequired:
|
| 437 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
|
| 484 |
await m.reply_text(
|
| 485 |
text="This user is in my support staff, cannot restrict them."
|
| 486 |
)
|
| 487 |
+
|
| 488 |
await m.stop_propagation()
|
| 489 |
|
| 490 |
try:
|
|
|
|
| 588 |
txt,
|
| 589 |
parse_mode=enums.ParseMode.HTML,
|
| 590 |
)
|
| 591 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from KICK_GFIS\n{kickk}")
|
| 592 |
await m.chat.unban_member(user_id)
|
| 593 |
except ChatAdminRequired:
|
| 594 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
|
| 642 |
|
| 643 |
try:
|
| 644 |
statu = (await m.chat.get_member(user_id)).status
|
| 645 |
+
if statu not in [enums.ChatMemberStatus.BANNED, enums.ChatMemberStatus.RESTRICTED]:
|
| 646 |
await m.reply_text("User is not banned in this chat\nOr using this command as reply to his message")
|
| 647 |
return
|
| 648 |
except Exception as e:
|
|
|
|
| 814 |
m.chat.id, animation=str(animm), caption=txt, reply_markup=keyboard
|
| 815 |
)
|
| 816 |
except Exception:
|
| 817 |
+
await c.send_message(m.chat.id, txt, enums.ParseMode.HTML, reply_markup=keyboard)
|
| 818 |
+
await c.send_messagea(MESSAGE_DUMP, f"#REMOVE from BAN_GIFS\n{animm}")
|
| 819 |
except ChatAdminRequired:
|
| 820 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 821 |
except PeerIdInvalid:
|
|
|
|
| 922 |
parse_mode=enums.ParseMode.HTML,
|
| 923 |
)
|
| 924 |
except Exception:
|
| 925 |
+
|
| 926 |
await m.reply_text(
|
| 927 |
reply_to_message_id=r_id,
|
| 928 |
text=txt,
|
| 929 |
reply_markup=keyboard,
|
| 930 |
parse_mode=enums.ParseMode.HTML,
|
| 931 |
)
|
| 932 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
| 933 |
except ChatAdminRequired:
|
| 934 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 935 |
except PeerIdInvalid:
|
|
|
|
| 989 |
async def kickme(c: Gojo, m: Message):
|
| 990 |
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
| 991 |
try:
|
| 992 |
+
mem = await c.get_chat_member(m.chat.id, m.from_user.id)
|
| 993 |
if mem.status in [enums.ChatMemberStatus.ADMINISTRATOR, enums.ChatMemberStatus.OWNER]:
|
| 994 |
try:
|
| 995 |
await c.promote_chat_member(
|
Powers/plugins/birthday.py
CHANGED
|
@@ -8,7 +8,7 @@ from pyrogram.types import InlineKeyboardButton as IKB
|
|
| 8 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
| 9 |
from pyrogram.types import Message
|
| 10 |
|
| 11 |
-
from Powers import BDB_URI, LOGGER
|
| 12 |
from Powers.bot_class import Gojo
|
| 13 |
from Powers.database.chats_db import Chats
|
| 14 |
|
|
@@ -18,8 +18,9 @@ if BDB_URI:
|
|
| 18 |
from Powers.utils.custom_filters import command
|
| 19 |
|
| 20 |
|
| 21 |
-
def give_date(date,form
|
| 22 |
-
return datetime.strptime(date,form).date()
|
|
|
|
| 23 |
|
| 24 |
@Gojo.on_message(command("remember"))
|
| 25 |
async def remember_me(c: Gojo, m: Message):
|
|
@@ -28,10 +29,12 @@ async def remember_me(c: Gojo, m: Message):
|
|
| 28 |
return
|
| 29 |
splited = m.text.split()
|
| 30 |
if len(splited) == 1:
|
| 31 |
-
await m.reply_text(
|
|
|
|
| 32 |
return
|
| 33 |
if len(splited) != 2 and m.reply_to_message:
|
| 34 |
-
await m.reply_text(
|
|
|
|
| 35 |
return
|
| 36 |
DOB = splited[1] if len(splited) == 2 else splited[2]
|
| 37 |
if len(splited) == 2 and m.reply_to_message:
|
|
@@ -42,10 +45,8 @@ async def remember_me(c: Gojo, m: Message):
|
|
| 42 |
if len(DOB) not in [3, 2]:
|
| 43 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
| 44 |
return
|
| 45 |
-
is_correct = False
|
| 46 |
-
if len(DOB)
|
| 47 |
-
is_correct = (len(DOB[2]) == 4)
|
| 48 |
-
if len(DOB[0]) != 2 and len(DOB[1]) !=2 and not is_correct:
|
| 49 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
| 50 |
return
|
| 51 |
try:
|
|
@@ -57,12 +58,12 @@ async def remember_me(c: Gojo, m: Message):
|
|
| 57 |
else:
|
| 58 |
year = "1900"
|
| 59 |
is_year = 0
|
| 60 |
-
DOB = f"{date}/{
|
| 61 |
except ValueError:
|
| 62 |
await m.reply_text("DOB should be numbers only")
|
| 63 |
return
|
| 64 |
|
| 65 |
-
data = {"user_id":user,"dob":DOB,"is_year":is_year}
|
| 66 |
try:
|
| 67 |
if result := bday_info.find_one({"user_id": user}):
|
| 68 |
await m.reply_text("User is already in my database")
|
|
@@ -81,7 +82,8 @@ async def remember_me(c: Gojo, m: Message):
|
|
| 81 |
LOGGER.error(format_exc())
|
| 82 |
return
|
| 83 |
|
| 84 |
-
|
|
|
|
| 85 |
async def who_are_you_again(c: Gojo, m: Message):
|
| 86 |
if not BDB_URI:
|
| 87 |
await m.reply_text("BDB_URI is not configured")
|
|
@@ -89,7 +91,7 @@ async def who_are_you_again(c: Gojo, m: Message):
|
|
| 89 |
user = m.from_user.id
|
| 90 |
try:
|
| 91 |
if result := bday_info.find_one({"user_id": user}):
|
| 92 |
-
bday_info.delete_one({"user_id":user})
|
| 93 |
await m.reply_text("Removed your birthday")
|
| 94 |
else:
|
| 95 |
await m.reply_text("User is not in my database")
|
|
@@ -98,7 +100,8 @@ async def who_are_you_again(c: Gojo, m: Message):
|
|
| 98 |
await m.reply_text(f"Got an error\n{e}")
|
| 99 |
return
|
| 100 |
|
| 101 |
-
|
|
|
|
| 102 |
async def who_is_next(c: Gojo, m: Message):
|
| 103 |
if not BDB_URI:
|
| 104 |
await m.reply_text("BDB_URI is not configured")
|
|
@@ -120,20 +123,22 @@ async def who_is_next(c: Gojo, m: Message):
|
|
| 120 |
break
|
| 121 |
if not users:
|
| 122 |
await xx.delete()
|
| 123 |
-
await m.reply_text(
|
|
|
|
| 124 |
return
|
| 125 |
txt = "🎊 Upcomming Birthdays Are 🎊\n"
|
| 126 |
for i in users:
|
| 127 |
DOB = give_date(i["dob"])
|
| 128 |
dete = date(curr.year, DOB.month, DOB.day)
|
| 129 |
-
leff = (dete - curr).days
|
| 130 |
txt += f"`{i['user_id']}` : {leff} days left\n"
|
| 131 |
txt += "\n\nYou can use /info [user id] to get info about the user"
|
| 132 |
await xx.delete()
|
| 133 |
await m.reply_text(txt)
|
| 134 |
return
|
| 135 |
|
| 136 |
-
|
|
|
|
| 137 |
async def cant_recall_it(c: Gojo, m: Message):
|
| 138 |
if not BDB_URI:
|
| 139 |
await m.reply_text("BDB_URI is not configured")
|
|
@@ -144,27 +149,27 @@ async def cant_recall_it(c: Gojo, m: Message):
|
|
| 144 |
user = m.reply_to_message.from_user.id
|
| 145 |
men = m.reply_to_message.from_user.mention
|
| 146 |
try:
|
| 147 |
-
result = bday_info.find_one({"user_id":user})
|
| 148 |
if not result:
|
| 149 |
await m.reply_text("User is not in my database")
|
| 150 |
return
|
| 151 |
except Exception as e:
|
| 152 |
await m.reply_text(f"Got an error\n{e}")
|
| 153 |
return
|
| 154 |
-
|
| 155 |
-
curr = datetime.now().date()
|
| 156 |
u_dob = give_date(result["dob"])
|
| 157 |
formatted = str(u_dob.strftime('%d' + '%B %Y'))[2:-5]
|
| 158 |
day = int(result["dob"].split('/')[0])
|
| 159 |
suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
|
| 160 |
bday_on = f"{day}{suffix} {formatted}"
|
| 161 |
-
if (u_dob.day,u_dob.month) < (curr.day,curr.month):
|
| 162 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
| 163 |
days_left = (next_b - curr).days
|
| 164 |
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {abs(days_left)}"
|
| 165 |
txt += f"\nBirthday on: {bday_on}"
|
| 166 |
txt += f"\n\nDate of birth: {result['dob']}"
|
| 167 |
-
elif (u_dob.day,u_dob.month) == (curr.day,curr.month):
|
| 168 |
txt = f"Today is {men}'s birthday."
|
| 169 |
else:
|
| 170 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
|
@@ -172,11 +177,12 @@ async def cant_recall_it(c: Gojo, m: Message):
|
|
| 172 |
txt = f"User's birthday is coming🥳\nDays left: {abs(days_left)}"
|
| 173 |
txt += f"\nBirthday on: {bday_on}"
|
| 174 |
txt += f"\n\nDate of birth: {result['dob']}"
|
| 175 |
-
txt+= "\n\n**NOTE**:\nDOB may be wrong if user haven't entered his/her birth year"
|
| 176 |
await m.reply_text(txt)
|
| 177 |
return
|
| 178 |
|
| 179 |
-
|
|
|
|
| 180 |
async def chat_birthday_settings(c: Gojo, m: Message):
|
| 181 |
if not BDB_URI:
|
| 182 |
await m.reply_text("BDB_URI is not configured")
|
|
@@ -185,20 +191,21 @@ async def chat_birthday_settings(c: Gojo, m: Message):
|
|
| 185 |
await m.reply_text("Use in groups")
|
| 186 |
return
|
| 187 |
chats = m.chat.id
|
| 188 |
-
c_in = bday_cinfo.find_one({"chat_id":chats})
|
| 189 |
kb = IKM(
|
| 190 |
[
|
| 191 |
[
|
| 192 |
-
IKB(f"{'No' if c_in else 'Yes'}",f"switchh_{'no' if c_in else 'yes'}"),
|
| 193 |
IKB("Close", "f_close")
|
| 194 |
]
|
| 195 |
]
|
| 196 |
)
|
| 197 |
-
await m.reply_text("Do you want to wish members for their birthday in the group?",reply_markup=kb)
|
| 198 |
return
|
| 199 |
|
|
|
|
| 200 |
@Gojo.on_callback_query(filters.regex(r"^switchh_(yes|no)$"))
|
| 201 |
-
async def switch_on_off(c:Gojo, q: CallbackQuery):
|
| 202 |
user = (await q.message.chat.get_member(q.from_user.id)).status
|
| 203 |
await q.message.chat.get_member(q.from_user.id)
|
| 204 |
if user not in [ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
|
@@ -206,16 +213,16 @@ async def switch_on_off(c:Gojo, q: CallbackQuery):
|
|
| 206 |
return
|
| 207 |
data = q.data.split("_")[1]
|
| 208 |
chats = q.message.chat.id
|
| 209 |
-
query = {"chat_id":chats}
|
| 210 |
if data == "yes":
|
| 211 |
bday_cinfo.delete_one(query)
|
| 212 |
elif data == "no":
|
| 213 |
bday_cinfo.insert_one(query)
|
| 214 |
-
await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",
|
|
|
|
| 215 |
return
|
| 216 |
|
| 217 |
|
| 218 |
-
|
| 219 |
__PLUGIN__ = "birthday"
|
| 220 |
|
| 221 |
__HELP__ = """
|
|
|
|
| 8 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
| 9 |
from pyrogram.types import Message
|
| 10 |
|
| 11 |
+
from Powers import BDB_URI, LOGGER
|
| 12 |
from Powers.bot_class import Gojo
|
| 13 |
from Powers.database.chats_db import Chats
|
| 14 |
|
|
|
|
| 18 |
from Powers.utils.custom_filters import command
|
| 19 |
|
| 20 |
|
| 21 |
+
def give_date(date, form="%d/%m/%Y"):
|
| 22 |
+
return datetime.strptime(date, form).date()
|
| 23 |
+
|
| 24 |
|
| 25 |
@Gojo.on_message(command("remember"))
|
| 26 |
async def remember_me(c: Gojo, m: Message):
|
|
|
|
| 29 |
return
|
| 30 |
splited = m.text.split()
|
| 31 |
if len(splited) == 1:
|
| 32 |
+
await m.reply_text(
|
| 33 |
+
"**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
| 34 |
return
|
| 35 |
if len(splited) != 2 and m.reply_to_message:
|
| 36 |
+
await m.reply_text(
|
| 37 |
+
"**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
| 38 |
return
|
| 39 |
DOB = splited[1] if len(splited) == 2 else splited[2]
|
| 40 |
if len(splited) == 2 and m.reply_to_message:
|
|
|
|
| 45 |
if len(DOB) not in [3, 2]:
|
| 46 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
| 47 |
return
|
| 48 |
+
is_correct = (len(DOB[2]) == 4) if len(DOB) == 3 else False
|
| 49 |
+
if len(DOB[0]) != 2 and len(DOB[1]) != 2 and not is_correct:
|
|
|
|
|
|
|
| 50 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
| 51 |
return
|
| 52 |
try:
|
|
|
|
| 58 |
else:
|
| 59 |
year = "1900"
|
| 60 |
is_year = 0
|
| 61 |
+
DOB = f"{date}/{month}/{str(year)}"
|
| 62 |
except ValueError:
|
| 63 |
await m.reply_text("DOB should be numbers only")
|
| 64 |
return
|
| 65 |
|
| 66 |
+
data = {"user_id": user, "dob": DOB, "is_year": is_year}
|
| 67 |
try:
|
| 68 |
if result := bday_info.find_one({"user_id": user}):
|
| 69 |
await m.reply_text("User is already in my database")
|
|
|
|
| 82 |
LOGGER.error(format_exc())
|
| 83 |
return
|
| 84 |
|
| 85 |
+
|
| 86 |
+
@Gojo.on_message(command(["removebday", "rmbday"]))
|
| 87 |
async def who_are_you_again(c: Gojo, m: Message):
|
| 88 |
if not BDB_URI:
|
| 89 |
await m.reply_text("BDB_URI is not configured")
|
|
|
|
| 91 |
user = m.from_user.id
|
| 92 |
try:
|
| 93 |
if result := bday_info.find_one({"user_id": user}):
|
| 94 |
+
bday_info.delete_one({"user_id": user})
|
| 95 |
await m.reply_text("Removed your birthday")
|
| 96 |
else:
|
| 97 |
await m.reply_text("User is not in my database")
|
|
|
|
| 100 |
await m.reply_text(f"Got an error\n{e}")
|
| 101 |
return
|
| 102 |
|
| 103 |
+
|
| 104 |
+
@Gojo.on_message(command(["nextbdays", "nbdays", "birthdays", "bdays"]))
|
| 105 |
async def who_is_next(c: Gojo, m: Message):
|
| 106 |
if not BDB_URI:
|
| 107 |
await m.reply_text("BDB_URI is not configured")
|
|
|
|
| 123 |
break
|
| 124 |
if not users:
|
| 125 |
await xx.delete()
|
| 126 |
+
await m.reply_text(
|
| 127 |
+
"There are no upcoming birthdays of any user in this chat:/\nEither all the birthdays are passed or no user from this chat have registered their birthday")
|
| 128 |
return
|
| 129 |
txt = "🎊 Upcomming Birthdays Are 🎊\n"
|
| 130 |
for i in users:
|
| 131 |
DOB = give_date(i["dob"])
|
| 132 |
dete = date(curr.year, DOB.month, DOB.day)
|
| 133 |
+
leff = (dete - curr).days
|
| 134 |
txt += f"`{i['user_id']}` : {leff} days left\n"
|
| 135 |
txt += "\n\nYou can use /info [user id] to get info about the user"
|
| 136 |
await xx.delete()
|
| 137 |
await m.reply_text(txt)
|
| 138 |
return
|
| 139 |
|
| 140 |
+
|
| 141 |
+
@Gojo.on_message(command(["getbday", "gbday", "mybirthday", "mybday"]))
|
| 142 |
async def cant_recall_it(c: Gojo, m: Message):
|
| 143 |
if not BDB_URI:
|
| 144 |
await m.reply_text("BDB_URI is not configured")
|
|
|
|
| 149 |
user = m.reply_to_message.from_user.id
|
| 150 |
men = m.reply_to_message.from_user.mention
|
| 151 |
try:
|
| 152 |
+
result = bday_info.find_one({"user_id": user})
|
| 153 |
if not result:
|
| 154 |
await m.reply_text("User is not in my database")
|
| 155 |
return
|
| 156 |
except Exception as e:
|
| 157 |
await m.reply_text(f"Got an error\n{e}")
|
| 158 |
return
|
| 159 |
+
|
| 160 |
+
curr = datetime.now().date()
|
| 161 |
u_dob = give_date(result["dob"])
|
| 162 |
formatted = str(u_dob.strftime('%d' + '%B %Y'))[2:-5]
|
| 163 |
day = int(result["dob"].split('/')[0])
|
| 164 |
suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
|
| 165 |
bday_on = f"{day}{suffix} {formatted}"
|
| 166 |
+
if (u_dob.day, u_dob.month) < (curr.day, curr.month):
|
| 167 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
| 168 |
days_left = (next_b - curr).days
|
| 169 |
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {abs(days_left)}"
|
| 170 |
txt += f"\nBirthday on: {bday_on}"
|
| 171 |
txt += f"\n\nDate of birth: {result['dob']}"
|
| 172 |
+
elif (u_dob.day, u_dob.month) == (curr.day, curr.month):
|
| 173 |
txt = f"Today is {men}'s birthday."
|
| 174 |
else:
|
| 175 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
|
|
|
| 177 |
txt = f"User's birthday is coming🥳\nDays left: {abs(days_left)}"
|
| 178 |
txt += f"\nBirthday on: {bday_on}"
|
| 179 |
txt += f"\n\nDate of birth: {result['dob']}"
|
| 180 |
+
txt += "\n\n**NOTE**:\nDOB may be wrong if user haven't entered his/her birth year"
|
| 181 |
await m.reply_text(txt)
|
| 182 |
return
|
| 183 |
|
| 184 |
+
|
| 185 |
+
@Gojo.on_message(command(["settingbday", "sbday"]))
|
| 186 |
async def chat_birthday_settings(c: Gojo, m: Message):
|
| 187 |
if not BDB_URI:
|
| 188 |
await m.reply_text("BDB_URI is not configured")
|
|
|
|
| 191 |
await m.reply_text("Use in groups")
|
| 192 |
return
|
| 193 |
chats = m.chat.id
|
| 194 |
+
c_in = bday_cinfo.find_one({"chat_id": chats})
|
| 195 |
kb = IKM(
|
| 196 |
[
|
| 197 |
[
|
| 198 |
+
IKB(f"{'No' if c_in else 'Yes'}", f"switchh_{'no' if c_in else 'yes'}"),
|
| 199 |
IKB("Close", "f_close")
|
| 200 |
]
|
| 201 |
]
|
| 202 |
)
|
| 203 |
+
await m.reply_text("Do you want to wish members for their birthday in the group?", reply_markup=kb)
|
| 204 |
return
|
| 205 |
|
| 206 |
+
|
| 207 |
@Gojo.on_callback_query(filters.regex(r"^switchh_(yes|no)$"))
|
| 208 |
+
async def switch_on_off(c: Gojo, q: CallbackQuery):
|
| 209 |
user = (await q.message.chat.get_member(q.from_user.id)).status
|
| 210 |
await q.message.chat.get_member(q.from_user.id)
|
| 211 |
if user not in [ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
|
|
|
| 213 |
return
|
| 214 |
data = q.data.split("_")[1]
|
| 215 |
chats = q.message.chat.id
|
| 216 |
+
query = {"chat_id": chats}
|
| 217 |
if data == "yes":
|
| 218 |
bday_cinfo.delete_one(query)
|
| 219 |
elif data == "no":
|
| 220 |
bday_cinfo.insert_one(query)
|
| 221 |
+
await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",
|
| 222 |
+
reply_markup=IKM([[IKB("Close", "f_close")]]))
|
| 223 |
return
|
| 224 |
|
| 225 |
|
|
|
|
| 226 |
__PLUGIN__ = "birthday"
|
| 227 |
|
| 228 |
__HELP__ = """
|
Powers/plugins/blacklist.py
CHANGED
|
@@ -4,7 +4,6 @@ from pyrogram import filters
|
|
| 4 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 5 |
from pyrogram.types import CallbackQuery, Message
|
| 6 |
|
| 7 |
-
from Powers import LOGGER
|
| 8 |
from Powers.bot_class import Gojo
|
| 9 |
from Powers.database.blacklist_db import Blacklist
|
| 10 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
|
@@ -53,13 +52,13 @@ async def add_blacklist(_, m: Message):
|
|
| 53 |
|
| 54 |
if already_added_words:
|
| 55 |
rep_text = (
|
| 56 |
-
|
| 57 |
-
|
| 58 |
)
|
| 59 |
trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
| 60 |
await m.reply_text(
|
| 61 |
text=f"Added <code>{trigger}</code> in blacklist words!"
|
| 62 |
-
|
| 63 |
)
|
| 64 |
|
| 65 |
await m.stop_propagation()
|
|
@@ -110,13 +109,13 @@ async def rm_blacklist(_, m: Message):
|
|
| 110 |
|
| 111 |
if non_found_words:
|
| 112 |
rep_text = (
|
| 113 |
-
|
| 114 |
-
|
| 115 |
|
| 116 |
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
| 117 |
await m.reply_text(
|
| 118 |
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
| 119 |
-
|
| 120 |
)
|
| 121 |
|
| 122 |
await m.stop_propagation()
|
|
@@ -134,8 +133,8 @@ async def set_bl_action(_, m: Message):
|
|
| 134 |
if action not in valid_actions:
|
| 135 |
await m.reply_text(
|
| 136 |
(
|
| 137 |
-
|
| 138 |
-
|
| 139 |
),
|
| 140 |
)
|
| 141 |
|
|
|
|
| 4 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 5 |
from pyrogram.types import CallbackQuery, Message
|
| 6 |
|
|
|
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
from Powers.database.blacklist_db import Blacklist
|
| 9 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
|
|
|
| 52 |
|
| 53 |
if already_added_words:
|
| 54 |
rep_text = (
|
| 55 |
+
", ".join([f"<code>{i}</code>" for i in bl_words])
|
| 56 |
+
+ " already added in blacklist, skipped them!"
|
| 57 |
)
|
| 58 |
trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
| 59 |
await m.reply_text(
|
| 60 |
text=f"Added <code>{trigger}</code> in blacklist words!"
|
| 61 |
+
+ (f"\n{rep_text}" if rep_text else ""),
|
| 62 |
)
|
| 63 |
|
| 64 |
await m.stop_propagation()
|
|
|
|
| 109 |
|
| 110 |
if non_found_words:
|
| 111 |
rep_text = (
|
| 112 |
+
"Could not find " + ", ".join(f"<code>{i}</code>" for i in non_found_words)
|
| 113 |
+
) + " in blcklisted words, skipped them."
|
| 114 |
|
| 115 |
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
| 116 |
await m.reply_text(
|
| 117 |
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
| 118 |
+
+ (f"\n{rep_text}" if rep_text else ""),
|
| 119 |
)
|
| 120 |
|
| 121 |
await m.stop_propagation()
|
|
|
|
| 133 |
if action not in valid_actions:
|
| 134 |
await m.reply_text(
|
| 135 |
(
|
| 136 |
+
"Choose a valid blacklist action from "
|
| 137 |
+
+ ", ".join(f"<code>{i}</code>" for i in valid_actions)
|
| 138 |
),
|
| 139 |
)
|
| 140 |
|
Powers/plugins/captcha.py
CHANGED
|
@@ -3,7 +3,6 @@ from random import choice, shuffle
|
|
| 3 |
from traceback import format_exc
|
| 4 |
from typing import List
|
| 5 |
|
| 6 |
-
import pyrogram
|
| 7 |
from pyrogram import filters
|
| 8 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 9 |
from pyrogram.enums import ParseMode as PM
|
|
@@ -53,7 +52,8 @@ async def set_captcha_mode(c: Gojo, m: Message):
|
|
| 53 |
if len(split) == 1:
|
| 54 |
if curr := captcha.get_captcha(m.chat.id):
|
| 55 |
capatcha_type = curr["captcha_type"]
|
| 56 |
-
await m.reply_text(
|
|
|
|
| 57 |
else:
|
| 58 |
await m.reply_text("Captcha verification is off for the current chat")
|
| 59 |
else:
|
|
@@ -137,7 +137,7 @@ async def captcha_codes_check(c: Gojo, q: CallbackQuery):
|
|
| 137 |
reply_markup=keyboard,
|
| 138 |
parse_mode=PM.HTML,
|
| 139 |
)
|
| 140 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
| 141 |
c_data.remove_cap_data(chat, user)
|
| 142 |
c_data.del_message_id(q.message.chat.id, user)
|
| 143 |
else:
|
|
@@ -192,7 +192,7 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
| 192 |
continue
|
| 193 |
|
| 194 |
if not is_already:
|
| 195 |
-
captcha_type = "image"
|
| 196 |
if captcha_type == "image":
|
| 197 |
img, code = await get_image_captcha(chat, user.id)
|
| 198 |
cap = f"Please {user.mention} please choose the correct code from the one given bellow\nYou have three tries if you get all three wrong u will be banned from the chat.\nTries left: 3"
|
|
@@ -210,19 +210,19 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
| 210 |
kb = ikm(
|
| 211 |
[
|
| 212 |
[
|
| 213 |
-
IKB(rand[0], ini+rand[0])
|
| 214 |
],
|
| 215 |
[
|
| 216 |
-
IKB(rand[1], ini+rand[1])
|
| 217 |
],
|
| 218 |
[
|
| 219 |
-
IKB(rand[2], ini+rand[2])
|
| 220 |
],
|
| 221 |
[
|
| 222 |
-
IKB(rand[3], ini+rand[3])
|
| 223 |
],
|
| 224 |
[
|
| 225 |
-
IKB(rand[4], ini+rand[4])
|
| 226 |
]
|
| 227 |
]
|
| 228 |
)
|
|
|
|
| 3 |
from traceback import format_exc
|
| 4 |
from typing import List
|
| 5 |
|
|
|
|
| 6 |
from pyrogram import filters
|
| 7 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 8 |
from pyrogram.enums import ParseMode as PM
|
|
|
|
| 52 |
if len(split) == 1:
|
| 53 |
if curr := captcha.get_captcha(m.chat.id):
|
| 54 |
capatcha_type = curr["captcha_type"]
|
| 55 |
+
await m.reply_text(
|
| 56 |
+
f"Current captcha verification methode is {capatcha_type}\nAvailable methodes:\n■ qr\n■ image")
|
| 57 |
else:
|
| 58 |
await m.reply_text("Captcha verification is off for the current chat")
|
| 59 |
else:
|
|
|
|
| 137 |
reply_markup=keyboard,
|
| 138 |
parse_mode=PM.HTML,
|
| 139 |
)
|
| 140 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
| 141 |
c_data.remove_cap_data(chat, user)
|
| 142 |
c_data.del_message_id(q.message.chat.id, user)
|
| 143 |
else:
|
|
|
|
| 192 |
continue
|
| 193 |
|
| 194 |
if not is_already:
|
| 195 |
+
captcha_type = "image" # I am not going to apply qr captcha in this update
|
| 196 |
if captcha_type == "image":
|
| 197 |
img, code = await get_image_captcha(chat, user.id)
|
| 198 |
cap = f"Please {user.mention} please choose the correct code from the one given bellow\nYou have three tries if you get all three wrong u will be banned from the chat.\nTries left: 3"
|
|
|
|
| 210 |
kb = ikm(
|
| 211 |
[
|
| 212 |
[
|
| 213 |
+
IKB(rand[0], ini + rand[0])
|
| 214 |
],
|
| 215 |
[
|
| 216 |
+
IKB(rand[1], ini + rand[1])
|
| 217 |
],
|
| 218 |
[
|
| 219 |
+
IKB(rand[2], ini + rand[2])
|
| 220 |
],
|
| 221 |
[
|
| 222 |
+
IKB(rand[3], ini + rand[3])
|
| 223 |
],
|
| 224 |
[
|
| 225 |
+
IKB(rand[4], ini + rand[4])
|
| 226 |
]
|
| 227 |
]
|
| 228 |
)
|
Powers/plugins/chat_blacklist.py
CHANGED
|
@@ -87,8 +87,8 @@ async def list_blacklist_chats(_, m: Message):
|
|
| 87 |
if bl_chats := db.list_all_chats():
|
| 88 |
txt = (
|
| 89 |
(
|
| 90 |
-
|
| 91 |
-
|
| 92 |
),
|
| 93 |
)
|
| 94 |
|
|
@@ -100,8 +100,6 @@ async def list_blacklist_chats(_, m: Message):
|
|
| 100 |
|
| 101 |
__PLUGIN__ = "Chat blacklist"
|
| 102 |
|
| 103 |
-
|
| 104 |
-
|
| 105 |
__HELP__ = """
|
| 106 |
**Chat blacklist**
|
| 107 |
|
|
@@ -109,4 +107,4 @@ __HELP__ = """
|
|
| 109 |
• /blchat [space separated id or username of chats]: Add chats to black list if given or the current chat.
|
| 110 |
• /rmblchat [space separated id or username of chats]: Remove chats from black list if given or the current chat.
|
| 111 |
• /blchats: Give the list of blacklisted chats
|
| 112 |
-
"""
|
|
|
|
| 87 |
if bl_chats := db.list_all_chats():
|
| 88 |
txt = (
|
| 89 |
(
|
| 90 |
+
"These Chats are Blacklisted:\n"
|
| 91 |
+
+ "\n".join(f"<code>{i}</code>" for i in bl_chats)
|
| 92 |
),
|
| 93 |
)
|
| 94 |
|
|
|
|
| 100 |
|
| 101 |
__PLUGIN__ = "Chat blacklist"
|
| 102 |
|
|
|
|
|
|
|
| 103 |
__HELP__ = """
|
| 104 |
**Chat blacklist**
|
| 105 |
|
|
|
|
| 107 |
• /blchat [space separated id or username of chats]: Add chats to black list if given or the current chat.
|
| 108 |
• /rmblchat [space separated id or username of chats]: Remove chats from black list if given or the current chat.
|
| 109 |
• /blchats: Give the list of blacklisted chats
|
| 110 |
+
"""
|
Powers/plugins/dev.py
CHANGED
|
@@ -8,7 +8,6 @@ from sys import executable
|
|
| 8 |
from time import gmtime, strftime, time
|
| 9 |
from traceback import format_exc
|
| 10 |
|
| 11 |
-
from pyrogram import filters
|
| 12 |
from pyrogram.errors import (ChannelInvalid, ChannelPrivate, ChatAdminRequired,
|
| 13 |
EntityBoundsInvalid, FloodWait, MessageTooLong,
|
| 14 |
PeerIdInvalid, RPCError)
|
|
@@ -31,15 +30,16 @@ from Powers.utils.parser import mention_markdown
|
|
| 31 |
|
| 32 |
|
| 33 |
def can_change_type(curr, to_user):
|
| 34 |
-
if curr == "dev" and to_user in ["whitelist","sudo"]:
|
| 35 |
return True
|
| 36 |
elif curr == "sudo" and to_user == "whitelist":
|
| 37 |
return True
|
| 38 |
else:
|
| 39 |
return False
|
| 40 |
|
|
|
|
| 41 |
@Gojo.on_message(command(["addsupport"]))
|
| 42 |
-
async def add_support(c: Gojo, m:Message):
|
| 43 |
support = SUPPORTS()
|
| 44 |
curr_user = support.get_support_type(m.from_user.id)
|
| 45 |
if not curr_user:
|
|
@@ -58,7 +58,7 @@ async def add_support(c: Gojo, m:Message):
|
|
| 58 |
except IndexError:
|
| 59 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
| 60 |
return
|
| 61 |
-
if to not in ["dev","sudo","whitelist"]:
|
| 62 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
| 63 |
return
|
| 64 |
if m.from_user.id == int(OWNER_ID):
|
|
@@ -68,14 +68,15 @@ async def add_support(c: Gojo, m:Message):
|
|
| 68 |
kb = IKM(
|
| 69 |
[
|
| 70 |
[
|
| 71 |
-
IKB("Yes",f"change_support_type:{to}"),
|
| 72 |
-
IKB("No","change_support_type:no")
|
| 73 |
]
|
| 74 |
]
|
| 75 |
)
|
| 76 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
|
|
|
| 77 |
else:
|
| 78 |
-
support.insert_support_user(userr,to)
|
| 79 |
if to == "dev":
|
| 80 |
DEV_USERS.add(userr)
|
| 81 |
elif to == "sudo":
|
|
@@ -91,14 +92,15 @@ async def add_support(c: Gojo, m:Message):
|
|
| 91 |
kb = IKM(
|
| 92 |
[
|
| 93 |
[
|
| 94 |
-
IKB("Yes",f"change_support_type:{to}"),
|
| 95 |
-
IKB("No","change_support_type:no")
|
| 96 |
]
|
| 97 |
]
|
| 98 |
)
|
| 99 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
|
|
|
| 100 |
else:
|
| 101 |
-
support.insert_support_user(userr,to)
|
| 102 |
await m.reply_text(f"This user is now a {to} user")
|
| 103 |
else:
|
| 104 |
await m.reply_text("Sorry you can't do it")
|
|
@@ -106,7 +108,7 @@ async def add_support(c: Gojo, m:Message):
|
|
| 106 |
elif len(split) >= 3:
|
| 107 |
user = split[1]
|
| 108 |
try:
|
| 109 |
-
userr,_,_ = extract_user(user)
|
| 110 |
except Exception:
|
| 111 |
await m.reply_text("Tell the user to start me first")
|
| 112 |
return
|
|
@@ -114,9 +116,10 @@ async def add_support(c: Gojo, m:Message):
|
|
| 114 |
try:
|
| 115 |
to = m.command[2].lower()
|
| 116 |
except IndexError:
|
| 117 |
-
await m.reply_text(
|
|
|
|
| 118 |
return
|
| 119 |
-
if to not in ["dev","sudo","whitelist"]:
|
| 120 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
| 121 |
return
|
| 122 |
if m.from_user.id == int(OWNER_ID):
|
|
@@ -126,14 +129,15 @@ async def add_support(c: Gojo, m:Message):
|
|
| 126 |
kb = IKM(
|
| 127 |
[
|
| 128 |
[
|
| 129 |
-
IKB("Yes",f"change_support_type:{to}"),
|
| 130 |
-
IKB("No","change_support_type:no")
|
| 131 |
]
|
| 132 |
]
|
| 133 |
)
|
| 134 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
|
|
|
| 135 |
else:
|
| 136 |
-
support.insert_support_user(userr,to)
|
| 137 |
await m.reply_text(f"This user is now a {to} user")
|
| 138 |
return
|
| 139 |
if can_do := can_change_type(curr_user, to):
|
|
@@ -143,19 +147,21 @@ async def add_support(c: Gojo, m:Message):
|
|
| 143 |
kb = IKM(
|
| 144 |
[
|
| 145 |
[
|
| 146 |
-
IKB("Yes",f"change_support_type:{to}"),
|
| 147 |
-
IKB("No","change_support_type:no")
|
| 148 |
]
|
| 149 |
]
|
| 150 |
)
|
| 151 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
|
|
|
| 152 |
else:
|
| 153 |
-
support.insert_support_user(userr,to)
|
| 154 |
await m.reply_text(f"This user is now a {to} user")
|
| 155 |
else:
|
| 156 |
await m.reply_text("Sorry you can't do it")
|
| 157 |
return
|
| 158 |
|
|
|
|
| 159 |
@Gojo.on_message(command("rmsupport"))
|
| 160 |
async def rm_support(c: Gojo, m: Message):
|
| 161 |
support = SUPPORTS()
|
|
@@ -175,7 +181,7 @@ async def rm_support(c: Gojo, m: Message):
|
|
| 175 |
curr = int(split[1])
|
| 176 |
except Exception:
|
| 177 |
try:
|
| 178 |
-
curr,_,_ = extract_user(m)
|
| 179 |
except Exception:
|
| 180 |
await m.reply_text("Dunno who u r talking abt")
|
| 181 |
return
|
|
@@ -183,7 +189,7 @@ async def rm_support(c: Gojo, m: Message):
|
|
| 183 |
await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
|
| 184 |
return
|
| 185 |
to_user = support.get_support_type(curr)
|
| 186 |
-
can_user = can_change_type(curr_user,to_user)
|
| 187 |
if m.from_user.id == int(OWNER_ID) or can_user:
|
| 188 |
support.delete_support_user(curr)
|
| 189 |
DEV_USERS.discard(curr)
|
|
@@ -194,6 +200,7 @@ async def rm_support(c: Gojo, m: Message):
|
|
| 194 |
await m.reply_text("Sorry you can't do that...")
|
| 195 |
return
|
| 196 |
|
|
|
|
| 197 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
| 198 |
async def ping(_, m: Message):
|
| 199 |
start = time()
|
|
@@ -202,18 +209,20 @@ async def ping(_, m: Message):
|
|
| 202 |
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
|
| 203 |
return
|
| 204 |
|
|
|
|
| 205 |
"""
|
| 206 |
|
| 207 |
['Metadata-Version', 'Name', 'Version', 'Summary', 'Home-page', 'Author', 'Author-email', 'License', 'Download-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Keywords', 'Platform', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Requires-Python', 'Description-Content-Type', 'License-File', 'License-File', 'License-File', 'Requires-Dist', 'Requires-Dist', 'Description']
|
| 208 |
|
| 209 |
"""
|
| 210 |
|
|
|
|
| 211 |
@Gojo.on_message(command(["minfo", "moduleinfo"], dev_cmd=True))
|
| 212 |
async def check_module_info(_, m: Message):
|
| 213 |
if len(m.command) != 2:
|
| 214 |
await m.reply_text("**USAGE**\n/minfo [module name]")
|
| 215 |
return
|
| 216 |
-
|
| 217 |
module = m.command[-1]
|
| 218 |
|
| 219 |
try:
|
|
@@ -221,7 +230,7 @@ async def check_module_info(_, m: Message):
|
|
| 221 |
except PackageNotFoundError:
|
| 222 |
await m.reply_text(f"No module found with name {module}")
|
| 223 |
return
|
| 224 |
-
|
| 225 |
name = minfo["Name"]
|
| 226 |
version = minfo["Version"]
|
| 227 |
summary = minfo["Summary"]
|
|
@@ -247,7 +256,6 @@ Here are the info about the module **{name}**
|
|
| 247 |
await m.reply_text(txt, disable_web_page_preview=True)
|
| 248 |
return
|
| 249 |
|
| 250 |
-
|
| 251 |
|
| 252 |
@Gojo.on_message(command("logs", dev_cmd=True))
|
| 253 |
async def send_log(c: Gojo, m: Message):
|
|
@@ -289,6 +297,7 @@ async def neofetch_stats(_, m: Message):
|
|
| 289 |
await m.delete()
|
| 290 |
return
|
| 291 |
|
|
|
|
| 292 |
HARMFUL = [
|
| 293 |
"base64",
|
| 294 |
"bash",
|
|
@@ -306,7 +315,7 @@ HARMFUL = [
|
|
| 306 |
"SSH_CLIENT",
|
| 307 |
"SSH_CONNECTION"
|
| 308 |
"SSH"
|
| 309 |
-
|
| 310 |
]
|
| 311 |
|
| 312 |
|
|
@@ -326,9 +335,11 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
| 326 |
await c.send_message(
|
| 327 |
MESSAGE_DUMP,
|
| 328 |
f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
|
| 329 |
-
|
| 330 |
return
|
| 331 |
-
if m.reply_to_message and m.reply_to_message.document and (m.reply_to_message.document.mime_type.split("/")[
|
|
|
|
|
|
|
| 332 |
await sm.delete()
|
| 333 |
await m.reply_text("Loading external plugin is prohibited")
|
| 334 |
return
|
|
@@ -362,8 +373,8 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
| 362 |
for i in evaluation.split(None):
|
| 363 |
ev = i.strip()
|
| 364 |
if (
|
| 365 |
-
|
| 366 |
-
|
| 367 |
) and m.from_user.id != OWNER_ID:
|
| 368 |
evaluation = "Bhaag ja bsdk"
|
| 369 |
await c.send_message(
|
|
@@ -418,8 +429,6 @@ async def aexec(code, c, m):
|
|
| 418 |
return await locals()["__aexec"](c, m)
|
| 419 |
|
| 420 |
|
| 421 |
-
|
| 422 |
-
|
| 423 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
| 424 |
async def execution(c: Gojo, m: Message):
|
| 425 |
protect = BOT_TOKEN.split(":")
|
|
@@ -443,9 +452,9 @@ async def execution(c: Gojo, m: Message):
|
|
| 443 |
out = o
|
| 444 |
xxx = o.split()
|
| 445 |
for OwO in xxx:
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
for x in xxx:
|
| 450 |
xx = x.split("=")
|
| 451 |
if xx and xx[0] in HARMFUL and m.from_user.id != OWNER_ID:
|
|
@@ -481,38 +490,41 @@ async def execution(c: Gojo, m: Message):
|
|
| 481 |
await sm.delete()
|
| 482 |
return
|
| 483 |
|
| 484 |
-
|
|
|
|
| 485 |
runtime = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
|
| 486 |
LOGGER.info("Uploading logs before stopping...!\n")
|
| 487 |
-
|
| 488 |
await c.send_document(
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
if MESSAGE_DUMP:
|
| 496 |
# LOG_CHANNEL is not necessary
|
| 497 |
await c.send_document(
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
MongoDB.close()
|
| 503 |
LOGGER.info(
|
| 504 |
-
|
| 505 |
Logs have been uploaded to the MESSAGE_DUMP Group!
|
| 506 |
Runtime: {runtime}s\n
|
| 507 |
""",
|
| 508 |
-
|
| 509 |
return
|
| 510 |
|
|
|
|
| 511 |
@Gojo.on_message(command(["restart", "update"], owner_cmd=True))
|
| 512 |
-
async def restart_the_bot(c:Gojo,m:Message):
|
| 513 |
try:
|
| 514 |
cmds = m.command
|
| 515 |
-
await m.reply_text(
|
|
|
|
| 516 |
if cmds[0] == "update":
|
| 517 |
try:
|
| 518 |
out = subp.check_output(["git", "pull"]).decode("UTF-8")
|
|
@@ -522,7 +534,7 @@ async def restart_the_bot(c:Gojo,m:Message):
|
|
| 522 |
except Exception as e:
|
| 523 |
return await m.reply_text(str(e))
|
| 524 |
m = await m.reply_text("**Updated with main branch, restarting now.**")
|
| 525 |
-
await stop_and_send_logger(c,True)
|
| 526 |
if cmds[0] == "restart":
|
| 527 |
await stop_and_send_logger(c)
|
| 528 |
execvp(executable, [executable, "-m", "Powers"])
|
|
@@ -532,6 +544,7 @@ async def restart_the_bot(c:Gojo,m:Message):
|
|
| 532 |
LOGGER.error(format_exc())
|
| 533 |
return
|
| 534 |
|
|
|
|
| 535 |
@Gojo.on_message(command("chatlist", dev_cmd=True))
|
| 536 |
async def chats(c: Gojo, m: Message):
|
| 537 |
exmsg = await m.reply_text(text="Exporting Charlist...")
|
|
@@ -641,7 +654,8 @@ async def chat_broadcast(c: Gojo, m: Message):
|
|
| 641 |
|
| 642 |
return
|
| 643 |
|
| 644 |
-
|
|
|
|
| 645 |
async def forward_type_broadcast(c: Gojo, m: Message):
|
| 646 |
repl = m.reply_to_message
|
| 647 |
if not repl:
|
|
@@ -681,7 +695,7 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
| 681 |
await sleep(0.1)
|
| 682 |
except Exception:
|
| 683 |
failed += 1
|
| 684 |
-
txt = f"Broadcasted message to {total-failed} peers out of {total}\nFailed to broadcast message to {failed} peers"
|
| 685 |
if not failed:
|
| 686 |
txt = f"Broadcasted message to {total} peers"
|
| 687 |
await m.reply_text(txt)
|
|
@@ -692,10 +706,8 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
| 692 |
return
|
| 693 |
|
| 694 |
|
| 695 |
-
|
| 696 |
__PLUGIN__ = "devs"
|
| 697 |
|
| 698 |
-
|
| 699 |
__HELP__ = """
|
| 700 |
**DEV and SUDOERS commands**
|
| 701 |
|
|
|
|
| 8 |
from time import gmtime, strftime, time
|
| 9 |
from traceback import format_exc
|
| 10 |
|
|
|
|
| 11 |
from pyrogram.errors import (ChannelInvalid, ChannelPrivate, ChatAdminRequired,
|
| 12 |
EntityBoundsInvalid, FloodWait, MessageTooLong,
|
| 13 |
PeerIdInvalid, RPCError)
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
def can_change_type(curr, to_user):
|
| 33 |
+
if curr == "dev" and to_user in ["whitelist", "sudo"]:
|
| 34 |
return True
|
| 35 |
elif curr == "sudo" and to_user == "whitelist":
|
| 36 |
return True
|
| 37 |
else:
|
| 38 |
return False
|
| 39 |
|
| 40 |
+
|
| 41 |
@Gojo.on_message(command(["addsupport"]))
|
| 42 |
+
async def add_support(c: Gojo, m: Message):
|
| 43 |
support = SUPPORTS()
|
| 44 |
curr_user = support.get_support_type(m.from_user.id)
|
| 45 |
if not curr_user:
|
|
|
|
| 58 |
except IndexError:
|
| 59 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
| 60 |
return
|
| 61 |
+
if to not in ["dev", "sudo", "whitelist"]:
|
| 62 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
| 63 |
return
|
| 64 |
if m.from_user.id == int(OWNER_ID):
|
|
|
|
| 68 |
kb = IKM(
|
| 69 |
[
|
| 70 |
[
|
| 71 |
+
IKB("Yes", f"change_support_type:{to}"),
|
| 72 |
+
IKB("No", "change_support_type:no")
|
| 73 |
]
|
| 74 |
]
|
| 75 |
)
|
| 76 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
| 77 |
+
reply_markup=kb)
|
| 78 |
else:
|
| 79 |
+
support.insert_support_user(userr, to)
|
| 80 |
if to == "dev":
|
| 81 |
DEV_USERS.add(userr)
|
| 82 |
elif to == "sudo":
|
|
|
|
| 92 |
kb = IKM(
|
| 93 |
[
|
| 94 |
[
|
| 95 |
+
IKB("Yes", f"change_support_type:{to}"),
|
| 96 |
+
IKB("No", "change_support_type:no")
|
| 97 |
]
|
| 98 |
]
|
| 99 |
)
|
| 100 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
| 101 |
+
reply_markup=kb)
|
| 102 |
else:
|
| 103 |
+
support.insert_support_user(userr, to)
|
| 104 |
await m.reply_text(f"This user is now a {to} user")
|
| 105 |
else:
|
| 106 |
await m.reply_text("Sorry you can't do it")
|
|
|
|
| 108 |
elif len(split) >= 3:
|
| 109 |
user = split[1]
|
| 110 |
try:
|
| 111 |
+
userr, _, _ = extract_user(user)
|
| 112 |
except Exception:
|
| 113 |
await m.reply_text("Tell the user to start me first")
|
| 114 |
return
|
|
|
|
| 116 |
try:
|
| 117 |
to = m.command[2].lower()
|
| 118 |
except IndexError:
|
| 119 |
+
await m.reply_text(
|
| 120 |
+
"**USAGE**\n/addsupport [reply to message | user id | username] [dev | sudo | whitelist]")
|
| 121 |
return
|
| 122 |
+
if to not in ["dev", "sudo", "whitelist"]:
|
| 123 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
| 124 |
return
|
| 125 |
if m.from_user.id == int(OWNER_ID):
|
|
|
|
| 129 |
kb = IKM(
|
| 130 |
[
|
| 131 |
[
|
| 132 |
+
IKB("Yes", f"change_support_type:{to}"),
|
| 133 |
+
IKB("No", "change_support_type:no")
|
| 134 |
]
|
| 135 |
]
|
| 136 |
)
|
| 137 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
| 138 |
+
reply_markup=kb)
|
| 139 |
else:
|
| 140 |
+
support.insert_support_user(userr, to)
|
| 141 |
await m.reply_text(f"This user is now a {to} user")
|
| 142 |
return
|
| 143 |
if can_do := can_change_type(curr_user, to):
|
|
|
|
| 147 |
kb = IKM(
|
| 148 |
[
|
| 149 |
[
|
| 150 |
+
IKB("Yes", f"change_support_type:{to}"),
|
| 151 |
+
IKB("No", "change_support_type:no")
|
| 152 |
]
|
| 153 |
]
|
| 154 |
)
|
| 155 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
| 156 |
+
reply_markup=kb)
|
| 157 |
else:
|
| 158 |
+
support.insert_support_user(userr, to)
|
| 159 |
await m.reply_text(f"This user is now a {to} user")
|
| 160 |
else:
|
| 161 |
await m.reply_text("Sorry you can't do it")
|
| 162 |
return
|
| 163 |
|
| 164 |
+
|
| 165 |
@Gojo.on_message(command("rmsupport"))
|
| 166 |
async def rm_support(c: Gojo, m: Message):
|
| 167 |
support = SUPPORTS()
|
|
|
|
| 181 |
curr = int(split[1])
|
| 182 |
except Exception:
|
| 183 |
try:
|
| 184 |
+
curr, _, _ = extract_user(m)
|
| 185 |
except Exception:
|
| 186 |
await m.reply_text("Dunno who u r talking abt")
|
| 187 |
return
|
|
|
|
| 189 |
await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
|
| 190 |
return
|
| 191 |
to_user = support.get_support_type(curr)
|
| 192 |
+
can_user = can_change_type(curr_user, to_user)
|
| 193 |
if m.from_user.id == int(OWNER_ID) or can_user:
|
| 194 |
support.delete_support_user(curr)
|
| 195 |
DEV_USERS.discard(curr)
|
|
|
|
| 200 |
await m.reply_text("Sorry you can't do that...")
|
| 201 |
return
|
| 202 |
|
| 203 |
+
|
| 204 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
| 205 |
async def ping(_, m: Message):
|
| 206 |
start = time()
|
|
|
|
| 209 |
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
|
| 210 |
return
|
| 211 |
|
| 212 |
+
|
| 213 |
"""
|
| 214 |
|
| 215 |
['Metadata-Version', 'Name', 'Version', 'Summary', 'Home-page', 'Author', 'Author-email', 'License', 'Download-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Keywords', 'Platform', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Requires-Python', 'Description-Content-Type', 'License-File', 'License-File', 'License-File', 'Requires-Dist', 'Requires-Dist', 'Description']
|
| 216 |
|
| 217 |
"""
|
| 218 |
|
| 219 |
+
|
| 220 |
@Gojo.on_message(command(["minfo", "moduleinfo"], dev_cmd=True))
|
| 221 |
async def check_module_info(_, m: Message):
|
| 222 |
if len(m.command) != 2:
|
| 223 |
await m.reply_text("**USAGE**\n/minfo [module name]")
|
| 224 |
return
|
| 225 |
+
|
| 226 |
module = m.command[-1]
|
| 227 |
|
| 228 |
try:
|
|
|
|
| 230 |
except PackageNotFoundError:
|
| 231 |
await m.reply_text(f"No module found with name {module}")
|
| 232 |
return
|
| 233 |
+
|
| 234 |
name = minfo["Name"]
|
| 235 |
version = minfo["Version"]
|
| 236 |
summary = minfo["Summary"]
|
|
|
|
| 256 |
await m.reply_text(txt, disable_web_page_preview=True)
|
| 257 |
return
|
| 258 |
|
|
|
|
| 259 |
|
| 260 |
@Gojo.on_message(command("logs", dev_cmd=True))
|
| 261 |
async def send_log(c: Gojo, m: Message):
|
|
|
|
| 297 |
await m.delete()
|
| 298 |
return
|
| 299 |
|
| 300 |
+
|
| 301 |
HARMFUL = [
|
| 302 |
"base64",
|
| 303 |
"bash",
|
|
|
|
| 315 |
"SSH_CLIENT",
|
| 316 |
"SSH_CONNECTION"
|
| 317 |
"SSH"
|
| 318 |
+
|
| 319 |
]
|
| 320 |
|
| 321 |
|
|
|
|
| 335 |
await c.send_message(
|
| 336 |
MESSAGE_DUMP,
|
| 337 |
f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
|
| 338 |
+
)
|
| 339 |
return
|
| 340 |
+
if m.reply_to_message and m.reply_to_message.document and (m.reply_to_message.document.mime_type.split("/")[
|
| 341 |
+
1] == "x-python" or m.reply_to_message.document.file_name.endswith(
|
| 342 |
+
"py")):
|
| 343 |
await sm.delete()
|
| 344 |
await m.reply_text("Loading external plugin is prohibited")
|
| 345 |
return
|
|
|
|
| 373 |
for i in evaluation.split(None):
|
| 374 |
ev = i.strip()
|
| 375 |
if (
|
| 376 |
+
(ev.startswith(initial) or ev.endswith(end))
|
| 377 |
+
or (BOT_TOKEN in ev)
|
| 378 |
) and m.from_user.id != OWNER_ID:
|
| 379 |
evaluation = "Bhaag ja bsdk"
|
| 380 |
await c.send_message(
|
|
|
|
| 429 |
return await locals()["__aexec"](c, m)
|
| 430 |
|
| 431 |
|
|
|
|
|
|
|
| 432 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
| 433 |
async def execution(c: Gojo, m: Message):
|
| 434 |
protect = BOT_TOKEN.split(":")
|
|
|
|
| 452 |
out = o
|
| 453 |
xxx = o.split()
|
| 454 |
for OwO in xxx:
|
| 455 |
+
if OwO.startswith(initial) or OwO.endswith(end):
|
| 456 |
+
out = "You can't access them"
|
| 457 |
+
break
|
| 458 |
for x in xxx:
|
| 459 |
xx = x.split("=")
|
| 460 |
if xx and xx[0] in HARMFUL and m.from_user.id != OWNER_ID:
|
|
|
|
| 490 |
await sm.delete()
|
| 491 |
return
|
| 492 |
|
| 493 |
+
|
| 494 |
+
async def stop_and_send_logger(c: Gojo, is_update=False):
|
| 495 |
runtime = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
|
| 496 |
LOGGER.info("Uploading logs before stopping...!\n")
|
| 497 |
+
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
| 498 |
await c.send_document(
|
| 499 |
+
MESSAGE_DUMP,
|
| 500 |
+
document=LOGFILE,
|
| 501 |
+
caption=(
|
| 502 |
+
f"{'Updating and Restarting' if is_update else 'Restarting'} The Bot !\n\n" f"Uptime: {runtime}\n" f"<code>{LOG_DATETIME}</code>"
|
| 503 |
+
),
|
| 504 |
+
)
|
| 505 |
if MESSAGE_DUMP:
|
| 506 |
# LOG_CHANNEL is not necessary
|
| 507 |
await c.send_document(
|
| 508 |
+
MESSAGE_DUMP,
|
| 509 |
+
document=LOGFILE,
|
| 510 |
+
caption=f"Uptime: {runtime}",
|
| 511 |
+
)
|
| 512 |
MongoDB.close()
|
| 513 |
LOGGER.info(
|
| 514 |
+
f"""Bot Stopped.
|
| 515 |
Logs have been uploaded to the MESSAGE_DUMP Group!
|
| 516 |
Runtime: {runtime}s\n
|
| 517 |
""",
|
| 518 |
+
)
|
| 519 |
return
|
| 520 |
|
| 521 |
+
|
| 522 |
@Gojo.on_message(command(["restart", "update"], owner_cmd=True))
|
| 523 |
+
async def restart_the_bot(c: Gojo, m: Message):
|
| 524 |
try:
|
| 525 |
cmds = m.command
|
| 526 |
+
await m.reply_text(
|
| 527 |
+
f"Restarting{' and updating ' if cmds[0] == 'update' else ' '}the bot...\nType `/ping` after few minutes")
|
| 528 |
if cmds[0] == "update":
|
| 529 |
try:
|
| 530 |
out = subp.check_output(["git", "pull"]).decode("UTF-8")
|
|
|
|
| 534 |
except Exception as e:
|
| 535 |
return await m.reply_text(str(e))
|
| 536 |
m = await m.reply_text("**Updated with main branch, restarting now.**")
|
| 537 |
+
await stop_and_send_logger(c, True)
|
| 538 |
if cmds[0] == "restart":
|
| 539 |
await stop_and_send_logger(c)
|
| 540 |
execvp(executable, [executable, "-m", "Powers"])
|
|
|
|
| 544 |
LOGGER.error(format_exc())
|
| 545 |
return
|
| 546 |
|
| 547 |
+
|
| 548 |
@Gojo.on_message(command("chatlist", dev_cmd=True))
|
| 549 |
async def chats(c: Gojo, m: Message):
|
| 550 |
exmsg = await m.reply_text(text="Exporting Charlist...")
|
|
|
|
| 654 |
|
| 655 |
return
|
| 656 |
|
| 657 |
+
|
| 658 |
+
@Gojo.on_message(command(["forward", "fwd"], dev_cmd=True))
|
| 659 |
async def forward_type_broadcast(c: Gojo, m: Message):
|
| 660 |
repl = m.reply_to_message
|
| 661 |
if not repl:
|
|
|
|
| 695 |
await sleep(0.1)
|
| 696 |
except Exception:
|
| 697 |
failed += 1
|
| 698 |
+
txt = f"Broadcasted message to {total - failed} peers out of {total}\nFailed to broadcast message to {failed} peers"
|
| 699 |
if not failed:
|
| 700 |
txt = f"Broadcasted message to {total} peers"
|
| 701 |
await m.reply_text(txt)
|
|
|
|
| 706 |
return
|
| 707 |
|
| 708 |
|
|
|
|
| 709 |
__PLUGIN__ = "devs"
|
| 710 |
|
|
|
|
| 711 |
__HELP__ = """
|
| 712 |
**DEV and SUDOERS commands**
|
| 713 |
|
Powers/plugins/disable.py
CHANGED
|
@@ -5,7 +5,7 @@ from pyrogram.enums import ChatMemberStatus as CMS
|
|
| 5 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
| 6 |
InlineKeyboardMarkup, Message)
|
| 7 |
|
| 8 |
-
from Powers import HELP_COMMANDS
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
from Powers.database.disable_db import Disabling
|
| 11 |
from Powers.utils.custom_filters import (admin_filter, can_change_filter,
|
|
@@ -146,7 +146,6 @@ __PLUGIN__ = "disable able"
|
|
| 146 |
|
| 147 |
__alt_name__ = ["disable commands", "disable"]
|
| 148 |
|
| 149 |
-
|
| 150 |
__HELP__ = """
|
| 151 |
**Disable commands**
|
| 152 |
|
|
@@ -159,4 +158,4 @@ __HELP__ = """
|
|
| 159 |
|
| 160 |
**Owner command:**
|
| 161 |
• /enableall : Enable all the disabled commands.
|
| 162 |
-
"""
|
|
|
|
| 5 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
| 6 |
InlineKeyboardMarkup, Message)
|
| 7 |
|
| 8 |
+
from Powers import HELP_COMMANDS
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
from Powers.database.disable_db import Disabling
|
| 11 |
from Powers.utils.custom_filters import (admin_filter, can_change_filter,
|
|
|
|
| 146 |
|
| 147 |
__alt_name__ = ["disable commands", "disable"]
|
| 148 |
|
|
|
|
| 149 |
__HELP__ = """
|
| 150 |
**Disable commands**
|
| 151 |
|
|
|
|
| 158 |
|
| 159 |
**Owner command:**
|
| 160 |
• /enableall : Enable all the disabled commands.
|
| 161 |
+
"""
|
Powers/plugins/filters.py
CHANGED
|
@@ -6,7 +6,7 @@ from pyrogram import filters
|
|
| 6 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 7 |
from pyrogram.enums import ParseMode as PM
|
| 8 |
from pyrogram.errors import RPCError
|
| 9 |
-
from pyrogram.types import CallbackQuery,
|
| 10 |
|
| 11 |
from Powers.bot_class import LOGGER, Gojo
|
| 12 |
from Powers.database.filters_db import Filters
|
|
@@ -44,7 +44,6 @@ async def view_filters(_, m: Message):
|
|
| 44 |
|
| 45 |
@Gojo.on_message(command(["filter", "addfilter"]) & admin_filter & ~filters.bot)
|
| 46 |
async def add_filter(_, m: Message):
|
| 47 |
-
|
| 48 |
args = m.text.split(" ", 1)
|
| 49 |
all_filters = db.get_all_filters(m.chat.id)
|
| 50 |
actual_filters = {j for i in all_filters for j in i.split("|")}
|
|
@@ -237,10 +236,10 @@ async def send_filter_reply(c: Gojo, m: Message, trigger: str):
|
|
| 237 |
return
|
| 238 |
|
| 239 |
elif msgtype in (
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
):
|
| 245 |
await (await send_cmd(c, msgtype))(
|
| 246 |
m.chat.id,
|
|
@@ -266,7 +265,6 @@ async def send_filter_reply(c: Gojo, m: Message, trigger: str):
|
|
| 266 |
|
| 267 |
@Gojo.on_message(filters.text & filters.group & ~filters.bot, group=69)
|
| 268 |
async def filters_watcher(c: Gojo, m: Message):
|
| 269 |
-
|
| 270 |
chat_filters = db.get_all_filters(m.chat.id)
|
| 271 |
actual_filters = {j for i in chat_filters for j in i.split("|")}
|
| 272 |
|
|
|
|
| 6 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 7 |
from pyrogram.enums import ParseMode as PM
|
| 8 |
from pyrogram.errors import RPCError
|
| 9 |
+
from pyrogram.types import CallbackQuery, Message
|
| 10 |
|
| 11 |
from Powers.bot_class import LOGGER, Gojo
|
| 12 |
from Powers.database.filters_db import Filters
|
|
|
|
| 44 |
|
| 45 |
@Gojo.on_message(command(["filter", "addfilter"]) & admin_filter & ~filters.bot)
|
| 46 |
async def add_filter(_, m: Message):
|
|
|
|
| 47 |
args = m.text.split(" ", 1)
|
| 48 |
all_filters = db.get_all_filters(m.chat.id)
|
| 49 |
actual_filters = {j for i in all_filters for j in i.split("|")}
|
|
|
|
| 236 |
return
|
| 237 |
|
| 238 |
elif msgtype in (
|
| 239 |
+
Types.STICKER,
|
| 240 |
+
Types.VIDEO_NOTE,
|
| 241 |
+
Types.CONTACT,
|
| 242 |
+
Types.ANIMATED_STICKER,
|
| 243 |
):
|
| 244 |
await (await send_cmd(c, msgtype))(
|
| 245 |
m.chat.id,
|
|
|
|
| 265 |
|
| 266 |
@Gojo.on_message(filters.text & filters.group & ~filters.bot, group=69)
|
| 267 |
async def filters_watcher(c: Gojo, m: Message):
|
|
|
|
| 268 |
chat_filters = db.get_all_filters(m.chat.id)
|
| 269 |
actual_filters = {j for i in chat_filters for j in i.split("|")}
|
| 270 |
|
Powers/plugins/flood.py
CHANGED
|
@@ -20,6 +20,7 @@ from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
|
| 20 |
on_key = ["on", "start", "disable"]
|
| 21 |
off_key = ["off", "end", "enable", "stop"]
|
| 22 |
|
|
|
|
| 23 |
async def get_what_temp(what):
|
| 24 |
return InlineKeyboardMarkup(
|
| 25 |
[
|
|
@@ -36,7 +37,8 @@ async def get_what_temp(what):
|
|
| 36 |
]
|
| 37 |
)
|
| 38 |
|
| 39 |
-
|
|
|
|
| 40 |
[
|
| 41 |
[
|
| 42 |
InlineKeyboardButton(
|
|
@@ -132,7 +134,8 @@ limit_kb = InlineKeyboardMarkup(
|
|
| 132 |
]
|
| 133 |
)
|
| 134 |
|
| 135 |
-
|
|
|
|
| 136 |
async def flood_action(c: Gojo, m: Message):
|
| 137 |
Flood = Floods()
|
| 138 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
|
@@ -153,21 +156,24 @@ async def flood_action(c: Gojo, m: Message):
|
|
| 153 |
await m.reply_text("Switch on the flood protection first.")
|
| 154 |
return
|
| 155 |
|
|
|
|
| 156 |
@Gojo.on_message(command(['isflood', 'flood']) & ~filters.bot)
|
| 157 |
async def flood_on_off(c: Gojo, m: Message):
|
| 158 |
-
if m.chat.type == CT.PRIVATE:
|
| 159 |
-
|
| 160 |
Flood = Floods()
|
| 161 |
c_id = m.chat.id
|
| 162 |
is_flood = Flood.is_chat(c_id)
|
| 163 |
c_id = m.chat.id
|
| 164 |
if is_flood:
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
| 169 |
return await m.reply_text("Flood protection is off for this chat.")
|
| 170 |
|
|
|
|
| 171 |
@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
|
| 172 |
async def flood_set(c: Gojo, m: Message):
|
| 173 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
|
@@ -183,22 +189,24 @@ async def flood_set(c: Gojo, m: Message):
|
|
| 183 |
|
| 184 |
if len(split) == 1:
|
| 185 |
c_id = m.chat.id
|
| 186 |
-
if is_flood:
|
| 187 |
saction = is_flood[2]
|
| 188 |
slimit = is_flood[0]
|
| 189 |
-
swithin = is_flood[1]
|
| 190 |
-
return await m.reply_text(
|
|
|
|
| 191 |
return await m.reply_text("Flood protection is off of this chat.")
|
| 192 |
|
| 193 |
if len(split) == 2:
|
| 194 |
c_id = m.chat.id
|
| 195 |
if split[1].lower() in on_key:
|
| 196 |
-
if is_flood:
|
| 197 |
saction = is_flood[2]
|
| 198 |
slimit = is_flood[0]
|
| 199 |
swithin = is_flood[1]
|
| 200 |
|
| 201 |
-
await m.reply_text(
|
|
|
|
| 202 |
return
|
| 203 |
if split[1].lower() in off_key:
|
| 204 |
x = Flood.rm_flood(c_id)
|
|
@@ -213,6 +221,7 @@ async def flood_set(c: Gojo, m: Message):
|
|
| 213 |
await m.reply_text("**Usage:**\n `/setflood on/off`")
|
| 214 |
return
|
| 215 |
|
|
|
|
| 216 |
@Gojo.on_callback_query(filters.regex("^f_"))
|
| 217 |
async def callbacks(c: Gojo, q: CallbackQuery):
|
| 218 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
|
@@ -323,9 +332,10 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
| 323 |
await q.answer(
|
| 324 |
"You don't have enough permission to do this!\nStay in your limits!",
|
| 325 |
show_alert=True,
|
| 326 |
-
|
| 327 |
return
|
| 328 |
|
|
|
|
| 329 |
@Gojo.on_callback_query(filters.regex("^un_"))
|
| 330 |
async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
| 331 |
data = q.data.split("_")
|
|
@@ -370,7 +380,10 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
| 370 |
await q.message.edit_text(f"{q.from_user.mention} unmuted {whoo.mention}!")
|
| 371 |
return
|
| 372 |
|
|
|
|
| 373 |
dic = {}
|
|
|
|
|
|
|
| 374 |
@Gojo.on_message(flood_filter, 18)
|
| 375 |
async def flood_watcher(c: Gojo, m: Message):
|
| 376 |
c_id = m.chat.id
|
|
@@ -381,26 +394,25 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 381 |
|
| 382 |
is_flood = Flood.is_chat(c_id)
|
| 383 |
|
| 384 |
-
|
| 385 |
action = is_flood[2]
|
| 386 |
limit = int(is_flood[0])
|
| 387 |
within = int(is_flood[1])
|
| 388 |
|
| 389 |
if not len(dic):
|
| 390 |
-
z = {c_id
|
| 391 |
dic.update(z)
|
| 392 |
|
| 393 |
try:
|
| 394 |
-
|
| 395 |
except KeyError:
|
| 396 |
-
|
| 397 |
-
|
| 398 |
|
| 399 |
try:
|
| 400 |
-
|
| 401 |
except KeyError:
|
| 402 |
-
|
| 403 |
-
|
| 404 |
|
| 405 |
sec = round(time.time())
|
| 406 |
|
|
@@ -408,18 +420,18 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 408 |
dic[c_id][u_id][0].append(sec)
|
| 409 |
dic[c_id][u_id][1].append("x")
|
| 410 |
except KeyError:
|
| 411 |
-
dic[c_id].update({u_id
|
| 412 |
|
| 413 |
x = int(dic[c_id][u_id][0][0])
|
| 414 |
y = int(dic[c_id][u_id][0][-1])
|
| 415 |
|
| 416 |
if len(dic[c_id][u_id][1]) == limit:
|
| 417 |
-
if y-x <= within:
|
| 418 |
action = action.split("_")
|
| 419 |
if len(action) == 2:
|
| 420 |
try:
|
| 421 |
to_do = action[0]
|
| 422 |
-
for_tim = int(action[1].replace("min",""))
|
| 423 |
except Exception:
|
| 424 |
for_tim = 30
|
| 425 |
for_how_much = datetime.now() + timedelta(minutes=for_tim)
|
|
@@ -471,7 +483,7 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 471 |
except UserAdminInvalid:
|
| 472 |
await m.reply_text(
|
| 473 |
"I can't protect this chat from this user",
|
| 474 |
-
|
| 475 |
dic[c_id][u_id][1].clear()
|
| 476 |
dic[c_id][u_id][0].clear()
|
| 477 |
return
|
|
@@ -480,7 +492,7 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 480 |
text=f"""Some error occured, report it using `/bug`
|
| 481 |
|
| 482 |
<b>Error:</b> <code>{ef}</code>"""
|
| 483 |
-
|
| 484 |
LOGGER.error(ef)
|
| 485 |
LOGGER.error(format_exc())
|
| 486 |
dic[c_id][u_id][1].clear()
|
|
@@ -514,7 +526,7 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 514 |
except UserAdminInvalid:
|
| 515 |
await m.reply_text(
|
| 516 |
"I can't protect this chat from this user",
|
| 517 |
-
|
| 518 |
dic[c_id][u_id][1].clear()
|
| 519 |
dic[c_id][u_id][0].clear()
|
| 520 |
return
|
|
@@ -523,7 +535,7 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 523 |
text=f"""Some error occured, report it using `/bug`
|
| 524 |
|
| 525 |
<b>Error:</b> <code>{ef}</code>"""
|
| 526 |
-
|
| 527 |
LOGGER.error(ef)
|
| 528 |
LOGGER.error(format_exc())
|
| 529 |
dic[c_id][u_id][1].clear()
|
|
@@ -532,7 +544,8 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 532 |
|
| 533 |
elif action == "kick":
|
| 534 |
try:
|
| 535 |
-
d = datetime.now()+timedelta(
|
|
|
|
| 536 |
await m.chat.ban_member(u_id, until_date=d)
|
| 537 |
success = await c.unban_chat_member(m.chat.id, u_id)
|
| 538 |
txt = f"Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: {'kicked' if success else 'banned for 30 seconds'}\nReason: Spaming"
|
|
@@ -610,23 +623,23 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
| 610 |
dic[c_id][u_id][1].clear()
|
| 611 |
dic[c_id][u_id][0].clear()
|
| 612 |
return
|
| 613 |
-
elif y-x > within:
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
else:
|
| 621 |
return
|
| 622 |
|
| 623 |
|
| 624 |
__PLUGIN__ = "flood"
|
| 625 |
__alt_name__ = [
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
]
|
| 631 |
__HELP__ = """
|
| 632 |
**Anti Flood**
|
|
@@ -640,4 +653,3 @@ __HELP__ = """
|
|
| 640 |
**Example:**
|
| 641 |
`/setflood on`
|
| 642 |
"""
|
| 643 |
-
|
|
|
|
| 20 |
on_key = ["on", "start", "disable"]
|
| 21 |
off_key = ["off", "end", "enable", "stop"]
|
| 22 |
|
| 23 |
+
|
| 24 |
async def get_what_temp(what):
|
| 25 |
return InlineKeyboardMarkup(
|
| 26 |
[
|
|
|
|
| 37 |
]
|
| 38 |
)
|
| 39 |
|
| 40 |
+
|
| 41 |
+
close_kb = InlineKeyboardMarkup(
|
| 42 |
[
|
| 43 |
[
|
| 44 |
InlineKeyboardButton(
|
|
|
|
| 134 |
]
|
| 135 |
)
|
| 136 |
|
| 137 |
+
|
| 138 |
+
@Gojo.on_message(command(['floodaction', 'actionflood']) & admin_filter)
|
| 139 |
async def flood_action(c: Gojo, m: Message):
|
| 140 |
Flood = Floods()
|
| 141 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
|
|
|
| 156 |
await m.reply_text("Switch on the flood protection first.")
|
| 157 |
return
|
| 158 |
|
| 159 |
+
|
| 160 |
@Gojo.on_message(command(['isflood', 'flood']) & ~filters.bot)
|
| 161 |
async def flood_on_off(c: Gojo, m: Message):
|
| 162 |
+
if m.chat.type == CT.PRIVATE:
|
| 163 |
+
return await m.reply_text("This command is ment to be used in groups.")
|
| 164 |
Flood = Floods()
|
| 165 |
c_id = m.chat.id
|
| 166 |
is_flood = Flood.is_chat(c_id)
|
| 167 |
c_id = m.chat.id
|
| 168 |
if is_flood:
|
| 169 |
+
saction = is_flood[2]
|
| 170 |
+
slimit = is_flood[0]
|
| 171 |
+
swithin = is_flood[1]
|
| 172 |
+
return await m.reply_text(
|
| 173 |
+
f"Flood is on for this chat\n**Action**: {saction}\n**Messages**: {slimit} within {swithin} sec")
|
| 174 |
return await m.reply_text("Flood protection is off for this chat.")
|
| 175 |
|
| 176 |
+
|
| 177 |
@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
|
| 178 |
async def flood_set(c: Gojo, m: Message):
|
| 179 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
|
|
|
| 189 |
|
| 190 |
if len(split) == 1:
|
| 191 |
c_id = m.chat.id
|
| 192 |
+
if is_flood:
|
| 193 |
saction = is_flood[2]
|
| 194 |
slimit = is_flood[0]
|
| 195 |
+
swithin = is_flood[1]
|
| 196 |
+
return await m.reply_text(
|
| 197 |
+
f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
| 198 |
return await m.reply_text("Flood protection is off of this chat.")
|
| 199 |
|
| 200 |
if len(split) == 2:
|
| 201 |
c_id = m.chat.id
|
| 202 |
if split[1].lower() in on_key:
|
| 203 |
+
if is_flood:
|
| 204 |
saction = is_flood[2]
|
| 205 |
slimit = is_flood[0]
|
| 206 |
swithin = is_flood[1]
|
| 207 |
|
| 208 |
+
await m.reply_text(
|
| 209 |
+
f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
| 210 |
return
|
| 211 |
if split[1].lower() in off_key:
|
| 212 |
x = Flood.rm_flood(c_id)
|
|
|
|
| 221 |
await m.reply_text("**Usage:**\n `/setflood on/off`")
|
| 222 |
return
|
| 223 |
|
| 224 |
+
|
| 225 |
@Gojo.on_callback_query(filters.regex("^f_"))
|
| 226 |
async def callbacks(c: Gojo, q: CallbackQuery):
|
| 227 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
|
|
|
| 332 |
await q.answer(
|
| 333 |
"You don't have enough permission to do this!\nStay in your limits!",
|
| 334 |
show_alert=True,
|
| 335 |
+
)
|
| 336 |
return
|
| 337 |
|
| 338 |
+
|
| 339 |
@Gojo.on_callback_query(filters.regex("^un_"))
|
| 340 |
async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
| 341 |
data = q.data.split("_")
|
|
|
|
| 380 |
await q.message.edit_text(f"{q.from_user.mention} unmuted {whoo.mention}!")
|
| 381 |
return
|
| 382 |
|
| 383 |
+
|
| 384 |
dic = {}
|
| 385 |
+
|
| 386 |
+
|
| 387 |
@Gojo.on_message(flood_filter, 18)
|
| 388 |
async def flood_watcher(c: Gojo, m: Message):
|
| 389 |
c_id = m.chat.id
|
|
|
|
| 394 |
|
| 395 |
is_flood = Flood.is_chat(c_id)
|
| 396 |
|
|
|
|
| 397 |
action = is_flood[2]
|
| 398 |
limit = int(is_flood[0])
|
| 399 |
within = int(is_flood[1])
|
| 400 |
|
| 401 |
if not len(dic):
|
| 402 |
+
z = {c_id: {u_id: [[], []]}}
|
| 403 |
dic.update(z)
|
| 404 |
|
| 405 |
try:
|
| 406 |
+
dic[c_id] # access and check weather the c_id present or not
|
| 407 |
except KeyError:
|
| 408 |
+
z = {c_id: {u_id: [[], []]}}
|
| 409 |
+
dic.update(z)
|
| 410 |
|
| 411 |
try:
|
| 412 |
+
dic[c_id][u_id]
|
| 413 |
except KeyError:
|
| 414 |
+
z = {u_id: [[], []]}
|
| 415 |
+
dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[for time],[for msg]]}}
|
| 416 |
|
| 417 |
sec = round(time.time())
|
| 418 |
|
|
|
|
| 420 |
dic[c_id][u_id][0].append(sec)
|
| 421 |
dic[c_id][u_id][1].append("x")
|
| 422 |
except KeyError:
|
| 423 |
+
dic[c_id].update({u_id: [[sec], ["x"]]})
|
| 424 |
|
| 425 |
x = int(dic[c_id][u_id][0][0])
|
| 426 |
y = int(dic[c_id][u_id][0][-1])
|
| 427 |
|
| 428 |
if len(dic[c_id][u_id][1]) == limit:
|
| 429 |
+
if y - x <= within:
|
| 430 |
action = action.split("_")
|
| 431 |
if len(action) == 2:
|
| 432 |
try:
|
| 433 |
to_do = action[0]
|
| 434 |
+
for_tim = int(action[1].replace("min", ""))
|
| 435 |
except Exception:
|
| 436 |
for_tim = 30
|
| 437 |
for_how_much = datetime.now() + timedelta(minutes=for_tim)
|
|
|
|
| 483 |
except UserAdminInvalid:
|
| 484 |
await m.reply_text(
|
| 485 |
"I can't protect this chat from this user",
|
| 486 |
+
)
|
| 487 |
dic[c_id][u_id][1].clear()
|
| 488 |
dic[c_id][u_id][0].clear()
|
| 489 |
return
|
|
|
|
| 492 |
text=f"""Some error occured, report it using `/bug`
|
| 493 |
|
| 494 |
<b>Error:</b> <code>{ef}</code>"""
|
| 495 |
+
)
|
| 496 |
LOGGER.error(ef)
|
| 497 |
LOGGER.error(format_exc())
|
| 498 |
dic[c_id][u_id][1].clear()
|
|
|
|
| 526 |
except UserAdminInvalid:
|
| 527 |
await m.reply_text(
|
| 528 |
"I can't protect this chat from this user",
|
| 529 |
+
)
|
| 530 |
dic[c_id][u_id][1].clear()
|
| 531 |
dic[c_id][u_id][0].clear()
|
| 532 |
return
|
|
|
|
| 535 |
text=f"""Some error occured, report it using `/bug`
|
| 536 |
|
| 537 |
<b>Error:</b> <code>{ef}</code>"""
|
| 538 |
+
)
|
| 539 |
LOGGER.error(ef)
|
| 540 |
LOGGER.error(format_exc())
|
| 541 |
dic[c_id][u_id][1].clear()
|
|
|
|
| 544 |
|
| 545 |
elif action == "kick":
|
| 546 |
try:
|
| 547 |
+
d = datetime.now() + timedelta(
|
| 548 |
+
seconds=31) # will automatically unban user after 31 seconds kind of fail safe if unban members doesn't work properly
|
| 549 |
await m.chat.ban_member(u_id, until_date=d)
|
| 550 |
success = await c.unban_chat_member(m.chat.id, u_id)
|
| 551 |
txt = f"Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: {'kicked' if success else 'banned for 30 seconds'}\nReason: Spaming"
|
|
|
|
| 623 |
dic[c_id][u_id][1].clear()
|
| 624 |
dic[c_id][u_id][0].clear()
|
| 625 |
return
|
| 626 |
+
elif y - x > within:
|
| 627 |
+
try:
|
| 628 |
+
dic[c_id][u_id][1].clear()
|
| 629 |
+
dic[c_id][u_id][0].clear()
|
| 630 |
+
return
|
| 631 |
+
except Exception:
|
| 632 |
+
pass
|
| 633 |
else:
|
| 634 |
return
|
| 635 |
|
| 636 |
|
| 637 |
__PLUGIN__ = "flood"
|
| 638 |
__alt_name__ = [
|
| 639 |
+
"anit-flood",
|
| 640 |
+
"flood",
|
| 641 |
+
"spam",
|
| 642 |
+
"anti-spam",
|
| 643 |
]
|
| 644 |
__HELP__ = """
|
| 645 |
**Anti Flood**
|
|
|
|
| 653 |
**Example:**
|
| 654 |
`/setflood on`
|
| 655 |
"""
|
|
|
Powers/plugins/formatting.py
CHANGED
|
@@ -4,7 +4,6 @@ from pyrogram import enums, filters
|
|
| 4 |
from pyrogram.errors import MediaCaptionTooLong
|
| 5 |
from pyrogram.types import CallbackQuery, Message
|
| 6 |
|
| 7 |
-
from Powers import LOGGER
|
| 8 |
from Powers.bot_class import Gojo
|
| 9 |
from Powers.utils.custom_filters import command
|
| 10 |
from Powers.utils.extras import StartPic
|
|
@@ -59,6 +58,7 @@ If you would like to send buttons on the same row, use the <code>:same</code> fo
|
|
| 59 |
<code>[button 3](buttonurl://example.com)</code>
|
| 60 |
This will show button 1 and 2 on the same line, while 3 will be underneath."""
|
| 61 |
|
|
|
|
| 62 |
async def get_splited_formatting(msg, page=1):
|
| 63 |
msg = msg.split("\n")
|
| 64 |
l = len(msg)
|
|
@@ -71,7 +71,7 @@ async def get_splited_formatting(msg, page=1):
|
|
| 71 |
new_msg += f"{i}\n"
|
| 72 |
kb = [
|
| 73 |
[
|
| 74 |
-
("Next page ▶️", f"next_format_{page+1}")
|
| 75 |
]
|
| 76 |
]
|
| 77 |
else:
|
|
@@ -81,38 +81,39 @@ async def get_splited_formatting(msg, page=1):
|
|
| 81 |
new_msg += f"{i}\n"
|
| 82 |
kb = [
|
| 83 |
[
|
| 84 |
-
("◀️ Previous page", f"next_format_{page-1}")
|
| 85 |
]
|
| 86 |
]
|
| 87 |
else:
|
| 88 |
for i in msg[first:last]:
|
| 89 |
new_msg += f"{i}\n"
|
| 90 |
kb = [
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
]
|
| 95 |
]
|
| 96 |
-
|
| 97 |
|
| 98 |
kb = ikb(kb, True, "back.formatting")
|
| 99 |
|
| 100 |
return new_msg, kb
|
| 101 |
|
|
|
|
| 102 |
@Gojo.on_callback_query(filters.regex(r"^next_format_.*[0-9]$"))
|
| 103 |
async def change_formatting_page(c: Gojo, q: CallbackQuery):
|
| 104 |
page = q.data.split("_")[-1]
|
| 105 |
txt, kb = await get_splited_formatting(md_txt, int(page))
|
| 106 |
-
await q.edit_message_caption(txt, reply_markup=kb,parse_mode=enums.ParseMode.HTML,)
|
| 107 |
return
|
| 108 |
|
|
|
|
| 109 |
@Gojo.on_callback_query(filters.regex("^formatting."))
|
| 110 |
async def get_formatting_info(c: Gojo, q: CallbackQuery):
|
| 111 |
cmd = q.data.split(".")[1]
|
| 112 |
kb = ikb([[("Back", "back.formatting")]])
|
| 113 |
|
| 114 |
if cmd == "md_formatting":
|
| 115 |
-
|
| 116 |
try:
|
| 117 |
await q.edit_message_caption(
|
| 118 |
caption=md_txt,
|
|
|
|
| 4 |
from pyrogram.errors import MediaCaptionTooLong
|
| 5 |
from pyrogram.types import CallbackQuery, Message
|
| 6 |
|
|
|
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
from Powers.utils.custom_filters import command
|
| 9 |
from Powers.utils.extras import StartPic
|
|
|
|
| 58 |
<code>[button 3](buttonurl://example.com)</code>
|
| 59 |
This will show button 1 and 2 on the same line, while 3 will be underneath."""
|
| 60 |
|
| 61 |
+
|
| 62 |
async def get_splited_formatting(msg, page=1):
|
| 63 |
msg = msg.split("\n")
|
| 64 |
l = len(msg)
|
|
|
|
| 71 |
new_msg += f"{i}\n"
|
| 72 |
kb = [
|
| 73 |
[
|
| 74 |
+
("Next page ▶️", f"next_format_{page + 1}")
|
| 75 |
]
|
| 76 |
]
|
| 77 |
else:
|
|
|
|
| 81 |
new_msg += f"{i}\n"
|
| 82 |
kb = [
|
| 83 |
[
|
| 84 |
+
("◀️ Previous page", f"next_format_{page - 1}")
|
| 85 |
]
|
| 86 |
]
|
| 87 |
else:
|
| 88 |
for i in msg[first:last]:
|
| 89 |
new_msg += f"{i}\n"
|
| 90 |
kb = [
|
| 91 |
+
[
|
| 92 |
+
("◀️ Previous page", f"next_format_{page - 1}"),
|
| 93 |
+
("Next page ▶️", f"next_format_{page + 1}")
|
|
|
|
| 94 |
]
|
| 95 |
+
]
|
| 96 |
|
| 97 |
kb = ikb(kb, True, "back.formatting")
|
| 98 |
|
| 99 |
return new_msg, kb
|
| 100 |
|
| 101 |
+
|
| 102 |
@Gojo.on_callback_query(filters.regex(r"^next_format_.*[0-9]$"))
|
| 103 |
async def change_formatting_page(c: Gojo, q: CallbackQuery):
|
| 104 |
page = q.data.split("_")[-1]
|
| 105 |
txt, kb = await get_splited_formatting(md_txt, int(page))
|
| 106 |
+
await q.edit_message_caption(txt, reply_markup=kb, parse_mode=enums.ParseMode.HTML, )
|
| 107 |
return
|
| 108 |
|
| 109 |
+
|
| 110 |
@Gojo.on_callback_query(filters.regex("^formatting."))
|
| 111 |
async def get_formatting_info(c: Gojo, q: CallbackQuery):
|
| 112 |
cmd = q.data.split(".")[1]
|
| 113 |
kb = ikb([[("Back", "back.formatting")]])
|
| 114 |
|
| 115 |
if cmd == "md_formatting":
|
| 116 |
+
|
| 117 |
try:
|
| 118 |
await q.edit_message_caption(
|
| 119 |
caption=md_txt,
|
Powers/plugins/greetings.py
CHANGED
|
@@ -26,11 +26,11 @@ gdb = GBan()
|
|
| 26 |
ChatType = enums.ChatType
|
| 27 |
|
| 28 |
|
| 29 |
-
async def
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
) -> str:
|
| 35 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
| 36 |
if teks:
|
|
@@ -157,7 +157,7 @@ async def save_wlcm(_, m: Message):
|
|
| 157 |
await m.reply_text("Please provide some data for this to reply with!")
|
| 158 |
return
|
| 159 |
|
| 160 |
-
db.set_welcome_text(text,msgtype,file)
|
| 161 |
await m.reply_text("Saved welcome!")
|
| 162 |
return
|
| 163 |
|
|
@@ -195,7 +195,7 @@ async def save_gdbye(_, m: Message):
|
|
| 195 |
await m.reply_text("Please provide some data for this to reply with!")
|
| 196 |
return
|
| 197 |
|
| 198 |
-
db.set_goodbye_text(text,msgtype,file)
|
| 199 |
await m.reply_text("Saved goodbye!")
|
| 200 |
return
|
| 201 |
|
|
@@ -206,7 +206,7 @@ async def resetgb(_, m: Message):
|
|
| 206 |
if m and not m.from_user:
|
| 207 |
return
|
| 208 |
text = "Sad to see you leaving {first}.\nTake Care!"
|
| 209 |
-
db.set_goodbye_text(text,None)
|
| 210 |
await m.reply_text("Ok Done!")
|
| 211 |
return
|
| 212 |
|
|
@@ -217,7 +217,7 @@ async def resetwlcm(_, m: Message):
|
|
| 217 |
if m and not m.from_user:
|
| 218 |
return
|
| 219 |
text = "Hey {first}, welcome to {chatname}!"
|
| 220 |
-
db.set_welcome_text(text,None)
|
| 221 |
await m.reply_text("Done!")
|
| 222 |
return
|
| 223 |
|
|
@@ -232,6 +232,7 @@ async def cleannnnn(_, m: Message):
|
|
| 232 |
except Exception:
|
| 233 |
pass
|
| 234 |
|
|
|
|
| 235 |
@Gojo.on_message(filters.group & filters.new_chat_members & ~captcha_filter, group=69)
|
| 236 |
async def member_has_joined(c: Gojo, m: Message):
|
| 237 |
users: List[User] = m.new_chat_members
|
|
@@ -256,7 +257,7 @@ async def member_has_joined(c: Gojo, m: Message):
|
|
| 256 |
)
|
| 257 |
continue
|
| 258 |
if user.is_bot:
|
| 259 |
-
continue
|
| 260 |
except ChatAdminRequired:
|
| 261 |
continue
|
| 262 |
status = db.get_welcome_status()
|
|
@@ -306,7 +307,7 @@ async def member_has_joined(c: Gojo, m: Message):
|
|
| 306 |
disable_web_page_preview=True,
|
| 307 |
)
|
| 308 |
else:
|
| 309 |
-
jj = await (await send_cmd(c,mtype))(
|
| 310 |
m.chat.id,
|
| 311 |
UwU,
|
| 312 |
caption=teks,
|
|
@@ -354,7 +355,7 @@ async def member_has_left(c: Gojo, m: Message):
|
|
| 354 |
else:
|
| 355 |
teks = tek
|
| 356 |
|
| 357 |
-
if not teks:
|
| 358 |
teks = f"Thanks for being part of this group {user.mention}. But I don't like your arrogance and leaving the group {emoji.EYES}"
|
| 359 |
|
| 360 |
ifff = db.get_current_cleangoodbye_id()
|
|
@@ -375,16 +376,16 @@ async def member_has_left(c: Gojo, m: Message):
|
|
| 375 |
try:
|
| 376 |
ooo = (
|
| 377 |
await (await send_cmd(c, mtype))(
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
)
|
| 389 |
if ooo:
|
| 390 |
db.set_cleangoodbye_id(int(ooo.id))
|
|
@@ -445,14 +446,14 @@ async def welcome(c: Gojo, m: Message):
|
|
| 445 |
button = await build_keyboard(button)
|
| 446 |
button = ikb(button) if button else None
|
| 447 |
if not UwU:
|
| 448 |
-
|
| 449 |
m.chat.id,
|
| 450 |
text=tek,
|
| 451 |
reply_markup=button,
|
| 452 |
disable_web_page_preview=True,
|
| 453 |
)
|
| 454 |
else:
|
| 455 |
-
|
| 456 |
m.chat.id,
|
| 457 |
UwU,
|
| 458 |
caption=tek,
|
|
@@ -507,14 +508,14 @@ async def goodbye(c: Gojo, m: Message):
|
|
| 507 |
button = await build_keyboard(button)
|
| 508 |
button = ikb(button) if button else None
|
| 509 |
if not UwU:
|
| 510 |
-
|
| 511 |
m.chat.id,
|
| 512 |
text=tek,
|
| 513 |
reply_markup=button,
|
| 514 |
disable_web_page_preview=True,
|
| 515 |
)
|
| 516 |
else:
|
| 517 |
-
|
| 518 |
m.chat.id,
|
| 519 |
UwU,
|
| 520 |
caption=tek,
|
|
@@ -522,6 +523,7 @@ async def goodbye(c: Gojo, m: Message):
|
|
| 522 |
)
|
| 523 |
return
|
| 524 |
|
|
|
|
| 525 |
__PLUGIN__ = "greetings"
|
| 526 |
__alt_name__ = ["welcome", "goodbye", "cleanservice"]
|
| 527 |
|
|
|
|
| 26 |
ChatType = enums.ChatType
|
| 27 |
|
| 28 |
|
| 29 |
+
async def escape_mentions_using_curly_brackets_wl(
|
| 30 |
+
user: User,
|
| 31 |
+
m: Message,
|
| 32 |
+
text: str,
|
| 33 |
+
parse_words: list,
|
| 34 |
) -> str:
|
| 35 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
| 36 |
if teks:
|
|
|
|
| 157 |
await m.reply_text("Please provide some data for this to reply with!")
|
| 158 |
return
|
| 159 |
|
| 160 |
+
db.set_welcome_text(text, msgtype, file)
|
| 161 |
await m.reply_text("Saved welcome!")
|
| 162 |
return
|
| 163 |
|
|
|
|
| 195 |
await m.reply_text("Please provide some data for this to reply with!")
|
| 196 |
return
|
| 197 |
|
| 198 |
+
db.set_goodbye_text(text, msgtype, file)
|
| 199 |
await m.reply_text("Saved goodbye!")
|
| 200 |
return
|
| 201 |
|
|
|
|
| 206 |
if m and not m.from_user:
|
| 207 |
return
|
| 208 |
text = "Sad to see you leaving {first}.\nTake Care!"
|
| 209 |
+
db.set_goodbye_text(text, None)
|
| 210 |
await m.reply_text("Ok Done!")
|
| 211 |
return
|
| 212 |
|
|
|
|
| 217 |
if m and not m.from_user:
|
| 218 |
return
|
| 219 |
text = "Hey {first}, welcome to {chatname}!"
|
| 220 |
+
db.set_welcome_text(text, None)
|
| 221 |
await m.reply_text("Done!")
|
| 222 |
return
|
| 223 |
|
|
|
|
| 232 |
except Exception:
|
| 233 |
pass
|
| 234 |
|
| 235 |
+
|
| 236 |
@Gojo.on_message(filters.group & filters.new_chat_members & ~captcha_filter, group=69)
|
| 237 |
async def member_has_joined(c: Gojo, m: Message):
|
| 238 |
users: List[User] = m.new_chat_members
|
|
|
|
| 257 |
)
|
| 258 |
continue
|
| 259 |
if user.is_bot:
|
| 260 |
+
continue # ignore bots
|
| 261 |
except ChatAdminRequired:
|
| 262 |
continue
|
| 263 |
status = db.get_welcome_status()
|
|
|
|
| 307 |
disable_web_page_preview=True,
|
| 308 |
)
|
| 309 |
else:
|
| 310 |
+
jj = await (await send_cmd(c, mtype))(
|
| 311 |
m.chat.id,
|
| 312 |
UwU,
|
| 313 |
caption=teks,
|
|
|
|
| 355 |
else:
|
| 356 |
teks = tek
|
| 357 |
|
| 358 |
+
if not teks: # Just in case
|
| 359 |
teks = f"Thanks for being part of this group {user.mention}. But I don't like your arrogance and leaving the group {emoji.EYES}"
|
| 360 |
|
| 361 |
ifff = db.get_current_cleangoodbye_id()
|
|
|
|
| 376 |
try:
|
| 377 |
ooo = (
|
| 378 |
await (await send_cmd(c, mtype))(
|
| 379 |
+
m.chat.id,
|
| 380 |
+
UwU,
|
| 381 |
+
caption=teks,
|
| 382 |
+
reply_markup=button,
|
| 383 |
+
) if UwU else await c.send_message(
|
| 384 |
+
m.chat.id,
|
| 385 |
+
text=teks,
|
| 386 |
+
reply_markup=button,
|
| 387 |
+
disable_web_page_preview=True,
|
| 388 |
+
)
|
| 389 |
)
|
| 390 |
if ooo:
|
| 391 |
db.set_cleangoodbye_id(int(ooo.id))
|
|
|
|
| 446 |
button = await build_keyboard(button)
|
| 447 |
button = ikb(button) if button else None
|
| 448 |
if not UwU:
|
| 449 |
+
await c.send_message(
|
| 450 |
m.chat.id,
|
| 451 |
text=tek,
|
| 452 |
reply_markup=button,
|
| 453 |
disable_web_page_preview=True,
|
| 454 |
)
|
| 455 |
else:
|
| 456 |
+
await (await send_cmd(c, mtype))(
|
| 457 |
m.chat.id,
|
| 458 |
UwU,
|
| 459 |
caption=tek,
|
|
|
|
| 508 |
button = await build_keyboard(button)
|
| 509 |
button = ikb(button) if button else None
|
| 510 |
if not UwU:
|
| 511 |
+
await c.send_message(
|
| 512 |
m.chat.id,
|
| 513 |
text=tek,
|
| 514 |
reply_markup=button,
|
| 515 |
disable_web_page_preview=True,
|
| 516 |
)
|
| 517 |
else:
|
| 518 |
+
await (await send_cmd(c, mtype))(
|
| 519 |
m.chat.id,
|
| 520 |
UwU,
|
| 521 |
caption=tek,
|
|
|
|
| 523 |
)
|
| 524 |
return
|
| 525 |
|
| 526 |
+
|
| 527 |
__PLUGIN__ = "greetings"
|
| 528 |
__alt_name__ = ["welcome", "goodbye", "cleanservice"]
|
| 529 |
|
Powers/plugins/info.py
CHANGED
|
@@ -22,13 +22,13 @@ async def count(c: Gojo, chat):
|
|
| 22 |
try:
|
| 23 |
administrator = []
|
| 24 |
async for admin in c.get_chat_members(
|
| 25 |
-
|
| 26 |
):
|
| 27 |
administrator.append(admin)
|
| 28 |
total_admin = administrator
|
| 29 |
bot = []
|
| 30 |
async for tbot in c.get_chat_members(
|
| 31 |
-
|
| 32 |
):
|
| 33 |
bot.append(tbot)
|
| 34 |
|
|
@@ -36,7 +36,7 @@ async def count(c: Gojo, chat):
|
|
| 36 |
bot_admin = 0
|
| 37 |
ban = []
|
| 38 |
async for banned in c.get_chat_members(
|
| 39 |
-
|
| 40 |
):
|
| 41 |
ban.append(banned)
|
| 42 |
|
|
@@ -90,7 +90,7 @@ async def user_info(c: Gojo, user, already=False):
|
|
| 90 |
is_verified = user.is_verified
|
| 91 |
is_restricted = user.is_restricted
|
| 92 |
photo_id = user.photo.big_file_id if user.photo else None
|
| 93 |
-
is_support =
|
| 94 |
if user_id == c.me.id:
|
| 95 |
is_support = "A person is a great support to himself"
|
| 96 |
omp = "Hmmm.......Who is that again?"
|
|
@@ -114,22 +114,22 @@ async def user_info(c: Gojo, user, already=False):
|
|
| 114 |
status = user.status
|
| 115 |
last_date = "Unable to fetch"
|
| 116 |
if is_bot is True:
|
| 117 |
-
|
| 118 |
if status == enums.UserStatus.RECENTLY:
|
| 119 |
-
|
| 120 |
if status == enums.UserStatus.LAST_WEEK:
|
| 121 |
-
|
| 122 |
if status == enums.UserStatus.LAST_MONTH:
|
| 123 |
-
|
| 124 |
if status == enums.UserStatus.LONG_AGO:
|
| 125 |
-
|
| 126 |
if status == enums.UserStatus.ONLINE:
|
| 127 |
-
|
| 128 |
-
if status == enums.UserStatus.OFFLINE:
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
|
| 134 |
caption = f"""
|
| 135 |
<b><i><u>⚡️ Extracted User info From Telegram ⚡️</b></i></u>
|
|
@@ -173,10 +173,10 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 173 |
GetFullChannel(
|
| 174 |
channel=chat_r
|
| 175 |
)
|
| 176 |
-
)
|
| 177 |
u_name = ll.chats[0].usernames
|
| 178 |
except Exception:
|
| 179 |
-
pass
|
| 180 |
except Exception:
|
| 181 |
try:
|
| 182 |
chat_r = await c.resolve_peer(chat)
|
|
@@ -186,7 +186,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 186 |
GetFullChannel(
|
| 187 |
channel=chat_r
|
| 188 |
)
|
| 189 |
-
)
|
| 190 |
u_name = ll.chats[0].usernames
|
| 191 |
except Exception:
|
| 192 |
pass
|
|
@@ -194,7 +194,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 194 |
caption = f"Failed to find the chat due to\n{e}"
|
| 195 |
return caption, None
|
| 196 |
chat_id = chat.id
|
| 197 |
-
username = " ".join([f"@{i}"for i in u_name]) if u_name else chat.username
|
| 198 |
total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
|
| 199 |
title = chat.title
|
| 200 |
type_ = str(chat.type).split(".")[1]
|
|
@@ -282,7 +282,8 @@ async def info_func(c: Gojo, message: Message):
|
|
| 282 |
LOGGER.error(format_exc())
|
| 283 |
except Exception as e:
|
| 284 |
if e == "User not found ! Error: 'InputPeerChannel' object has no attribute 'user_id'":
|
| 285 |
-
await m.reply_text(
|
|
|
|
| 286 |
return
|
| 287 |
|
| 288 |
await message.reply_text(text=e)
|
|
@@ -300,7 +301,7 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
| 300 |
if len(splited) == 1:
|
| 301 |
if message.reply_to_message and message.reply_to_message.sender_chat:
|
| 302 |
chat = message.reply_to_message.sender_chat.id
|
| 303 |
-
else:
|
| 304 |
chat = message.chat.id
|
| 305 |
|
| 306 |
else:
|
|
@@ -309,15 +310,14 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
| 309 |
try:
|
| 310 |
chat = int(chat)
|
| 311 |
except Exception as ef:
|
| 312 |
-
if "invalid literal for int() with base 10:" in str(ef):
|
| 313 |
-
chat = str(chat)
|
| 314 |
-
if chat.startswith("https://"):
|
| 315 |
-
chat = '@'+chat.split("/")[-1]
|
| 316 |
-
else:
|
| 317 |
return await message.reply_text(
|
| 318 |
f"Got and exception {ef}\n**Usage:**/chinfo [USERNAME|ID]"
|
| 319 |
)
|
| 320 |
|
|
|
|
|
|
|
|
|
|
| 321 |
m = await message.reply_text(
|
| 322 |
"Fetching chat info of chat from telegram's database....."
|
| 323 |
)
|
|
|
|
| 22 |
try:
|
| 23 |
administrator = []
|
| 24 |
async for admin in c.get_chat_members(
|
| 25 |
+
chat_id=chat, filter=enums.ChatMembersFilter.ADMINISTRATORS
|
| 26 |
):
|
| 27 |
administrator.append(admin)
|
| 28 |
total_admin = administrator
|
| 29 |
bot = []
|
| 30 |
async for tbot in c.get_chat_members(
|
| 31 |
+
chat_id=chat, filter=enums.ChatMembersFilter.BOTS
|
| 32 |
):
|
| 33 |
bot.append(tbot)
|
| 34 |
|
|
|
|
| 36 |
bot_admin = 0
|
| 37 |
ban = []
|
| 38 |
async for banned in c.get_chat_members(
|
| 39 |
+
chat, filter=enums.ChatMembersFilter.BANNED
|
| 40 |
):
|
| 41 |
ban.append(banned)
|
| 42 |
|
|
|
|
| 90 |
is_verified = user.is_verified
|
| 91 |
is_restricted = user.is_restricted
|
| 92 |
photo_id = user.photo.big_file_id if user.photo else None
|
| 93 |
+
is_support = user_id in SUPPORT_STAFF
|
| 94 |
if user_id == c.me.id:
|
| 95 |
is_support = "A person is a great support to himself"
|
| 96 |
omp = "Hmmm.......Who is that again?"
|
|
|
|
| 114 |
status = user.status
|
| 115 |
last_date = "Unable to fetch"
|
| 116 |
if is_bot is True:
|
| 117 |
+
last_date = "Targeted user is a bot"
|
| 118 |
if status == enums.UserStatus.RECENTLY:
|
| 119 |
+
last_date = "User was seen recently"
|
| 120 |
if status == enums.UserStatus.LAST_WEEK:
|
| 121 |
+
last_date = "User was seen last week"
|
| 122 |
if status == enums.UserStatus.LAST_MONTH:
|
| 123 |
+
last_date = "User was seen last month"
|
| 124 |
if status == enums.UserStatus.LONG_AGO:
|
| 125 |
+
last_date = "User was seen long ago or may be I am blocked by the user :("
|
| 126 |
if status == enums.UserStatus.ONLINE:
|
| 127 |
+
last_date = "User is online"
|
| 128 |
+
if status == enums.UserStatus.OFFLINE:
|
| 129 |
+
try:
|
| 130 |
+
last_date = datetime.fromtimestamp(user.status.date).strftime("%Y-%m-%d %H:%M:%S")
|
| 131 |
+
except Exception:
|
| 132 |
+
last_date = "User is offline"
|
| 133 |
|
| 134 |
caption = f"""
|
| 135 |
<b><i><u>⚡️ Extracted User info From Telegram ⚡️</b></i></u>
|
|
|
|
| 173 |
GetFullChannel(
|
| 174 |
channel=chat_r
|
| 175 |
)
|
| 176 |
+
)
|
| 177 |
u_name = ll.chats[0].usernames
|
| 178 |
except Exception:
|
| 179 |
+
pass
|
| 180 |
except Exception:
|
| 181 |
try:
|
| 182 |
chat_r = await c.resolve_peer(chat)
|
|
|
|
| 186 |
GetFullChannel(
|
| 187 |
channel=chat_r
|
| 188 |
)
|
| 189 |
+
)
|
| 190 |
u_name = ll.chats[0].usernames
|
| 191 |
except Exception:
|
| 192 |
pass
|
|
|
|
| 194 |
caption = f"Failed to find the chat due to\n{e}"
|
| 195 |
return caption, None
|
| 196 |
chat_id = chat.id
|
| 197 |
+
username = " ".join([f"@{i}" for i in u_name]) if u_name else chat.username
|
| 198 |
total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
|
| 199 |
title = chat.title
|
| 200 |
type_ = str(chat.type).split(".")[1]
|
|
|
|
| 282 |
LOGGER.error(format_exc())
|
| 283 |
except Exception as e:
|
| 284 |
if e == "User not found ! Error: 'InputPeerChannel' object has no attribute 'user_id'":
|
| 285 |
+
await m.reply_text(
|
| 286 |
+
"Looks like you are trying to fetch info of a chat not an user. In that case please use /chinfo")
|
| 287 |
return
|
| 288 |
|
| 289 |
await message.reply_text(text=e)
|
|
|
|
| 301 |
if len(splited) == 1:
|
| 302 |
if message.reply_to_message and message.reply_to_message.sender_chat:
|
| 303 |
chat = message.reply_to_message.sender_chat.id
|
| 304 |
+
else:
|
| 305 |
chat = message.chat.id
|
| 306 |
|
| 307 |
else:
|
|
|
|
| 310 |
try:
|
| 311 |
chat = int(chat)
|
| 312 |
except Exception as ef:
|
| 313 |
+
if "invalid literal for int() with base 10:" not in str(ef):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
return await message.reply_text(
|
| 315 |
f"Got and exception {ef}\n**Usage:**/chinfo [USERNAME|ID]"
|
| 316 |
)
|
| 317 |
|
| 318 |
+
chat = str(chat)
|
| 319 |
+
if chat.startswith("https://"):
|
| 320 |
+
chat = '@' + chat.split("/")[-1]
|
| 321 |
m = await message.reply_text(
|
| 322 |
"Fetching chat info of chat from telegram's database....."
|
| 323 |
)
|
Powers/plugins/locks.py
CHANGED
|
@@ -455,14 +455,15 @@ async def is_approved_user(c: Gojo, m: Message):
|
|
| 455 |
return bool(
|
| 456 |
m.from_user
|
| 457 |
and (
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
)
|
| 463 |
)
|
| 464 |
elif m.forward_from_chat:
|
| 465 |
-
if m.from_user and (
|
|
|
|
| 466 |
return True
|
| 467 |
elif m.automatic_forward:
|
| 468 |
return True
|
|
@@ -470,10 +471,10 @@ async def is_approved_user(c: Gojo, m: Message):
|
|
| 470 |
return False
|
| 471 |
elif m.from_user:
|
| 472 |
return (
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
)
|
| 478 |
else:
|
| 479 |
return False
|
|
@@ -506,10 +507,10 @@ async def lock_del_mess(c: Gojo, m: Message):
|
|
| 506 |
return
|
| 507 |
|
| 508 |
if (
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
):
|
| 514 |
if m.chat.is_admin:
|
| 515 |
return
|
|
|
|
| 455 |
return bool(
|
| 456 |
m.from_user
|
| 457 |
and (
|
| 458 |
+
m.from_user.id in ul
|
| 459 |
+
or m.from_user.id in SUDO_LEVEL
|
| 460 |
+
or m.from_user.id in admins_group
|
| 461 |
+
or m.from_user.id == c.me.id
|
| 462 |
)
|
| 463 |
)
|
| 464 |
elif m.forward_from_chat:
|
| 465 |
+
if m.from_user and (
|
| 466 |
+
m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == c.me.id):
|
| 467 |
return True
|
| 468 |
elif m.automatic_forward:
|
| 469 |
return True
|
|
|
|
| 471 |
return False
|
| 472 |
elif m.from_user:
|
| 473 |
return (
|
| 474 |
+
m.from_user.id in ul
|
| 475 |
+
or m.from_user.id in SUDO_LEVEL
|
| 476 |
+
or m.from_user.id in admins_group
|
| 477 |
+
or m.from_user.id == c.me.id
|
| 478 |
)
|
| 479 |
else:
|
| 480 |
return False
|
|
|
|
| 507 |
return
|
| 508 |
|
| 509 |
if (
|
| 510 |
+
chat_locks["anti_channel"]
|
| 511 |
+
and m.sender_chat
|
| 512 |
+
and not m.forward_from_chat
|
| 513 |
+
and not m.forward_from
|
| 514 |
):
|
| 515 |
if m.chat.is_admin:
|
| 516 |
return
|
Powers/plugins/muting.py
CHANGED
|
@@ -40,7 +40,6 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
| 40 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 41 |
|
| 42 |
if user_id in SUPPORT_STAFF:
|
| 43 |
-
|
| 44 |
await m.reply_text(
|
| 45 |
text="This user is in my support staff, cannot restrict them."
|
| 46 |
)
|
|
@@ -109,8 +108,8 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
| 109 |
reply_to_message_id=r_id,
|
| 110 |
)
|
| 111 |
except Exception:
|
| 112 |
-
await m.reply_text(txt,reply_markup=keyboard, reply_to_message_id=r_id)
|
| 113 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 114 |
except ChatAdminRequired:
|
| 115 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 116 |
except RightForbidden:
|
|
@@ -150,7 +149,6 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
| 150 |
|
| 151 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 152 |
if user_id in SUPPORT_STAFF:
|
| 153 |
-
|
| 154 |
await m.reply_text(
|
| 155 |
text="This user is in my support staff, cannot restrict them."
|
| 156 |
)
|
|
@@ -217,8 +215,8 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
| 217 |
reply_markup=keyboard,
|
| 218 |
)
|
| 219 |
except Exception:
|
| 220 |
-
await m.reply_text(txt,reply_markup=keyboard)
|
| 221 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 222 |
except ChatAdminRequired:
|
| 223 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 224 |
except RightForbidden:
|
|
@@ -346,7 +344,6 @@ async def mute_usr(c: Gojo, m: Message):
|
|
| 346 |
|
| 347 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 348 |
if user_id in SUPPORT_STAFF:
|
| 349 |
-
|
| 350 |
await m.reply_text(
|
| 351 |
text="This user is in my support staff, cannot restrict them."
|
| 352 |
)
|
|
@@ -390,8 +387,8 @@ async def mute_usr(c: Gojo, m: Message):
|
|
| 390 |
reply_to_message_id=r_id,
|
| 391 |
)
|
| 392 |
except Exception:
|
| 393 |
-
await m.reply_text(txt,reply_markup=keyboard, reply_to_message_id=r_id)
|
| 394 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 395 |
except ChatAdminRequired:
|
| 396 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 397 |
except RightForbidden:
|
|
@@ -490,7 +487,6 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
| 490 |
await m.reply_text("Huh, why would I mute myself?")
|
| 491 |
return
|
| 492 |
|
| 493 |
-
|
| 494 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 495 |
if user_id in SUPPORT_STAFF:
|
| 496 |
await m.reply_text(
|
|
@@ -536,8 +532,8 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
| 536 |
reply_markup=keyboard,
|
| 537 |
)
|
| 538 |
except Exception:
|
| 539 |
-
await m.reply_text(txt,reply_markup=keyboard)
|
| 540 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 541 |
except ChatAdminRequired:
|
| 542 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 543 |
except RightForbidden:
|
|
@@ -571,7 +567,7 @@ async def unmute_usr(c: Gojo, m: Message):
|
|
| 571 |
return
|
| 572 |
try:
|
| 573 |
statu = (await m.chat.get_member(user_id)).status
|
| 574 |
-
if statu not in [enums.ChatMemberStatus.BANNED,enums.ChatMemberStatus.RESTRICTED]:
|
| 575 |
await m.reply_text("User is not muted in this chat\nOr using this command as reply to his message")
|
| 576 |
return
|
| 577 |
except Exception as e:
|
|
|
|
| 40 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 41 |
|
| 42 |
if user_id in SUPPORT_STAFF:
|
|
|
|
| 43 |
await m.reply_text(
|
| 44 |
text="This user is in my support staff, cannot restrict them."
|
| 45 |
)
|
|
|
|
| 108 |
reply_to_message_id=r_id,
|
| 109 |
)
|
| 110 |
except Exception:
|
| 111 |
+
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
| 112 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 113 |
except ChatAdminRequired:
|
| 114 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 115 |
except RightForbidden:
|
|
|
|
| 149 |
|
| 150 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 151 |
if user_id in SUPPORT_STAFF:
|
|
|
|
| 152 |
await m.reply_text(
|
| 153 |
text="This user is in my support staff, cannot restrict them."
|
| 154 |
)
|
|
|
|
| 215 |
reply_markup=keyboard,
|
| 216 |
)
|
| 217 |
except Exception:
|
| 218 |
+
await m.reply_text(txt, reply_markup=keyboard)
|
| 219 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 220 |
except ChatAdminRequired:
|
| 221 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 222 |
except RightForbidden:
|
|
|
|
| 344 |
|
| 345 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 346 |
if user_id in SUPPORT_STAFF:
|
|
|
|
| 347 |
await m.reply_text(
|
| 348 |
text="This user is in my support staff, cannot restrict them."
|
| 349 |
)
|
|
|
|
| 387 |
reply_to_message_id=r_id,
|
| 388 |
)
|
| 389 |
except Exception:
|
| 390 |
+
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
| 391 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 392 |
except ChatAdminRequired:
|
| 393 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 394 |
except RightForbidden:
|
|
|
|
| 487 |
await m.reply_text("Huh, why would I mute myself?")
|
| 488 |
return
|
| 489 |
|
|
|
|
| 490 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 491 |
if user_id in SUPPORT_STAFF:
|
| 492 |
await m.reply_text(
|
|
|
|
| 532 |
reply_markup=keyboard,
|
| 533 |
)
|
| 534 |
except Exception:
|
| 535 |
+
await m.reply_text(txt, reply_markup=keyboard)
|
| 536 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
| 537 |
except ChatAdminRequired:
|
| 538 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 539 |
except RightForbidden:
|
|
|
|
| 567 |
return
|
| 568 |
try:
|
| 569 |
statu = (await m.chat.get_member(user_id)).status
|
| 570 |
+
if statu not in [enums.ChatMemberStatus.BANNED, enums.ChatMemberStatus.RESTRICTED]:
|
| 571 |
await m.reply_text("User is not muted in this chat\nOr using this command as reply to his message")
|
| 572 |
return
|
| 573 |
except Exception as e:
|
Powers/plugins/notes.py
CHANGED
|
@@ -73,7 +73,6 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
| 73 |
return
|
| 74 |
|
| 75 |
if priv_notes_status:
|
| 76 |
-
|
| 77 |
note_hash = next(i[1] for i in db.get_all_notes(m.chat.id) if i[0] == note_name)
|
| 78 |
await reply_text(
|
| 79 |
f"Click on the button to get the note <code>{note_name}</code>",
|
|
@@ -150,10 +149,10 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
| 150 |
)
|
| 151 |
return
|
| 152 |
elif msgtype in (
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
):
|
| 158 |
await (await send_cmd(c, msgtype))(
|
| 159 |
m.chat.id,
|
|
@@ -192,7 +191,7 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
| 192 |
reply_markup=button,
|
| 193 |
reply_to_message_id=reply_msg_id,
|
| 194 |
)
|
| 195 |
-
|
| 196 |
except Exception as e:
|
| 197 |
await m.reply_text(f"Error in notes: {e}")
|
| 198 |
return
|
|
@@ -222,10 +221,10 @@ async def get_raw_note(c: Gojo, m: Message, note: str):
|
|
| 222 |
teks, parse_mode=enums.ParseMode.DISABLED, reply_to_message_id=msg_id
|
| 223 |
)
|
| 224 |
elif msgtype in (
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
):
|
| 230 |
await (await send_cmd(c, msgtype))(
|
| 231 |
m.chat.id,
|
|
@@ -241,7 +240,7 @@ async def get_raw_note(c: Gojo, m: Message, note: str):
|
|
| 241 |
parse_mode=enums.ParseMode.DISABLED,
|
| 242 |
reply_to_message_id=msg_id,
|
| 243 |
)
|
| 244 |
-
|
| 245 |
return
|
| 246 |
|
| 247 |
|
|
@@ -267,7 +266,6 @@ async def hash_get(c: Gojo, m: Message):
|
|
| 267 |
|
| 268 |
@Gojo.on_message(command("get") & filters.group & ~filters.bot)
|
| 269 |
async def get_note(c: Gojo, m: Message):
|
| 270 |
-
|
| 271 |
if len(m.text.split()) == 2:
|
| 272 |
priv_notes_status = db_settings.get_privatenotes(m.chat.id)
|
| 273 |
note = ((m.text.split())[1]).lower()
|
|
@@ -290,7 +288,6 @@ async def get_note(c: Gojo, m: Message):
|
|
| 290 |
|
| 291 |
@Gojo.on_message(command(["privnotes", "privatenotes"]) & admin_filter & ~filters.bot)
|
| 292 |
async def priv_notes(_, m: Message):
|
| 293 |
-
|
| 294 |
chat_id = m.chat.id
|
| 295 |
if len(m.text.split()) == 2:
|
| 296 |
option = (m.text.split())[1]
|
|
@@ -353,7 +350,6 @@ async def local_notes(c: Gojo, m: Message):
|
|
| 353 |
|
| 354 |
@Gojo.on_message(command("clear") & admin_filter & ~filters.bot)
|
| 355 |
async def clear_note(_, m: Message):
|
| 356 |
-
|
| 357 |
if len(m.text.split()) <= 1:
|
| 358 |
await m.reply_text("What do you want to clear?")
|
| 359 |
return
|
|
@@ -370,7 +366,6 @@ async def clear_note(_, m: Message):
|
|
| 370 |
|
| 371 |
@Gojo.on_message(command("clearall") & owner_filter & ~filters.bot)
|
| 372 |
async def clear_allnote(_, m: Message):
|
| 373 |
-
|
| 374 |
all_notes = {i[0] for i in db.get_all_notes(m.chat.id)}
|
| 375 |
if not all_notes:
|
| 376 |
await m.reply_text("No notes are there in this chat")
|
|
|
|
| 73 |
return
|
| 74 |
|
| 75 |
if priv_notes_status:
|
|
|
|
| 76 |
note_hash = next(i[1] for i in db.get_all_notes(m.chat.id) if i[0] == note_name)
|
| 77 |
await reply_text(
|
| 78 |
f"Click on the button to get the note <code>{note_name}</code>",
|
|
|
|
| 149 |
)
|
| 150 |
return
|
| 151 |
elif msgtype in (
|
| 152 |
+
Types.STICKER,
|
| 153 |
+
Types.VIDEO_NOTE,
|
| 154 |
+
Types.CONTACT,
|
| 155 |
+
Types.ANIMATED_STICKER,
|
| 156 |
):
|
| 157 |
await (await send_cmd(c, msgtype))(
|
| 158 |
m.chat.id,
|
|
|
|
| 191 |
reply_markup=button,
|
| 192 |
reply_to_message_id=reply_msg_id,
|
| 193 |
)
|
| 194 |
+
|
| 195 |
except Exception as e:
|
| 196 |
await m.reply_text(f"Error in notes: {e}")
|
| 197 |
return
|
|
|
|
| 221 |
teks, parse_mode=enums.ParseMode.DISABLED, reply_to_message_id=msg_id
|
| 222 |
)
|
| 223 |
elif msgtype in (
|
| 224 |
+
Types.STICKER,
|
| 225 |
+
Types.VIDEO_NOTE,
|
| 226 |
+
Types.CONTACT,
|
| 227 |
+
Types.ANIMATED_STICKER,
|
| 228 |
):
|
| 229 |
await (await send_cmd(c, msgtype))(
|
| 230 |
m.chat.id,
|
|
|
|
| 240 |
parse_mode=enums.ParseMode.DISABLED,
|
| 241 |
reply_to_message_id=msg_id,
|
| 242 |
)
|
| 243 |
+
|
| 244 |
return
|
| 245 |
|
| 246 |
|
|
|
|
| 266 |
|
| 267 |
@Gojo.on_message(command("get") & filters.group & ~filters.bot)
|
| 268 |
async def get_note(c: Gojo, m: Message):
|
|
|
|
| 269 |
if len(m.text.split()) == 2:
|
| 270 |
priv_notes_status = db_settings.get_privatenotes(m.chat.id)
|
| 271 |
note = ((m.text.split())[1]).lower()
|
|
|
|
| 288 |
|
| 289 |
@Gojo.on_message(command(["privnotes", "privatenotes"]) & admin_filter & ~filters.bot)
|
| 290 |
async def priv_notes(_, m: Message):
|
|
|
|
| 291 |
chat_id = m.chat.id
|
| 292 |
if len(m.text.split()) == 2:
|
| 293 |
option = (m.text.split())[1]
|
|
|
|
| 350 |
|
| 351 |
@Gojo.on_message(command("clear") & admin_filter & ~filters.bot)
|
| 352 |
async def clear_note(_, m: Message):
|
|
|
|
| 353 |
if len(m.text.split()) <= 1:
|
| 354 |
await m.reply_text("What do you want to clear?")
|
| 355 |
return
|
|
|
|
| 366 |
|
| 367 |
@Gojo.on_message(command("clearall") & owner_filter & ~filters.bot)
|
| 368 |
async def clear_allnote(_, m: Message):
|
|
|
|
| 369 |
all_notes = {i[0] for i in db.get_all_notes(m.chat.id)}
|
| 370 |
if not all_notes:
|
| 371 |
await m.reply_text("No notes are there in this chat")
|
Powers/plugins/pin.py
CHANGED
|
@@ -5,7 +5,7 @@ from pyrogram.errors import ChatAdminRequired, RightForbidden, RPCError
|
|
| 5 |
from pyrogram.filters import regex
|
| 6 |
from pyrogram.types import CallbackQuery, Message
|
| 7 |
|
| 8 |
-
from Powers import LOGGER
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
from Powers.database.pins_db import Pins
|
| 11 |
from Powers.utils.custom_filters import admin_filter, command
|
|
@@ -27,7 +27,6 @@ async def pin_message(_, m: Message):
|
|
| 27 |
disable_notification=disable_notification,
|
| 28 |
)
|
| 29 |
|
| 30 |
-
|
| 31 |
if m.chat.username:
|
| 32 |
# If chat has a username, use this format
|
| 33 |
link_chat_id = m.chat.username
|
|
@@ -69,11 +68,11 @@ async def unpin_message(c: Gojo, m: Message):
|
|
| 69 |
try:
|
| 70 |
if m.reply_to_message:
|
| 71 |
await m.reply_to_message.unpin()
|
| 72 |
-
|
| 73 |
await m.reply_text(text="Unpinned last message.")
|
| 74 |
else:
|
| 75 |
m_id = (await c.get_chat(m.chat.id)).pinned_message.id
|
| 76 |
-
await c.unpin_chat_message(m.chat.id,m_id)
|
| 77 |
await m.reply_text(text="Unpinned last pinned message!")
|
| 78 |
except ChatAdminRequired:
|
| 79 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
|
| 5 |
from pyrogram.filters import regex
|
| 6 |
from pyrogram.types import CallbackQuery, Message
|
| 7 |
|
| 8 |
+
from Powers import LOGGER
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
from Powers.database.pins_db import Pins
|
| 11 |
from Powers.utils.custom_filters import admin_filter, command
|
|
|
|
| 27 |
disable_notification=disable_notification,
|
| 28 |
)
|
| 29 |
|
|
|
|
| 30 |
if m.chat.username:
|
| 31 |
# If chat has a username, use this format
|
| 32 |
link_chat_id = m.chat.username
|
|
|
|
| 68 |
try:
|
| 69 |
if m.reply_to_message:
|
| 70 |
await m.reply_to_message.unpin()
|
| 71 |
+
|
| 72 |
await m.reply_text(text="Unpinned last message.")
|
| 73 |
else:
|
| 74 |
m_id = (await c.get_chat(m.chat.id)).pinned_message.id
|
| 75 |
+
await c.unpin_chat_message(m.chat.id, m_id)
|
| 76 |
await m.reply_text(text="Unpinned last pinned message!")
|
| 77 |
except ChatAdminRequired:
|
| 78 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
Powers/plugins/purge.py
CHANGED
|
@@ -4,14 +4,12 @@ from pyrogram.enums import ChatType
|
|
| 4 |
from pyrogram.errors import MessageDeleteForbidden, RPCError
|
| 5 |
from pyrogram.types import Message
|
| 6 |
|
| 7 |
-
from Powers import SUPPORT_GROUP
|
| 8 |
from Powers.bot_class import Gojo
|
| 9 |
from Powers.utils.custom_filters import admin_filter, command
|
| 10 |
|
| 11 |
|
| 12 |
@Gojo.on_message(command("purge") & admin_filter)
|
| 13 |
async def purge(c: Gojo, m: Message):
|
| 14 |
-
|
| 15 |
if m.chat.type != ChatType.SUPERGROUP:
|
| 16 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 17 |
return
|
|
@@ -21,7 +19,7 @@ async def purge(c: Gojo, m: Message):
|
|
| 21 |
|
| 22 |
def divide_chunks(l: list, n: int = 100):
|
| 23 |
for i in range(0, len(l), n):
|
| 24 |
-
yield l[i
|
| 25 |
|
| 26 |
# Dielete messages in chunks of 100 messages
|
| 27 |
m_list = list(divide_chunks(message_ids))
|
|
@@ -58,7 +56,6 @@ async def purge(c: Gojo, m: Message):
|
|
| 58 |
|
| 59 |
@Gojo.on_message(command("spurge") & admin_filter)
|
| 60 |
async def spurge(c: Gojo, m: Message):
|
| 61 |
-
|
| 62 |
if m.chat.type != ChatType.SUPERGROUP:
|
| 63 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 64 |
return
|
|
@@ -68,7 +65,7 @@ async def spurge(c: Gojo, m: Message):
|
|
| 68 |
|
| 69 |
def divide_chunks(l: list, n: int = 100):
|
| 70 |
for i in range(0, len(l), n):
|
| 71 |
-
yield l[i
|
| 72 |
|
| 73 |
# Dielete messages in chunks of 100 messages
|
| 74 |
m_list = list(divide_chunks(message_ids))
|
|
@@ -101,7 +98,6 @@ async def spurge(c: Gojo, m: Message):
|
|
| 101 |
command("del") & admin_filter,
|
| 102 |
)
|
| 103 |
async def del_msg(c: Gojo, m: Message):
|
| 104 |
-
|
| 105 |
if m.chat.type != ChatType.SUPERGROUP:
|
| 106 |
return
|
| 107 |
|
|
|
|
| 4 |
from pyrogram.errors import MessageDeleteForbidden, RPCError
|
| 5 |
from pyrogram.types import Message
|
| 6 |
|
|
|
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
from Powers.utils.custom_filters import admin_filter, command
|
| 9 |
|
| 10 |
|
| 11 |
@Gojo.on_message(command("purge") & admin_filter)
|
| 12 |
async def purge(c: Gojo, m: Message):
|
|
|
|
| 13 |
if m.chat.type != ChatType.SUPERGROUP:
|
| 14 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 15 |
return
|
|
|
|
| 19 |
|
| 20 |
def divide_chunks(l: list, n: int = 100):
|
| 21 |
for i in range(0, len(l), n):
|
| 22 |
+
yield l[i: i + n]
|
| 23 |
|
| 24 |
# Dielete messages in chunks of 100 messages
|
| 25 |
m_list = list(divide_chunks(message_ids))
|
|
|
|
| 56 |
|
| 57 |
@Gojo.on_message(command("spurge") & admin_filter)
|
| 58 |
async def spurge(c: Gojo, m: Message):
|
|
|
|
| 59 |
if m.chat.type != ChatType.SUPERGROUP:
|
| 60 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 61 |
return
|
|
|
|
| 65 |
|
| 66 |
def divide_chunks(l: list, n: int = 100):
|
| 67 |
for i in range(0, len(l), n):
|
| 68 |
+
yield l[i: i + n]
|
| 69 |
|
| 70 |
# Dielete messages in chunks of 100 messages
|
| 71 |
m_list = list(divide_chunks(message_ids))
|
|
|
|
| 98 |
command("del") & admin_filter,
|
| 99 |
)
|
| 100 |
async def del_msg(c: Gojo, m: Message):
|
|
|
|
| 101 |
if m.chat.type != ChatType.SUPERGROUP:
|
| 102 |
return
|
| 103 |
|
Powers/plugins/report.py
CHANGED
|
@@ -58,7 +58,6 @@ async def report_setting(_, m: Message):
|
|
| 58 |
|
| 59 |
@Gojo.on_message(command("report") & filters.group)
|
| 60 |
async def report_watcher(c: Gojo, m: Message):
|
| 61 |
-
|
| 62 |
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 63 |
return
|
| 64 |
|
|
@@ -76,7 +75,7 @@ async def report_watcher(c: Gojo, m: Message):
|
|
| 76 |
if reported_user.id == me.id:
|
| 77 |
await m.reply_text("Nice try.")
|
| 78 |
return
|
| 79 |
-
|
| 80 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 81 |
if reported_user.id in SUPPORT_STAFF:
|
| 82 |
await m.reply_text("Uh? You reporting my support team?")
|
|
@@ -118,7 +117,6 @@ async def report_watcher(c: Gojo, m: Message):
|
|
| 118 |
],
|
| 119 |
)
|
| 120 |
|
| 121 |
-
|
| 122 |
await m.reply_text(
|
| 123 |
(
|
| 124 |
f"{(await mention_html(m.from_user.first_name, m.from_user.id))} "
|
|
@@ -129,7 +127,7 @@ async def report_watcher(c: Gojo, m: Message):
|
|
| 129 |
|
| 130 |
async for admin in c.get_chat_members(m.chat.id, filter=cmf.ADMINISTRATORS):
|
| 131 |
if (
|
| 132 |
-
|
| 133 |
): # can't message bots or deleted accounts
|
| 134 |
continue
|
| 135 |
if Reporting(admin.user.id).get_settings():
|
|
|
|
| 58 |
|
| 59 |
@Gojo.on_message(command("report") & filters.group)
|
| 60 |
async def report_watcher(c: Gojo, m: Message):
|
|
|
|
| 61 |
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
| 62 |
return
|
| 63 |
|
|
|
|
| 75 |
if reported_user.id == me.id:
|
| 76 |
await m.reply_text("Nice try.")
|
| 77 |
return
|
| 78 |
+
|
| 79 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 80 |
if reported_user.id in SUPPORT_STAFF:
|
| 81 |
await m.reply_text("Uh? You reporting my support team?")
|
|
|
|
| 117 |
],
|
| 118 |
)
|
| 119 |
|
|
|
|
| 120 |
await m.reply_text(
|
| 121 |
(
|
| 122 |
f"{(await mention_html(m.from_user.first_name, m.from_user.id))} "
|
|
|
|
| 127 |
|
| 128 |
async for admin in c.get_chat_members(m.chat.id, filter=cmf.ADMINISTRATORS):
|
| 129 |
if (
|
| 130 |
+
admin.user.is_bot or admin.user.is_deleted
|
| 131 |
): # can't message bots or deleted accounts
|
| 132 |
continue
|
| 133 |
if Reporting(admin.user.id).get_settings():
|
Powers/plugins/rules.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from pyrogram import filters
|
| 2 |
from pyrogram.types import CallbackQuery, Message
|
| 3 |
|
| 4 |
-
from Powers import LOGGER
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
from Powers.database.rules_db import Rules
|
| 7 |
from Powers.utils.custom_filters import admin_filter, command
|
|
|
|
| 1 |
from pyrogram import filters
|
| 2 |
from pyrogram.types import CallbackQuery, Message
|
| 3 |
|
|
|
|
| 4 |
from Powers.bot_class import Gojo
|
| 5 |
from Powers.database.rules_db import Rules
|
| 6 |
from Powers.utils.custom_filters import admin_filter, command
|
Powers/plugins/scheduled_jobs.py
CHANGED
|
@@ -16,12 +16,15 @@ from pyrogram.enums import ChatMemberStatus
|
|
| 16 |
from Powers.utils.extras import birthday_wish
|
| 17 |
|
| 18 |
|
| 19 |
-
def give_date(date,form
|
| 20 |
-
return datetime.strptime(date,form).date()
|
|
|
|
| 21 |
|
| 22 |
scheduler = AsyncIOScheduler()
|
| 23 |
scheduler.timezone = TIME_ZONE
|
| 24 |
-
scheduler_time = time(0,0,0)
|
|
|
|
|
|
|
| 25 |
async def send_wishish(JJK: Client):
|
| 26 |
c_list = Chats.list_chats_by_id()
|
| 27 |
blist = list(bday_info.find())
|
|
@@ -37,16 +40,16 @@ async def send_wishish(JJK: Client):
|
|
| 37 |
agee = ""
|
| 38 |
if i["is_year"]:
|
| 39 |
agee = curr.year - dob.year
|
| 40 |
-
if int(agee/10) == 1:
|
| 41 |
suf = "th"
|
| 42 |
else:
|
| 43 |
suffix = {1: 'st', 2: 'nd', 3: 'rd'}
|
| 44 |
-
suffix.get((agee%10), "th")
|
| 45 |
agee = f"{agee}{suf}"
|
| 46 |
-
U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
|
| 47 |
wish = choice(birthday_wish)
|
| 48 |
-
if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
| 49 |
-
xXx = await JJK.send_message(j,f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
|
| 50 |
try:
|
| 51 |
await xXx.pin()
|
| 52 |
except Exception:
|
|
@@ -54,6 +57,7 @@ async def send_wishish(JJK: Client):
|
|
| 54 |
except Exception:
|
| 55 |
pass
|
| 56 |
|
|
|
|
| 57 |
""""
|
| 58 |
from datetime import date, datetime
|
| 59 |
|
|
@@ -71,4 +75,3 @@ else:
|
|
| 71 |
print(days_left)
|
| 72 |
print(x.year - timm.year)
|
| 73 |
"""
|
| 74 |
-
|
|
|
|
| 16 |
from Powers.utils.extras import birthday_wish
|
| 17 |
|
| 18 |
|
| 19 |
+
def give_date(date, form="%d/%m/%Y"):
|
| 20 |
+
return datetime.strptime(date, form).date()
|
| 21 |
+
|
| 22 |
|
| 23 |
scheduler = AsyncIOScheduler()
|
| 24 |
scheduler.timezone = TIME_ZONE
|
| 25 |
+
scheduler_time = time(0, 0, 0)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
async def send_wishish(JJK: Client):
|
| 29 |
c_list = Chats.list_chats_by_id()
|
| 30 |
blist = list(bday_info.find())
|
|
|
|
| 40 |
agee = ""
|
| 41 |
if i["is_year"]:
|
| 42 |
agee = curr.year - dob.year
|
| 43 |
+
if int(agee / 10) == 1:
|
| 44 |
suf = "th"
|
| 45 |
else:
|
| 46 |
suffix = {1: 'st', 2: 'nd', 3: 'rd'}
|
| 47 |
+
suffix.get((agee % 10), "th")
|
| 48 |
agee = f"{agee}{suf}"
|
| 49 |
+
U = await JJK.get_chat_member(chat_id=j, user_id=i["user_id"])
|
| 50 |
wish = choice(birthday_wish)
|
| 51 |
+
if U.status in [ChatMemberStatus.MEMBER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
| 52 |
+
xXx = await JJK.send_message(j, f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
|
| 53 |
try:
|
| 54 |
await xXx.pin()
|
| 55 |
except Exception:
|
|
|
|
| 57 |
except Exception:
|
| 58 |
pass
|
| 59 |
|
| 60 |
+
|
| 61 |
""""
|
| 62 |
from datetime import date, datetime
|
| 63 |
|
|
|
|
| 75 |
print(days_left)
|
| 76 |
print(x.year - timm.year)
|
| 77 |
"""
|
|
|
Powers/plugins/search.py
CHANGED
|
@@ -14,12 +14,13 @@ from Powers.utils.custom_filters import command
|
|
| 14 |
from Powers.utils.http_helper import *
|
| 15 |
from Powers.utils.kbhelpers import ikb
|
| 16 |
|
| 17 |
-
#have to add youtube
|
| 18 |
|
| 19 |
gsearch = GoogleSearch()
|
| 20 |
anisearch = AnimeSearch()
|
| 21 |
stsearch = StackSearch()
|
| 22 |
|
|
|
|
| 23 |
@Gojo.on_message(command('google'))
|
| 24 |
async def g_search(c: Gojo, m: Message):
|
| 25 |
split = m.text.split(None, 1)
|
|
@@ -157,6 +158,7 @@ async def anime_search(c: Gojo, m: Message):
|
|
| 157 |
LOGGER.error(format_exc())
|
| 158 |
return
|
| 159 |
|
|
|
|
| 160 |
@Gojo.on_message(command('stack'))
|
| 161 |
async def stack_search(c: Gojo, m: Message):
|
| 162 |
split = m.text.split(None, 1)
|
|
@@ -240,7 +242,8 @@ async def getText(message: Message):
|
|
| 240 |
except Exception:
|
| 241 |
return None
|
| 242 |
|
| 243 |
-
|
|
|
|
| 244 |
async def get_image_search(_, m: Message):
|
| 245 |
# Credits: https://t.me/NovaXMod
|
| 246 |
# https://t.me/NovaXMod/98
|
|
@@ -262,8 +265,8 @@ async def get_image_search(_, m: Message):
|
|
| 262 |
except Exception:
|
| 263 |
await ab.edit("Error occurred while sending images. Please try again.")
|
| 264 |
|
| 265 |
-
__PLUGIN__ = "search"
|
| 266 |
|
|
|
|
| 267 |
|
| 268 |
__alt_name__ = [
|
| 269 |
"google",
|
|
|
|
| 14 |
from Powers.utils.http_helper import *
|
| 15 |
from Powers.utils.kbhelpers import ikb
|
| 16 |
|
| 17 |
+
# have to add youtube
|
| 18 |
|
| 19 |
gsearch = GoogleSearch()
|
| 20 |
anisearch = AnimeSearch()
|
| 21 |
stsearch = StackSearch()
|
| 22 |
|
| 23 |
+
|
| 24 |
@Gojo.on_message(command('google'))
|
| 25 |
async def g_search(c: Gojo, m: Message):
|
| 26 |
split = m.text.split(None, 1)
|
|
|
|
| 158 |
LOGGER.error(format_exc())
|
| 159 |
return
|
| 160 |
|
| 161 |
+
|
| 162 |
@Gojo.on_message(command('stack'))
|
| 163 |
async def stack_search(c: Gojo, m: Message):
|
| 164 |
split = m.text.split(None, 1)
|
|
|
|
| 242 |
except Exception:
|
| 243 |
return None
|
| 244 |
|
| 245 |
+
|
| 246 |
+
@Gojo.on_message(command(["images", "imgs"]))
|
| 247 |
async def get_image_search(_, m: Message):
|
| 248 |
# Credits: https://t.me/NovaXMod
|
| 249 |
# https://t.me/NovaXMod/98
|
|
|
|
| 265 |
except Exception:
|
| 266 |
await ab.edit("Error occurred while sending images. Please try again.")
|
| 267 |
|
|
|
|
| 268 |
|
| 269 |
+
__PLUGIN__ = "search"
|
| 270 |
|
| 271 |
__alt_name__ = [
|
| 272 |
"google",
|
Powers/plugins/start.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
from random import choice
|
| 3 |
from time import gmtime, strftime, time
|
| 4 |
|
|
@@ -67,14 +66,13 @@ async def close_admin_callback(_, q: CallbackQuery):
|
|
| 67 |
command("start") & (filters.group | filters.private),
|
| 68 |
)
|
| 69 |
async def start(c: Gojo, m: Message):
|
| 70 |
-
|
| 71 |
if m.chat.type == ChatType.PRIVATE:
|
| 72 |
if len(m.text.strip().split()) > 1:
|
| 73 |
arg = m.text.split(None, 1)[1]
|
| 74 |
help_option = arg.lower()
|
| 75 |
|
| 76 |
if help_option.startswith("note") and (
|
| 77 |
-
|
| 78 |
):
|
| 79 |
await get_private_note(c, m, help_option)
|
| 80 |
return
|
|
@@ -229,7 +227,7 @@ You can use {", ".join(PREFIX_HANDLER)} as your prefix handler
|
|
| 229 |
@Gojo.on_message(command("help"))
|
| 230 |
async def help_menu(c: Gojo, m: Message):
|
| 231 |
if len(m.text.split()) >= 2:
|
| 232 |
-
textt = m.text.replace(" ", "_",).replace("_", " ", 1)
|
| 233 |
help_option = (textt.split(None)[1]).lower()
|
| 234 |
help_msg, help_kb = await get_help_msg(c, m, help_option)
|
| 235 |
|
|
@@ -299,7 +297,7 @@ Commands available:
|
|
| 299 |
return
|
| 300 |
|
| 301 |
|
| 302 |
-
async def get_divided_msg(plugin_name: str, page:int=1, back_to_do
|
| 303 |
msg = HELP_COMMANDS[plugin_name]["help_msg"]
|
| 304 |
msg = msg.split("\n")
|
| 305 |
l = len(msg)
|
|
@@ -349,7 +347,8 @@ async def get_divided_msg(plugin_name: str, page:int=1, back_to_do = None):
|
|
| 349 |
]
|
| 350 |
kb = ikb(kb, True, back_to_do) if back_to_do else ikb(kb)
|
| 351 |
return new_msg, kb
|
| 352 |
-
|
|
|
|
| 353 |
@Gojo.on_callback_query(filters.regex(r"^iter_page_.*[0-9]$"))
|
| 354 |
async def helppp_page_iter(c: Gojo, q: CallbackQuery):
|
| 355 |
data = q.data.split("_")
|
|
@@ -450,7 +449,8 @@ async def give_bot_staffs(c: Gojo, q: CallbackQuery):
|
|
| 450 |
except RPCError:
|
| 451 |
pass
|
| 452 |
|
| 453 |
-
await q.edit_message_caption(reply,
|
|
|
|
| 454 |
return
|
| 455 |
|
| 456 |
|
|
|
|
|
|
|
| 1 |
from random import choice
|
| 2 |
from time import gmtime, strftime, time
|
| 3 |
|
|
|
|
| 66 |
command("start") & (filters.group | filters.private),
|
| 67 |
)
|
| 68 |
async def start(c: Gojo, m: Message):
|
|
|
|
| 69 |
if m.chat.type == ChatType.PRIVATE:
|
| 70 |
if len(m.text.strip().split()) > 1:
|
| 71 |
arg = m.text.split(None, 1)[1]
|
| 72 |
help_option = arg.lower()
|
| 73 |
|
| 74 |
if help_option.startswith("note") and (
|
| 75 |
+
help_option not in ("note", "notes")
|
| 76 |
):
|
| 77 |
await get_private_note(c, m, help_option)
|
| 78 |
return
|
|
|
|
| 227 |
@Gojo.on_message(command("help"))
|
| 228 |
async def help_menu(c: Gojo, m: Message):
|
| 229 |
if len(m.text.split()) >= 2:
|
| 230 |
+
textt = m.text.replace(" ", "_", ).replace("_", " ", 1)
|
| 231 |
help_option = (textt.split(None)[1]).lower()
|
| 232 |
help_msg, help_kb = await get_help_msg(c, m, help_option)
|
| 233 |
|
|
|
|
| 297 |
return
|
| 298 |
|
| 299 |
|
| 300 |
+
async def get_divided_msg(plugin_name: str, page: int = 1, back_to_do=None):
|
| 301 |
msg = HELP_COMMANDS[plugin_name]["help_msg"]
|
| 302 |
msg = msg.split("\n")
|
| 303 |
l = len(msg)
|
|
|
|
| 347 |
]
|
| 348 |
kb = ikb(kb, True, back_to_do) if back_to_do else ikb(kb)
|
| 349 |
return new_msg, kb
|
| 350 |
+
|
| 351 |
+
|
| 352 |
@Gojo.on_callback_query(filters.regex(r"^iter_page_.*[0-9]$"))
|
| 353 |
async def helppp_page_iter(c: Gojo, q: CallbackQuery):
|
| 354 |
data = q.data.split("_")
|
|
|
|
| 449 |
except RPCError:
|
| 450 |
pass
|
| 451 |
|
| 452 |
+
await q.edit_message_caption(reply,
|
| 453 |
+
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("« Back", "start_back")]]))
|
| 454 |
return
|
| 455 |
|
| 456 |
|
Powers/plugins/stickers.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
from random import choice
|
| 3 |
from traceback import format_exc
|
| 4 |
|
|
@@ -13,15 +12,14 @@ from pyrogram.types import InlineKeyboardMarkup as IKM
|
|
| 13 |
from pyrogram.types import Message
|
| 14 |
|
| 15 |
from Powers import LOGGER
|
| 16 |
-
from Powers.bot_class import Gojo
|
| 17 |
from Powers.utils.custom_filters import command
|
| 18 |
from Powers.utils.sticker_help import *
|
| 19 |
from Powers.utils.string import encode_decode
|
| 20 |
from Powers.utils.web_helpers import get_file_size
|
| 21 |
|
| 22 |
|
| 23 |
-
@Gojo.on_message(command(["stickerinfo","stinfo"]))
|
| 24 |
-
async def give_st_info(c: Gojo
|
| 25 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
| 26 |
await m.reply_text("Reply to a sticker")
|
| 27 |
return
|
|
@@ -41,10 +39,11 @@ Emoji : {st_in.emoji}
|
|
| 41 |
Pack name : {st_in.set_name}
|
| 42 |
"""
|
| 43 |
kb = IKM([[IKB("➕ Add sticker to pack", url=f"https://t.me/addstickers/{st_in.set_name}")]])
|
| 44 |
-
await m.reply_text(st_to_gib,reply_markup=kb)
|
| 45 |
return
|
| 46 |
|
| 47 |
-
|
|
|
|
| 48 |
async def sticker_id_gib(c: Gojo, m: Message):
|
| 49 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
| 50 |
await m.reply_text("Reply to a sticker")
|
|
@@ -55,17 +54,22 @@ async def sticker_id_gib(c: Gojo, m: Message):
|
|
| 55 |
|
| 56 |
|
| 57 |
@Gojo.on_message(command(["kang", "steal"]))
|
| 58 |
-
async def kang(c:Gojo, m: Message):
|
| 59 |
if not m.reply_to_message:
|
| 60 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
| 61 |
-
elif not (m.reply_to_message.animation or m.reply_to_message.sticker or m.reply_to_message.photo or (
|
|
|
|
| 62 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
| 63 |
if not m.from_user:
|
| 64 |
return await m.reply_text("You are anon admin, kang stickers in my pm.")
|
| 65 |
msg = await m.reply_text("Kanging Sticker..")
|
| 66 |
-
is_requ =
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
# Find the proper emoji
|
| 70 |
args = m.text.split()
|
| 71 |
if len(args) > 1:
|
|
@@ -74,23 +78,38 @@ async def kang(c:Gojo, m: Message):
|
|
| 74 |
try:
|
| 75 |
sticker_emoji = m.reply_to_message.sticker.emoji
|
| 76 |
if not sticker_emoji:
|
| 77 |
-
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
sticker_emoji = choice(ran)
|
| 79 |
except Exception:
|
| 80 |
-
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
sticker_emoji = choice(ran)
|
| 82 |
else:
|
| 83 |
edit = await msg.reply_text("No emoji provided choosing a random emoji")
|
| 84 |
-
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
sticker_emoji = choice(ran)
|
| 86 |
await edit.delete()
|
| 87 |
await msg.edit_text(f"Makeing a sticker with {sticker_emoji} emoji")
|
| 88 |
|
| 89 |
# Get the corresponding fileid, resize the file if necessary
|
| 90 |
try:
|
| 91 |
-
if is_requ or m.reply_to_message.animation or m.reply_to_message.video or m.reply_to_message.photo or (
|
|
|
|
|
|
|
| 92 |
# telegram doesn't allow animated and video sticker to be kanged as we do for normal stickers
|
| 93 |
-
if m.reply_to_message.animation or m.reply_to_message.video or (
|
|
|
|
| 94 |
path = await Vsticker(c, m.reply_to_message)
|
| 95 |
SIZE = os.path.getsize(path)
|
| 96 |
if SIZE > 261120:
|
|
@@ -98,7 +117,7 @@ async def kang(c:Gojo, m: Message):
|
|
| 98 |
os.remove(path)
|
| 99 |
return
|
| 100 |
elif is_requ:
|
| 101 |
-
path = await m.reply_to_message.download()
|
| 102 |
else:
|
| 103 |
sizee = (await get_file_size(m.reply_to_message)).split()
|
| 104 |
if (sizee[1] == "mb" and int(sizee[0]) > 10) or sizee[1] == "gb":
|
|
@@ -145,10 +164,11 @@ async def kang(c:Gojo, m: Message):
|
|
| 145 |
while not packname_found:
|
| 146 |
packname = f"CE{m.from_user.id}{packnum}_by_{c.me.username}"
|
| 147 |
kangpack = f"{f'@{m.from_user.username}' if m.from_user.username else m.from_user.first_name[:10]} {f'vOl {str(volume)}' if volume else ''} by @{c.me.username}"
|
| 148 |
-
if limit >= 50:
|
| 149 |
-
await m.reply_text(
|
|
|
|
| 150 |
return
|
| 151 |
-
sticker_set = await get_sticker_set_by_name(c,packname)
|
| 152 |
if not sticker_set:
|
| 153 |
try:
|
| 154 |
sticker_set = await create_sticker_set(
|
|
@@ -166,14 +186,14 @@ async def kang(c:Gojo, m: Message):
|
|
| 166 |
volume += 1
|
| 167 |
continue
|
| 168 |
try:
|
| 169 |
-
await add_sticker_to_set(c,sticker_set,sticker)
|
| 170 |
packname_found = True
|
| 171 |
except StickerEmojiInvalid:
|
| 172 |
return await msg.edit("[ERROR]: INVALID_EMOJI_IN_ARGUMENT")
|
| 173 |
kb = IKM(
|
| 174 |
[
|
| 175 |
[
|
| 176 |
-
IKB("➕ Add Pack ➕",url=f"t.me/addstickers/{packname}")
|
| 177 |
]
|
| 178 |
]
|
| 179 |
)
|
|
@@ -212,6 +232,7 @@ async def kang(c:Gojo, m: Message):
|
|
| 212 |
LOGGER.error(format_exc())
|
| 213 |
return
|
| 214 |
|
|
|
|
| 215 |
@Gojo.on_message(command(["rmsticker", "removesticker"]))
|
| 216 |
async def remove_sticker_from_pack(c: Gojo, m: Message):
|
| 217 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
|
@@ -230,16 +251,17 @@ async def remove_sticker_from_pack(c: Gojo, m: Message):
|
|
| 230 |
|
| 231 |
try:
|
| 232 |
await remove_sticker(c, sticker.file_id)
|
| 233 |
-
await to_modify.edit_text(
|
|
|
|
| 234 |
except Exception as e:
|
| 235 |
await to_modify.delete()
|
| 236 |
await m.reply_text(f"Failed to remove sticker due to:\n{e}\nPlease report this bug using `/bug`")
|
| 237 |
LOGGER.error(e)
|
| 238 |
LOGGER.error(format_exc())
|
| 239 |
return
|
| 240 |
-
|
| 241 |
|
| 242 |
-
|
|
|
|
| 243 |
async def memify_it(c: Gojo, m: Message):
|
| 244 |
if not m.reply_to_message:
|
| 245 |
await m.reply_text("Invalid type.")
|
|
@@ -254,7 +276,7 @@ async def memify_it(c: Gojo, m: Message):
|
|
| 254 |
kb = IKM(
|
| 255 |
[
|
| 256 |
[
|
| 257 |
-
IKB("Join for memes",url="https://t.me/memesofdank")
|
| 258 |
]
|
| 259 |
]
|
| 260 |
)
|
|
@@ -264,14 +286,14 @@ async def memify_it(c: Gojo, m: Message):
|
|
| 264 |
filll = m.command[0][-1]
|
| 265 |
fiil = "black" if filll == "b" else "white"
|
| 266 |
x = await m.reply_text("Memifying...")
|
| 267 |
-
meme = m.text.split(None,1)[1].strip()
|
| 268 |
name = f"@memesofdank_{m.id}.png"
|
| 269 |
path = await rep_to.download(name)
|
| 270 |
is_sticker = bool(rep_to.sticker)
|
| 271 |
-
output = await draw_meme(path,meme,is_sticker,fiil)
|
| 272 |
await x.delete()
|
| 273 |
-
xNx = await m.reply_photo(output[0],reply_markup=kb)
|
| 274 |
-
await xNx.reply_sticker(output[1],reply_markup=kb)
|
| 275 |
try:
|
| 276 |
os.remove(output[0])
|
| 277 |
os.remove(output[1])
|
|
@@ -280,7 +302,8 @@ async def memify_it(c: Gojo, m: Message):
|
|
| 280 |
LOGGER.error(format_exc())
|
| 281 |
return
|
| 282 |
|
| 283 |
-
|
|
|
|
| 284 |
async def get_sticker_from_file(c: Gojo, m: Message):
|
| 285 |
Caption = f"Converted by:\n@{c.me.username}"
|
| 286 |
repl = m.reply_to_message
|
|
@@ -288,14 +311,14 @@ async def get_sticker_from_file(c: Gojo, m: Message):
|
|
| 288 |
await m.reply_text("Reply to a sticker or file")
|
| 289 |
return
|
| 290 |
if (
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
not repl.document
|
| 297 |
or repl.document.mime_type.split("/")[0] not in ["image", "video"]
|
| 298 |
-
|
| 299 |
):
|
| 300 |
await m.reply_text("I only support conversion of plain stickers, images, videos and animation for now")
|
| 301 |
return
|
|
@@ -308,42 +331,43 @@ async def get_sticker_from_file(c: Gojo, m: Message):
|
|
| 308 |
if repl.sticker:
|
| 309 |
if repl.sticker.is_animated:
|
| 310 |
upp = await repl.download()
|
| 311 |
-
up = tgs_to_gif(upp,True)
|
| 312 |
await x.delete()
|
| 313 |
-
await m.reply_animation(up,caption=Caption)
|
| 314 |
elif repl.sticker.is_video:
|
| 315 |
upp = await repl.download()
|
| 316 |
up = await webm_to_gif(upp)
|
| 317 |
await x.delete()
|
| 318 |
-
await m.reply_animation(up,caption=Caption)
|
| 319 |
else:
|
| 320 |
upp = await repl.download()
|
| 321 |
-
up = toimage(upp,is_direc=True)
|
| 322 |
await x.delete()
|
| 323 |
await m.reply_document(up, caption=Caption)
|
| 324 |
os.remove(up)
|
| 325 |
return
|
| 326 |
elif repl.photo:
|
| 327 |
upp = await repl.download()
|
| 328 |
-
up = tosticker(upp,is_direc=True)
|
| 329 |
await x.delete()
|
| 330 |
await m.reply_sticker(up)
|
| 331 |
os.remove(up)
|
| 332 |
return
|
| 333 |
|
| 334 |
elif to_vid:
|
| 335 |
-
up = await Vsticker(c,repl)
|
| 336 |
await x.delete()
|
| 337 |
await m.reply_sticker(up)
|
| 338 |
os.remove(up)
|
| 339 |
return
|
| 340 |
|
|
|
|
| 341 |
@Gojo.on_message(command(["rmsticker", "rmst", "removesticker"]))
|
| 342 |
async def remove_from_MY_pack(c: Gojo, m: Message):
|
| 343 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
| 344 |
await m.reply_text("Please reply to a sticker to remove it from your pack")
|
| 345 |
return
|
| 346 |
-
|
| 347 |
sticker = m.reply_to_message.sticker
|
| 348 |
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
| 349 |
|
|
@@ -361,10 +385,11 @@ async def remove_from_MY_pack(c: Gojo, m: Message):
|
|
| 361 |
LOGGER.error(format_exc(e))
|
| 362 |
return
|
| 363 |
|
|
|
|
| 364 |
@Gojo.on_message(command(["getmypacks", "mypacks", "mysets", "stickerset", "stset"]))
|
| 365 |
async def get_my_sticker_sets(c: Gojo, m: Message):
|
| 366 |
to_del = await m.reply_text("Please wait while I fetch all the sticker set I have created for you.")
|
| 367 |
-
|
| 368 |
txt, kb = await get_all_sticker_packs(c, m.from_user.id)
|
| 369 |
|
| 370 |
await to_del.delete()
|
|
@@ -373,6 +398,7 @@ async def get_my_sticker_sets(c: Gojo, m: Message):
|
|
| 373 |
return
|
| 374 |
await m.reply_text(txt, reply_markup=kb)
|
| 375 |
|
|
|
|
| 376 |
@Gojo.on_message(command(["q", "ss"]))
|
| 377 |
async def quote_the_msg(_, m: Message):
|
| 378 |
if not m.reply_to_message:
|
|
@@ -381,7 +407,6 @@ async def quote_the_msg(_, m: Message):
|
|
| 381 |
|
| 382 |
to_edit = await m.reply_text("Genrating quote...")
|
| 383 |
|
| 384 |
-
msg_data = []
|
| 385 |
if len(m.command) > 1 and m.command[1].lower() == "r":
|
| 386 |
reply_msg = m.reply_to_message.reply_to_message
|
| 387 |
if not reply_msg or not reply_msg.text:
|
|
@@ -408,7 +433,7 @@ async def quote_the_msg(_, m: Message):
|
|
| 408 |
if m.reply_to_message.from_user.emoji_status:
|
| 409 |
emoji_status = str(m.reply_to_message.from_user.emoji_status.custom_emoji_id)
|
| 410 |
|
| 411 |
-
msg_data
|
| 412 |
{
|
| 413 |
"entities": get_msg_entities(m.reply_to_message),
|
| 414 |
"avatar": True,
|
|
@@ -420,8 +445,7 @@ async def quote_the_msg(_, m: Message):
|
|
| 420 |
"text": m.reply_to_message.text,
|
| 421 |
"replyMessage": reply_message,
|
| 422 |
}
|
| 423 |
-
|
| 424 |
-
|
| 425 |
status, path = quotify(msg_data)
|
| 426 |
|
| 427 |
if not status:
|
|
@@ -432,6 +456,7 @@ async def quote_the_msg(_, m: Message):
|
|
| 432 |
await to_edit.delete()
|
| 433 |
os.remove(path)
|
| 434 |
|
|
|
|
| 435 |
@Gojo.on_callback_query(filters.regex(r"^stickers_.*"))
|
| 436 |
async def sticker_callbacks(c: Gojo, q: CallbackQuery):
|
| 437 |
data = q.data.split("_")
|
|
@@ -450,7 +475,8 @@ async def sticker_callbacks(c: Gojo, q: CallbackQuery):
|
|
| 450 |
await q.edit_message_text(txt, reply_markup=kb)
|
| 451 |
|
| 452 |
return
|
| 453 |
-
|
|
|
|
| 454 |
__PLUGIN__ = "sticker"
|
| 455 |
__alt_name__ = [
|
| 456 |
"sticker",
|
|
|
|
|
|
|
| 1 |
from random import choice
|
| 2 |
from traceback import format_exc
|
| 3 |
|
|
|
|
| 12 |
from pyrogram.types import Message
|
| 13 |
|
| 14 |
from Powers import LOGGER
|
|
|
|
| 15 |
from Powers.utils.custom_filters import command
|
| 16 |
from Powers.utils.sticker_help import *
|
| 17 |
from Powers.utils.string import encode_decode
|
| 18 |
from Powers.utils.web_helpers import get_file_size
|
| 19 |
|
| 20 |
|
| 21 |
+
@Gojo.on_message(command(["stickerinfo", "stinfo"]))
|
| 22 |
+
async def give_st_info(c: Gojo, m: Message):
|
| 23 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
| 24 |
await m.reply_text("Reply to a sticker")
|
| 25 |
return
|
|
|
|
| 39 |
Pack name : {st_in.set_name}
|
| 40 |
"""
|
| 41 |
kb = IKM([[IKB("➕ Add sticker to pack", url=f"https://t.me/addstickers/{st_in.set_name}")]])
|
| 42 |
+
await m.reply_text(st_to_gib, reply_markup=kb)
|
| 43 |
return
|
| 44 |
|
| 45 |
+
|
| 46 |
+
@Gojo.on_message(command(["stickerid", "stid"]))
|
| 47 |
async def sticker_id_gib(c: Gojo, m: Message):
|
| 48 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
| 49 |
await m.reply_text("Reply to a sticker")
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
@Gojo.on_message(command(["kang", "steal"]))
|
| 57 |
+
async def kang(c: Gojo, m: Message):
|
| 58 |
if not m.reply_to_message:
|
| 59 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
| 60 |
+
elif not (m.reply_to_message.animation or m.reply_to_message.sticker or m.reply_to_message.photo or (
|
| 61 |
+
m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] in ["image", "video"])):
|
| 62 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
| 63 |
if not m.from_user:
|
| 64 |
return await m.reply_text("You are anon admin, kang stickers in my pm.")
|
| 65 |
msg = await m.reply_text("Kanging Sticker..")
|
| 66 |
+
is_requ = bool(
|
| 67 |
+
m.reply_to_message.sticker
|
| 68 |
+
and (
|
| 69 |
+
m.reply_to_message.sticker.is_animated
|
| 70 |
+
or m.reply_to_message.sticker.is_video
|
| 71 |
+
)
|
| 72 |
+
)
|
| 73 |
# Find the proper emoji
|
| 74 |
args = m.text.split()
|
| 75 |
if len(args) > 1:
|
|
|
|
| 78 |
try:
|
| 79 |
sticker_emoji = m.reply_to_message.sticker.emoji
|
| 80 |
if not sticker_emoji:
|
| 81 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂",
|
| 82 |
+
"🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿",
|
| 83 |
+
"💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨",
|
| 84 |
+
"👨❤️👨", "💑", "👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲",
|
| 85 |
+
"🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣", "😂", "😜", "😎"]
|
| 86 |
sticker_emoji = choice(ran)
|
| 87 |
except Exception:
|
| 88 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹",
|
| 89 |
+
"🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡",
|
| 90 |
+
"🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨", "👨❤️👨", "💑",
|
| 91 |
+
"👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖",
|
| 92 |
+
"👾", "🙌", "🥴", "🥰", "😇", "🤣", "😂", "😜", "😎"]
|
| 93 |
sticker_emoji = choice(ran)
|
| 94 |
else:
|
| 95 |
edit = await msg.reply_text("No emoji provided choosing a random emoji")
|
| 96 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺",
|
| 97 |
+
"🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌",
|
| 98 |
+
"👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨", "👨❤️👨", "💑", "👩❤️👩", "👩❤️👨",
|
| 99 |
+
"💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰",
|
| 100 |
+
"😇", "🤣", "😂", "😜", "😎"]
|
| 101 |
sticker_emoji = choice(ran)
|
| 102 |
await edit.delete()
|
| 103 |
await msg.edit_text(f"Makeing a sticker with {sticker_emoji} emoji")
|
| 104 |
|
| 105 |
# Get the corresponding fileid, resize the file if necessary
|
| 106 |
try:
|
| 107 |
+
if is_requ or m.reply_to_message.animation or m.reply_to_message.video or m.reply_to_message.photo or (
|
| 108 |
+
m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] in ["video",
|
| 109 |
+
"image"]):
|
| 110 |
# telegram doesn't allow animated and video sticker to be kanged as we do for normal stickers
|
| 111 |
+
if m.reply_to_message.animation or m.reply_to_message.video or (
|
| 112 |
+
m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] == "video"):
|
| 113 |
path = await Vsticker(c, m.reply_to_message)
|
| 114 |
SIZE = os.path.getsize(path)
|
| 115 |
if SIZE > 261120:
|
|
|
|
| 117 |
os.remove(path)
|
| 118 |
return
|
| 119 |
elif is_requ:
|
| 120 |
+
path = await m.reply_to_message.download()
|
| 121 |
else:
|
| 122 |
sizee = (await get_file_size(m.reply_to_message)).split()
|
| 123 |
if (sizee[1] == "mb" and int(sizee[0]) > 10) or sizee[1] == "gb":
|
|
|
|
| 164 |
while not packname_found:
|
| 165 |
packname = f"CE{m.from_user.id}{packnum}_by_{c.me.username}"
|
| 166 |
kangpack = f"{f'@{m.from_user.username}' if m.from_user.username else m.from_user.first_name[:10]} {f'vOl {str(volume)}' if volume else ''} by @{c.me.username}"
|
| 167 |
+
if limit >= 50: # To prevent this loop from running forever
|
| 168 |
+
await m.reply_text(
|
| 169 |
+
"Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
|
| 170 |
return
|
| 171 |
+
sticker_set = await get_sticker_set_by_name(c, packname)
|
| 172 |
if not sticker_set:
|
| 173 |
try:
|
| 174 |
sticker_set = await create_sticker_set(
|
|
|
|
| 186 |
volume += 1
|
| 187 |
continue
|
| 188 |
try:
|
| 189 |
+
await add_sticker_to_set(c, sticker_set, sticker)
|
| 190 |
packname_found = True
|
| 191 |
except StickerEmojiInvalid:
|
| 192 |
return await msg.edit("[ERROR]: INVALID_EMOJI_IN_ARGUMENT")
|
| 193 |
kb = IKM(
|
| 194 |
[
|
| 195 |
[
|
| 196 |
+
IKB("➕ Add Pack ➕", url=f"t.me/addstickers/{packname}")
|
| 197 |
]
|
| 198 |
]
|
| 199 |
)
|
|
|
|
| 232 |
LOGGER.error(format_exc())
|
| 233 |
return
|
| 234 |
|
| 235 |
+
|
| 236 |
@Gojo.on_message(command(["rmsticker", "removesticker"]))
|
| 237 |
async def remove_sticker_from_pack(c: Gojo, m: Message):
|
| 238 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
|
|
|
| 251 |
|
| 252 |
try:
|
| 253 |
await remove_sticker(c, sticker.file_id)
|
| 254 |
+
await to_modify.edit_text(
|
| 255 |
+
f"Successfully removed [sticker]({m.reply_to_message.link}) from {sticker_set.set.title}")
|
| 256 |
except Exception as e:
|
| 257 |
await to_modify.delete()
|
| 258 |
await m.reply_text(f"Failed to remove sticker due to:\n{e}\nPlease report this bug using `/bug`")
|
| 259 |
LOGGER.error(e)
|
| 260 |
LOGGER.error(format_exc())
|
| 261 |
return
|
|
|
|
| 262 |
|
| 263 |
+
|
| 264 |
+
@Gojo.on_message(command(["mmfb", "mmfw", "mmf"]))
|
| 265 |
async def memify_it(c: Gojo, m: Message):
|
| 266 |
if not m.reply_to_message:
|
| 267 |
await m.reply_text("Invalid type.")
|
|
|
|
| 276 |
kb = IKM(
|
| 277 |
[
|
| 278 |
[
|
| 279 |
+
IKB("Join for memes", url="https://t.me/memesofdank")
|
| 280 |
]
|
| 281 |
]
|
| 282 |
)
|
|
|
|
| 286 |
filll = m.command[0][-1]
|
| 287 |
fiil = "black" if filll == "b" else "white"
|
| 288 |
x = await m.reply_text("Memifying...")
|
| 289 |
+
meme = m.text.split(None, 1)[1].strip()
|
| 290 |
name = f"@memesofdank_{m.id}.png"
|
| 291 |
path = await rep_to.download(name)
|
| 292 |
is_sticker = bool(rep_to.sticker)
|
| 293 |
+
output = await draw_meme(path, meme, is_sticker, fiil)
|
| 294 |
await x.delete()
|
| 295 |
+
xNx = await m.reply_photo(output[0], reply_markup=kb)
|
| 296 |
+
await xNx.reply_sticker(output[1], reply_markup=kb)
|
| 297 |
try:
|
| 298 |
os.remove(output[0])
|
| 299 |
os.remove(output[1])
|
|
|
|
| 302 |
LOGGER.error(format_exc())
|
| 303 |
return
|
| 304 |
|
| 305 |
+
|
| 306 |
+
@Gojo.on_message(command(["getsticker", "getst"]))
|
| 307 |
async def get_sticker_from_file(c: Gojo, m: Message):
|
| 308 |
Caption = f"Converted by:\n@{c.me.username}"
|
| 309 |
repl = m.reply_to_message
|
|
|
|
| 311 |
await m.reply_text("Reply to a sticker or file")
|
| 312 |
return
|
| 313 |
if (
|
| 314 |
+
not repl.animation
|
| 315 |
+
and not repl.video
|
| 316 |
+
and not repl.sticker
|
| 317 |
+
and not repl.photo
|
| 318 |
+
and (
|
| 319 |
not repl.document
|
| 320 |
or repl.document.mime_type.split("/")[0] not in ["image", "video"]
|
| 321 |
+
)
|
| 322 |
):
|
| 323 |
await m.reply_text("I only support conversion of plain stickers, images, videos and animation for now")
|
| 324 |
return
|
|
|
|
| 331 |
if repl.sticker:
|
| 332 |
if repl.sticker.is_animated:
|
| 333 |
upp = await repl.download()
|
| 334 |
+
up = tgs_to_gif(upp, True)
|
| 335 |
await x.delete()
|
| 336 |
+
await m.reply_animation(up, caption=Caption)
|
| 337 |
elif repl.sticker.is_video:
|
| 338 |
upp = await repl.download()
|
| 339 |
up = await webm_to_gif(upp)
|
| 340 |
await x.delete()
|
| 341 |
+
await m.reply_animation(up, caption=Caption)
|
| 342 |
else:
|
| 343 |
upp = await repl.download()
|
| 344 |
+
up = toimage(upp, is_direc=True)
|
| 345 |
await x.delete()
|
| 346 |
await m.reply_document(up, caption=Caption)
|
| 347 |
os.remove(up)
|
| 348 |
return
|
| 349 |
elif repl.photo:
|
| 350 |
upp = await repl.download()
|
| 351 |
+
up = tosticker(upp, is_direc=True)
|
| 352 |
await x.delete()
|
| 353 |
await m.reply_sticker(up)
|
| 354 |
os.remove(up)
|
| 355 |
return
|
| 356 |
|
| 357 |
elif to_vid:
|
| 358 |
+
up = await Vsticker(c, repl)
|
| 359 |
await x.delete()
|
| 360 |
await m.reply_sticker(up)
|
| 361 |
os.remove(up)
|
| 362 |
return
|
| 363 |
|
| 364 |
+
|
| 365 |
@Gojo.on_message(command(["rmsticker", "rmst", "removesticker"]))
|
| 366 |
async def remove_from_MY_pack(c: Gojo, m: Message):
|
| 367 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
| 368 |
await m.reply_text("Please reply to a sticker to remove it from your pack")
|
| 369 |
return
|
| 370 |
+
|
| 371 |
sticker = m.reply_to_message.sticker
|
| 372 |
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
| 373 |
|
|
|
|
| 385 |
LOGGER.error(format_exc(e))
|
| 386 |
return
|
| 387 |
|
| 388 |
+
|
| 389 |
@Gojo.on_message(command(["getmypacks", "mypacks", "mysets", "stickerset", "stset"]))
|
| 390 |
async def get_my_sticker_sets(c: Gojo, m: Message):
|
| 391 |
to_del = await m.reply_text("Please wait while I fetch all the sticker set I have created for you.")
|
| 392 |
+
|
| 393 |
txt, kb = await get_all_sticker_packs(c, m.from_user.id)
|
| 394 |
|
| 395 |
await to_del.delete()
|
|
|
|
| 398 |
return
|
| 399 |
await m.reply_text(txt, reply_markup=kb)
|
| 400 |
|
| 401 |
+
|
| 402 |
@Gojo.on_message(command(["q", "ss"]))
|
| 403 |
async def quote_the_msg(_, m: Message):
|
| 404 |
if not m.reply_to_message:
|
|
|
|
| 407 |
|
| 408 |
to_edit = await m.reply_text("Genrating quote...")
|
| 409 |
|
|
|
|
| 410 |
if len(m.command) > 1 and m.command[1].lower() == "r":
|
| 411 |
reply_msg = m.reply_to_message.reply_to_message
|
| 412 |
if not reply_msg or not reply_msg.text:
|
|
|
|
| 433 |
if m.reply_to_message.from_user.emoji_status:
|
| 434 |
emoji_status = str(m.reply_to_message.from_user.emoji_status.custom_emoji_id)
|
| 435 |
|
| 436 |
+
msg_data = [
|
| 437 |
{
|
| 438 |
"entities": get_msg_entities(m.reply_to_message),
|
| 439 |
"avatar": True,
|
|
|
|
| 445 |
"text": m.reply_to_message.text,
|
| 446 |
"replyMessage": reply_message,
|
| 447 |
}
|
| 448 |
+
]
|
|
|
|
| 449 |
status, path = quotify(msg_data)
|
| 450 |
|
| 451 |
if not status:
|
|
|
|
| 456 |
await to_edit.delete()
|
| 457 |
os.remove(path)
|
| 458 |
|
| 459 |
+
|
| 460 |
@Gojo.on_callback_query(filters.regex(r"^stickers_.*"))
|
| 461 |
async def sticker_callbacks(c: Gojo, q: CallbackQuery):
|
| 462 |
data = q.data.split("_")
|
|
|
|
| 475 |
await q.edit_message_text(txt, reply_markup=kb)
|
| 476 |
|
| 477 |
return
|
| 478 |
+
|
| 479 |
+
|
| 480 |
__PLUGIN__ = "sticker"
|
| 481 |
__alt_name__ = [
|
| 482 |
"sticker",
|
Powers/plugins/utils.py
CHANGED
|
@@ -23,7 +23,6 @@ from Powers.utils.parser import mention_html
|
|
| 23 |
|
| 24 |
@Gojo.on_message(command("wiki"))
|
| 25 |
async def wiki(_, m: Message):
|
| 26 |
-
|
| 27 |
if len(m.text.split()) <= 1:
|
| 28 |
return await m.reply_text(
|
| 29 |
text="Please check help on how to use this this command."
|
|
@@ -81,6 +80,7 @@ async def gdpr_remove(_, m: Message):
|
|
| 81 |
)
|
| 82 |
await m.stop_propagation()
|
| 83 |
|
|
|
|
| 84 |
@Gojo.on_message(
|
| 85 |
command("lyrics") & (filters.group | filters.private),
|
| 86 |
)
|
|
@@ -102,7 +102,7 @@ async def get_lyrics(_, m: Message):
|
|
| 102 |
em = await m.reply_text(text=f"Finding lyrics for <code>{song_name}<code>...")
|
| 103 |
try:
|
| 104 |
if artist:
|
| 105 |
-
song = genius_lyrics.search_song(query,artist)
|
| 106 |
else:
|
| 107 |
song = genius_lyrics.search_song(query)
|
| 108 |
except Exception as e:
|
|
@@ -113,7 +113,7 @@ async def get_lyrics(_, m: Message):
|
|
| 113 |
if song:
|
| 114 |
if song.lyrics:
|
| 115 |
reply = song.lyrics
|
| 116 |
-
reply = reply.split("\n",1)[1]
|
| 117 |
artist = artist or song.artist
|
| 118 |
else:
|
| 119 |
reply = "Couldn't find any lyrics for that song!"
|
|
@@ -133,12 +133,10 @@ async def get_lyrics(_, m: Message):
|
|
| 133 |
return
|
| 134 |
|
| 135 |
|
| 136 |
-
|
| 137 |
@Gojo.on_message(
|
| 138 |
command("id") & (filters.group | filters.private),
|
| 139 |
)
|
| 140 |
async def id_info(c: Gojo, m: Message):
|
| 141 |
-
|
| 142 |
ChatType = enums.ChatType
|
| 143 |
user_id, _, _ = await extract_user(c, m)
|
| 144 |
try:
|
|
@@ -147,7 +145,8 @@ async def id_info(c: Gojo, m: Message):
|
|
| 147 |
await m.reply_text(txt, parse_mode=enums.ParseMode.HTML)
|
| 148 |
return
|
| 149 |
elif m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP] and not m.reply_to_message:
|
| 150 |
-
await m.reply_text(
|
|
|
|
| 151 |
return
|
| 152 |
|
| 153 |
elif m.chat.type == ChatType.PRIVATE and not m.reply_to_message:
|
|
@@ -184,15 +183,15 @@ Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
|
|
| 184 |
parse_mode=enums.ParseMode.HTML,
|
| 185 |
)
|
| 186 |
elif m.chat.type == ChatType.PRIVATE:
|
| 187 |
-
text=f"Your ID is <code>{m.chat.id}</code>."
|
| 188 |
if m.reply_to_message:
|
| 189 |
if m.forward_from:
|
| 190 |
-
text+=f"Forwarded from user ID <code>{m.forward_from.id}</code>."
|
| 191 |
elif m.forward_from_chat:
|
| 192 |
-
text+=f"Forwarded from user ID <code>{m.forward_from_chat.id}</code>."
|
| 193 |
await m.reply_text(text)
|
| 194 |
else:
|
| 195 |
-
text=f"Chat ID <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>"
|
| 196 |
await m.reply_text(text)
|
| 197 |
return
|
| 198 |
|
|
@@ -229,12 +228,13 @@ async def github(_, m: Message):
|
|
| 229 |
except Exception as e:
|
| 230 |
return await m.reply_text(f"ERROR:\n`{e}`")
|
| 231 |
if r.status_code != 200:
|
| 232 |
-
await m.reply_text(
|
|
|
|
| 233 |
return
|
| 234 |
r = r.json()
|
| 235 |
avtar = r.get("avatar_url", None)
|
| 236 |
if avtar:
|
| 237 |
-
avtar = avtar.rsplit("=",1)
|
| 238 |
avtar.pop(-1)
|
| 239 |
avtar.append("5")
|
| 240 |
avtar = "=".join(avtar)
|
|
@@ -245,10 +245,10 @@ async def github(_, m: Message):
|
|
| 245 |
following = r.get("following", 0)
|
| 246 |
public_repos = r.get("public_repos", 0)
|
| 247 |
bio = r.get("bio", None)
|
| 248 |
-
created_at = r.get("created_at", "NA").replace("T", " ").replace("Z","")
|
| 249 |
location = r.get("location", None)
|
| 250 |
email = r.get("email", None)
|
| 251 |
-
updated_at = r.get("updated_at", "NA").replace("T", " ").replace("Z","")
|
| 252 |
blog = r.get("blog", None)
|
| 253 |
twitter = r.get("twitter_username", None)
|
| 254 |
|
|
@@ -299,6 +299,7 @@ headers = {
|
|
| 299 |
"content-type": "application/json",
|
| 300 |
}
|
| 301 |
|
|
|
|
| 302 |
def paste(content: str):
|
| 303 |
data = {"content": content}
|
| 304 |
resp = resp_post(f"{BASE}api/v1/pastes", data=json.dumps(data), headers=headers)
|
|
@@ -331,7 +332,7 @@ async def paste_func(_, message: Message):
|
|
| 331 |
return await m.edit("Only text files can be pasted.")
|
| 332 |
|
| 333 |
doc = await message.reply_to_message.download()
|
| 334 |
-
exe = doc.rsplit(".",1)[-1]
|
| 335 |
async with aiofiles.open(doc, mode="r") as f:
|
| 336 |
fdata = await f.read()
|
| 337 |
content = fdata
|
|
@@ -359,7 +360,7 @@ async def paste_func(_, message: Message):
|
|
| 359 |
async def tr(_, message):
|
| 360 |
trl = Translator()
|
| 361 |
if message.reply_to_message and (
|
| 362 |
-
|
| 363 |
):
|
| 364 |
if len(message.text.split()) == 1:
|
| 365 |
target_lang = "en"
|
|
@@ -387,6 +388,7 @@ async def tr(_, message):
|
|
| 387 |
f"<b>Translated:</b> from {detectlang} to {target_lang} \n<code>``{tekstr.text}``</code>",
|
| 388 |
)
|
| 389 |
|
|
|
|
| 390 |
@Gojo.on_message(command("bug"))
|
| 391 |
async def reporting_query(c: Gojo, m: Message):
|
| 392 |
repl = m.reply_to_message
|
|
@@ -399,17 +401,18 @@ async def reporting_query(c: Gojo, m: Message):
|
|
| 399 |
txt = "#BUG\n"
|
| 400 |
txt += repl.text.html
|
| 401 |
txt += f"\nReported by: {m.from_user.id} ({m.from_user.mention})"
|
| 402 |
-
kb = InlineKeyboardMarkup([[InlineKeyboardButton("Update channel",url=f"https://t.me/{SUPPORT_GROUP}")],[
|
|
|
|
| 403 |
try:
|
| 404 |
-
z = await c.send_message(MESSAGE_DUMP,txt,parse_mode=enums.ParseMode.HTML)
|
| 405 |
except Exception:
|
| 406 |
txt = repl.text.html
|
| 407 |
-
z = await c.send_message(MESSAGE_DUMP,txt,parse_mode=enums.ParseMode.HTML)
|
| 408 |
await z.reply_text(f"#BUG\nReported by: {m.from_user.id} ({m.from_user.mention})")
|
| 409 |
await repl.delete()
|
| 410 |
-
await m.reply_photo(photo="./extras/Fire.jpg",caption="Successfully reported your bug",reply_markup=kb)
|
| 411 |
ppost = z.link
|
| 412 |
-
await c.send_message(OWNER_ID,f"New bug report\n{ppost}",disable_web_page_preview=True)
|
| 413 |
return
|
| 414 |
|
| 415 |
|
|
|
|
| 23 |
|
| 24 |
@Gojo.on_message(command("wiki"))
|
| 25 |
async def wiki(_, m: Message):
|
|
|
|
| 26 |
if len(m.text.split()) <= 1:
|
| 27 |
return await m.reply_text(
|
| 28 |
text="Please check help on how to use this this command."
|
|
|
|
| 80 |
)
|
| 81 |
await m.stop_propagation()
|
| 82 |
|
| 83 |
+
|
| 84 |
@Gojo.on_message(
|
| 85 |
command("lyrics") & (filters.group | filters.private),
|
| 86 |
)
|
|
|
|
| 102 |
em = await m.reply_text(text=f"Finding lyrics for <code>{song_name}<code>...")
|
| 103 |
try:
|
| 104 |
if artist:
|
| 105 |
+
song = genius_lyrics.search_song(query, artist)
|
| 106 |
else:
|
| 107 |
song = genius_lyrics.search_song(query)
|
| 108 |
except Exception as e:
|
|
|
|
| 113 |
if song:
|
| 114 |
if song.lyrics:
|
| 115 |
reply = song.lyrics
|
| 116 |
+
reply = reply.split("\n", 1)[1]
|
| 117 |
artist = artist or song.artist
|
| 118 |
else:
|
| 119 |
reply = "Couldn't find any lyrics for that song!"
|
|
|
|
| 133 |
return
|
| 134 |
|
| 135 |
|
|
|
|
| 136 |
@Gojo.on_message(
|
| 137 |
command("id") & (filters.group | filters.private),
|
| 138 |
)
|
| 139 |
async def id_info(c: Gojo, m: Message):
|
|
|
|
| 140 |
ChatType = enums.ChatType
|
| 141 |
user_id, _, _ = await extract_user(c, m)
|
| 142 |
try:
|
|
|
|
| 145 |
await m.reply_text(txt, parse_mode=enums.ParseMode.HTML)
|
| 146 |
return
|
| 147 |
elif m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP] and not m.reply_to_message:
|
| 148 |
+
await m.reply_text(
|
| 149 |
+
text=f"This Group's ID is <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>")
|
| 150 |
return
|
| 151 |
|
| 152 |
elif m.chat.type == ChatType.PRIVATE and not m.reply_to_message:
|
|
|
|
| 183 |
parse_mode=enums.ParseMode.HTML,
|
| 184 |
)
|
| 185 |
elif m.chat.type == ChatType.PRIVATE:
|
| 186 |
+
text = f"Your ID is <code>{m.chat.id}</code>."
|
| 187 |
if m.reply_to_message:
|
| 188 |
if m.forward_from:
|
| 189 |
+
text += f"Forwarded from user ID <code>{m.forward_from.id}</code>."
|
| 190 |
elif m.forward_from_chat:
|
| 191 |
+
text += f"Forwarded from user ID <code>{m.forward_from_chat.id}</code>."
|
| 192 |
await m.reply_text(text)
|
| 193 |
else:
|
| 194 |
+
text = f"Chat ID <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>"
|
| 195 |
await m.reply_text(text)
|
| 196 |
return
|
| 197 |
|
|
|
|
| 228 |
except Exception as e:
|
| 229 |
return await m.reply_text(f"ERROR:\n`{e}`")
|
| 230 |
if r.status_code != 200:
|
| 231 |
+
await m.reply_text(
|
| 232 |
+
f"{username} this user is not available on github\nMake sure you have given correct username")
|
| 233 |
return
|
| 234 |
r = r.json()
|
| 235 |
avtar = r.get("avatar_url", None)
|
| 236 |
if avtar:
|
| 237 |
+
avtar = avtar.rsplit("=", 1)
|
| 238 |
avtar.pop(-1)
|
| 239 |
avtar.append("5")
|
| 240 |
avtar = "=".join(avtar)
|
|
|
|
| 245 |
following = r.get("following", 0)
|
| 246 |
public_repos = r.get("public_repos", 0)
|
| 247 |
bio = r.get("bio", None)
|
| 248 |
+
created_at = r.get("created_at", "NA").replace("T", " ").replace("Z", "")
|
| 249 |
location = r.get("location", None)
|
| 250 |
email = r.get("email", None)
|
| 251 |
+
updated_at = r.get("updated_at", "NA").replace("T", " ").replace("Z", "")
|
| 252 |
blog = r.get("blog", None)
|
| 253 |
twitter = r.get("twitter_username", None)
|
| 254 |
|
|
|
|
| 299 |
"content-type": "application/json",
|
| 300 |
}
|
| 301 |
|
| 302 |
+
|
| 303 |
def paste(content: str):
|
| 304 |
data = {"content": content}
|
| 305 |
resp = resp_post(f"{BASE}api/v1/pastes", data=json.dumps(data), headers=headers)
|
|
|
|
| 332 |
return await m.edit("Only text files can be pasted.")
|
| 333 |
|
| 334 |
doc = await message.reply_to_message.download()
|
| 335 |
+
exe = doc.rsplit(".", 1)[-1]
|
| 336 |
async with aiofiles.open(doc, mode="r") as f:
|
| 337 |
fdata = await f.read()
|
| 338 |
content = fdata
|
|
|
|
| 360 |
async def tr(_, message):
|
| 361 |
trl = Translator()
|
| 362 |
if message.reply_to_message and (
|
| 363 |
+
message.reply_to_message.text or message.reply_to_message.caption
|
| 364 |
):
|
| 365 |
if len(message.text.split()) == 1:
|
| 366 |
target_lang = "en"
|
|
|
|
| 388 |
f"<b>Translated:</b> from {detectlang} to {target_lang} \n<code>``{tekstr.text}``</code>",
|
| 389 |
)
|
| 390 |
|
| 391 |
+
|
| 392 |
@Gojo.on_message(command("bug"))
|
| 393 |
async def reporting_query(c: Gojo, m: Message):
|
| 394 |
repl = m.reply_to_message
|
|
|
|
| 401 |
txt = "#BUG\n"
|
| 402 |
txt += repl.text.html
|
| 403 |
txt += f"\nReported by: {m.from_user.id} ({m.from_user.mention})"
|
| 404 |
+
kb = InlineKeyboardMarkup([[InlineKeyboardButton("Update channel", url=f"https://t.me/{SUPPORT_GROUP}")], [
|
| 405 |
+
InlineKeyboardButton("Report on github", url="https://github.com/Gojo-Bots/Gojo_Satoru/issues/new/choose")]])
|
| 406 |
try:
|
| 407 |
+
z = await c.send_message(MESSAGE_DUMP, txt, parse_mode=enums.ParseMode.HTML)
|
| 408 |
except Exception:
|
| 409 |
txt = repl.text.html
|
| 410 |
+
z = await c.send_message(MESSAGE_DUMP, txt, parse_mode=enums.ParseMode.HTML)
|
| 411 |
await z.reply_text(f"#BUG\nReported by: {m.from_user.id} ({m.from_user.mention})")
|
| 412 |
await repl.delete()
|
| 413 |
+
await m.reply_photo(photo="./extras/Fire.jpg", caption="Successfully reported your bug", reply_markup=kb)
|
| 414 |
ppost = z.link
|
| 415 |
+
await c.send_message(OWNER_ID, f"New bug report\n{ppost}", disable_web_page_preview=True)
|
| 416 |
return
|
| 417 |
|
| 418 |
|
Powers/plugins/warns.py
CHANGED
|
@@ -6,7 +6,7 @@ from pyrogram.types import (CallbackQuery, ChatPermissions,
|
|
| 6 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
| 7 |
Message)
|
| 8 |
|
| 9 |
-
from Powers import DEV_USERS,
|
| 10 |
from Powers.bot_class import Gojo
|
| 11 |
from Powers.database.rules_db import Rules
|
| 12 |
from Powers.database.users_db import Users
|
|
@@ -27,7 +27,7 @@ async def warn(c: Gojo, m: Message):
|
|
| 27 |
else:
|
| 28 |
r_id = m.id
|
| 29 |
reason = m.text.split(None, 2)[2] if len(m.text.split()) >= 3 else None
|
| 30 |
-
if
|
| 31 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
| 32 |
return
|
| 33 |
|
|
@@ -77,7 +77,7 @@ async def warn(c: Gojo, m: Message):
|
|
| 77 |
f"\n<b>Reason for last warn</b>:\n{reason}"
|
| 78 |
if reason
|
| 79 |
else "\n"
|
| 80 |
-
|
| 81 |
),
|
| 82 |
reply_to_message_id=r_id,
|
| 83 |
)
|
|
@@ -124,7 +124,6 @@ async def warn(c: Gojo, m: Message):
|
|
| 124 |
|
| 125 |
@Gojo.on_message(command("resetwarns") & restrict_filter)
|
| 126 |
async def reset_warn(c: Gojo, m: Message):
|
| 127 |
-
|
| 128 |
if len(m.command) <= 1 and not m.reply_to_message:
|
| 129 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
| 130 |
return
|
|
@@ -161,7 +160,6 @@ async def reset_warn(c: Gojo, m: Message):
|
|
| 161 |
|
| 162 |
@Gojo.on_message(command("warns") & filters.group)
|
| 163 |
async def list_warns(c: Gojo, m: Message):
|
| 164 |
-
|
| 165 |
user_id, user_first_name, _ = await extract_user(c, m)
|
| 166 |
|
| 167 |
if user_id == c.me.id:
|
|
@@ -191,7 +189,7 @@ async def list_warns(c: Gojo, m: Message):
|
|
| 191 |
if not warns:
|
| 192 |
await m.reply_text("This user has no warns!")
|
| 193 |
return
|
| 194 |
-
msg = f"{(await mention_html(user_first_name,user_id))} has <b>{num_warns}/{warn_settings['warn_limit']}</b> warns!\n\n<b>Reasons:</b>\n"
|
| 195 |
msg += "\n".join([("- No reason" if i is None else f" - {i}") for i in warns])
|
| 196 |
await m.reply_text(msg)
|
| 197 |
return
|
|
@@ -201,7 +199,6 @@ async def list_warns(c: Gojo, m: Message):
|
|
| 201 |
command(["rmwarn", "removewarn"]) & restrict_filter,
|
| 202 |
)
|
| 203 |
async def remove_warn(c: Gojo, m: Message):
|
| 204 |
-
|
| 205 |
if len(m.command) <= 1 and not m.reply_to_message:
|
| 206 |
await m.reply_text(
|
| 207 |
"I can't remove warns of nothing! Tell me user whose warn should be removed!",
|
|
@@ -239,7 +236,7 @@ async def remove_warn(c: Gojo, m: Message):
|
|
| 239 |
_, num_warns = warn_db.remove_warn(user_id)
|
| 240 |
await m.reply_text(
|
| 241 |
(
|
| 242 |
-
f"{(await mention_html(user_first_name,user_id))} now has <b>{num_warns}</b> warnings!\n"
|
| 243 |
"Their last warn was removed."
|
| 244 |
),
|
| 245 |
)
|
|
@@ -248,7 +245,6 @@ async def remove_warn(c: Gojo, m: Message):
|
|
| 248 |
|
| 249 |
@Gojo.on_callback_query(filters.regex("^warn."))
|
| 250 |
async def remove_last_warn_btn(c: Gojo, q: CallbackQuery):
|
| 251 |
-
|
| 252 |
try:
|
| 253 |
admins_group = {i[0] for i in ADMIN_CACHE[q.message.chat.id]}
|
| 254 |
except KeyError:
|
|
|
|
| 6 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
| 7 |
Message)
|
| 8 |
|
| 9 |
+
from Powers import DEV_USERS, SUDO_USERS, TIME_ZONE, WHITELIST_USERS
|
| 10 |
from Powers.bot_class import Gojo
|
| 11 |
from Powers.database.rules_db import Rules
|
| 12 |
from Powers.database.users_db import Users
|
|
|
|
| 27 |
else:
|
| 28 |
r_id = m.id
|
| 29 |
reason = m.text.split(None, 2)[2] if len(m.text.split()) >= 3 else None
|
| 30 |
+
if len(m.command) <= 1 and not m.reply_to_message:
|
| 31 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
| 32 |
return
|
| 33 |
|
|
|
|
| 77 |
f"\n<b>Reason for last warn</b>:\n{reason}"
|
| 78 |
if reason
|
| 79 |
else "\n"
|
| 80 |
+
f"{(await mention_html(user_first_name, user_id))} has been <b>{action}!</b>"
|
| 81 |
),
|
| 82 |
reply_to_message_id=r_id,
|
| 83 |
)
|
|
|
|
| 124 |
|
| 125 |
@Gojo.on_message(command("resetwarns") & restrict_filter)
|
| 126 |
async def reset_warn(c: Gojo, m: Message):
|
|
|
|
| 127 |
if len(m.command) <= 1 and not m.reply_to_message:
|
| 128 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
| 129 |
return
|
|
|
|
| 160 |
|
| 161 |
@Gojo.on_message(command("warns") & filters.group)
|
| 162 |
async def list_warns(c: Gojo, m: Message):
|
|
|
|
| 163 |
user_id, user_first_name, _ = await extract_user(c, m)
|
| 164 |
|
| 165 |
if user_id == c.me.id:
|
|
|
|
| 189 |
if not warns:
|
| 190 |
await m.reply_text("This user has no warns!")
|
| 191 |
return
|
| 192 |
+
msg = f"{(await mention_html(user_first_name, user_id))} has <b>{num_warns}/{warn_settings['warn_limit']}</b> warns!\n\n<b>Reasons:</b>\n"
|
| 193 |
msg += "\n".join([("- No reason" if i is None else f" - {i}") for i in warns])
|
| 194 |
await m.reply_text(msg)
|
| 195 |
return
|
|
|
|
| 199 |
command(["rmwarn", "removewarn"]) & restrict_filter,
|
| 200 |
)
|
| 201 |
async def remove_warn(c: Gojo, m: Message):
|
|
|
|
| 202 |
if len(m.command) <= 1 and not m.reply_to_message:
|
| 203 |
await m.reply_text(
|
| 204 |
"I can't remove warns of nothing! Tell me user whose warn should be removed!",
|
|
|
|
| 236 |
_, num_warns = warn_db.remove_warn(user_id)
|
| 237 |
await m.reply_text(
|
| 238 |
(
|
| 239 |
+
f"{(await mention_html(user_first_name, user_id))} now has <b>{num_warns}</b> warnings!\n"
|
| 240 |
"Their last warn was removed."
|
| 241 |
),
|
| 242 |
)
|
|
|
|
| 245 |
|
| 246 |
@Gojo.on_callback_query(filters.regex("^warn."))
|
| 247 |
async def remove_last_warn_btn(c: Gojo, q: CallbackQuery):
|
|
|
|
| 248 |
try:
|
| 249 |
admins_group = {i[0] for i in ADMIN_CACHE[q.message.chat.id]}
|
| 250 |
except KeyError:
|
Powers/plugins/watchers.py
CHANGED
|
@@ -15,7 +15,6 @@ from Powers.database.blacklist_db import Blacklist
|
|
| 15 |
from Powers.database.group_blacklist import BLACKLIST_CHATS
|
| 16 |
from Powers.database.pins_db import Pins
|
| 17 |
from Powers.database.warns_db import Warns, WarnSettings
|
| 18 |
-
from Powers.supports import get_support_staff
|
| 19 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 20 |
from Powers.utils.parser import mention_html
|
| 21 |
from Powers.utils.regex_utils import regex_searcher
|
|
@@ -23,6 +22,7 @@ from Powers.utils.regex_utils import regex_searcher
|
|
| 23 |
# Initialise
|
| 24 |
gban_db = GBan()
|
| 25 |
|
|
|
|
| 26 |
@Gojo.on_message(filters.linked_channel)
|
| 27 |
async def antichanpin_cleanlinked(c: Gojo, m: Message):
|
| 28 |
try:
|
|
@@ -121,7 +121,7 @@ async def bl_watcher(_, m: Message):
|
|
| 121 |
),
|
| 122 |
)
|
| 123 |
return
|
| 124 |
-
|
| 125 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 126 |
if m.from_user.id in SUPPORT_STAFF:
|
| 127 |
# Don't work on Support Staff!
|
|
@@ -156,7 +156,7 @@ async def bl_watcher(_, m: Message):
|
|
| 156 |
if match:
|
| 157 |
try:
|
| 158 |
await perform_action_blacklist(m, action, trigger)
|
| 159 |
-
|
| 160 |
await m.delete()
|
| 161 |
except RPCError as ef:
|
| 162 |
LOGGER.error(ef)
|
|
@@ -167,11 +167,10 @@ async def bl_watcher(_, m: Message):
|
|
| 167 |
return
|
| 168 |
|
| 169 |
|
| 170 |
-
|
| 171 |
@Gojo.on_message(filters.user(list(ANTISPAM_BANNED)) & filters.group, 5)
|
| 172 |
async def gban_watcher(c: Gojo, m: Message):
|
| 173 |
from Powers import SUPPORT_GROUP
|
| 174 |
-
|
| 175 |
if m and not m.from_user:
|
| 176 |
return
|
| 177 |
|
|
@@ -191,8 +190,8 @@ async def gban_watcher(c: Gojo, m: Message):
|
|
| 191 |
text=f"This user ({user_gbanned}) has been banned globally!\n\nTo get unbanned, appeal at @{SUPPORT_GROUP}")
|
| 192 |
return
|
| 193 |
except (ChatAdminRequired, UserAdminInvalid):
|
| 194 |
-
pass
|
| 195 |
-
|
| 196 |
except RPCError as ef:
|
| 197 |
await c.send_message(
|
| 198 |
MESSAGE_DUMP,
|
|
@@ -202,8 +201,6 @@ async def gban_watcher(c: Gojo, m: Message):
|
|
| 202 |
)
|
| 203 |
|
| 204 |
|
| 205 |
-
|
| 206 |
-
|
| 207 |
@Gojo.on_message(filters.chat(BLACKLIST_CHATS))
|
| 208 |
async def bl_chats_watcher(c: Gojo, m: Message):
|
| 209 |
from Powers import SUPPORT_GROUP
|
|
|
|
| 15 |
from Powers.database.group_blacklist import BLACKLIST_CHATS
|
| 16 |
from Powers.database.pins_db import Pins
|
| 17 |
from Powers.database.warns_db import Warns, WarnSettings
|
|
|
|
| 18 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 19 |
from Powers.utils.parser import mention_html
|
| 20 |
from Powers.utils.regex_utils import regex_searcher
|
|
|
|
| 22 |
# Initialise
|
| 23 |
gban_db = GBan()
|
| 24 |
|
| 25 |
+
|
| 26 |
@Gojo.on_message(filters.linked_channel)
|
| 27 |
async def antichanpin_cleanlinked(c: Gojo, m: Message):
|
| 28 |
try:
|
|
|
|
| 121 |
),
|
| 122 |
)
|
| 123 |
return
|
| 124 |
+
|
| 125 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
| 126 |
if m.from_user.id in SUPPORT_STAFF:
|
| 127 |
# Don't work on Support Staff!
|
|
|
|
| 156 |
if match:
|
| 157 |
try:
|
| 158 |
await perform_action_blacklist(m, action, trigger)
|
| 159 |
+
|
| 160 |
await m.delete()
|
| 161 |
except RPCError as ef:
|
| 162 |
LOGGER.error(ef)
|
|
|
|
| 167 |
return
|
| 168 |
|
| 169 |
|
|
|
|
| 170 |
@Gojo.on_message(filters.user(list(ANTISPAM_BANNED)) & filters.group, 5)
|
| 171 |
async def gban_watcher(c: Gojo, m: Message):
|
| 172 |
from Powers import SUPPORT_GROUP
|
| 173 |
+
|
| 174 |
if m and not m.from_user:
|
| 175 |
return
|
| 176 |
|
|
|
|
| 190 |
text=f"This user ({user_gbanned}) has been banned globally!\n\nTo get unbanned, appeal at @{SUPPORT_GROUP}")
|
| 191 |
return
|
| 192 |
except (ChatAdminRequired, UserAdminInvalid):
|
| 193 |
+
pass # For now just ignore the user in future will let the admins know once or after few times think abt it later
|
| 194 |
+
|
| 195 |
except RPCError as ef:
|
| 196 |
await c.send_message(
|
| 197 |
MESSAGE_DUMP,
|
|
|
|
| 201 |
)
|
| 202 |
|
| 203 |
|
|
|
|
|
|
|
| 204 |
@Gojo.on_message(filters.chat(BLACKLIST_CHATS))
|
| 205 |
async def bl_chats_watcher(c: Gojo, m: Message):
|
| 206 |
from Powers import SUPPORT_GROUP
|
Powers/plugins/web_con.py
CHANGED
|
@@ -1,21 +1,16 @@
|
|
| 1 |
import asyncio
|
| 2 |
-
import os
|
| 3 |
-
import shutil
|
| 4 |
-
from traceback import format_exc
|
| 5 |
|
| 6 |
from pyrogram import filters
|
| 7 |
from pyrogram.types import CallbackQuery
|
| 8 |
from pyrogram.types import InlineKeyboardButton as IKB
|
| 9 |
-
from pyrogram.types import InlineKeyboardMarkup as IKM
|
| 10 |
from pyrogram.types import InputMediaPhoto, InputMediaVideo, Message
|
| 11 |
|
| 12 |
-
from Powers import
|
| 13 |
-
from Powers.bot_class import Gojo
|
| 14 |
from Powers.utils.custom_filters import command
|
| 15 |
from Powers.utils.http_helper import *
|
| 16 |
from Powers.utils.sticker_help import toimage
|
| 17 |
from Powers.utils.web_helpers import *
|
| 18 |
-
from Powers.utils.web_scrapper import INSTAGRAM
|
| 19 |
|
| 20 |
# @Gojo.on_message(command(["songname","insong","songinfo","whichsong","rsong","reversesong"]))
|
| 21 |
# • /whichsong (/songname, /songinfo, /insong, /rsong, /reversesong) : Reply to file to get the song playing in it.
|
|
@@ -107,6 +102,7 @@ from Powers.utils.web_scrapper import INSTAGRAM, SCRAP_DATA
|
|
| 107 |
|
| 108 |
songs = {}
|
| 109 |
|
|
|
|
| 110 |
@Gojo.on_callback_query(filters.regex("^lyrics_"))
|
| 111 |
async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
| 112 |
data = q.data.split("_")[1].split(":")
|
|
@@ -116,17 +112,17 @@ async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
|
| 116 |
except IndexError:
|
| 117 |
artist = None
|
| 118 |
if artist:
|
| 119 |
-
song = genius_lyrics.search_song(song,artist)
|
| 120 |
else:
|
| 121 |
song = genius_lyrics.search_song(song)
|
| 122 |
artist = song.artist
|
| 123 |
if not song.lyrics:
|
| 124 |
-
await q.answer("‼️ No lyrics found ‼️",True)
|
| 125 |
return
|
| 126 |
header = f"{songe.capitalize()} by {artist}"
|
| 127 |
if song.lyrics:
|
| 128 |
await q.answer("Fetching lyrics")
|
| 129 |
-
reply = song.lyrics.split("\n",1)[1]
|
| 130 |
if len(reply) >= 4096:
|
| 131 |
cap = f"{header}\n{reply[:4080]}..."
|
| 132 |
if artist:
|
|
@@ -137,23 +133,24 @@ async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
|
| 137 |
art = ''
|
| 138 |
new_kb = [
|
| 139 |
[
|
| 140 |
-
IKB("Next",f"lyrics_next_{songe}{art}")
|
| 141 |
]
|
| 142 |
[
|
| 143 |
-
IKB("Close","f_close")
|
| 144 |
]
|
| 145 |
]
|
| 146 |
else:
|
| 147 |
cap = f"{header}\n{reply}"
|
| 148 |
new_kb = [
|
| 149 |
[
|
| 150 |
-
IKB("Close","f_close")
|
| 151 |
]
|
| 152 |
]
|
| 153 |
-
await q.message.reply_to_message.reply_text(cap,reply_markup=new_kb)
|
| 154 |
await q.message.delete()
|
| 155 |
return
|
| 156 |
|
|
|
|
| 157 |
@Gojo.on_callback_query(filters.regex("^lyrics_next_") | filters.regex("^lyrics_prev_"))
|
| 158 |
async def lyrics_for_song_next(c: Gojo, q: CallbackQuery):
|
| 159 |
split = q.data.split("_")
|
|
@@ -171,23 +168,23 @@ async def lyrics_for_song_next(c: Gojo, q: CallbackQuery):
|
|
| 171 |
songe = songs[song][artist] if artist else songs[song]
|
| 172 |
except KeyError:
|
| 173 |
if artist:
|
| 174 |
-
songe = genius_lyrics.search_song(song,artist)
|
| 175 |
else:
|
| 176 |
songe = genius_lyrics.search_song(song)
|
| 177 |
next_part = songe[4080:] if todo == "next" else songe[:4080]
|
| 178 |
next_part = f"{header}\n{next_part}"
|
| 179 |
new_kb = [
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
]
|
| 186 |
]
|
|
|
|
| 187 |
await q.edit_message_text(next_part, reply_markup=new_kb)
|
| 188 |
|
| 189 |
|
| 190 |
-
@Gojo.on_message(command(["removebackground","removebg","rmbg"]))
|
| 191 |
async def remove_background(c: Gojo, m: Message):
|
| 192 |
if not is_rmbg:
|
| 193 |
await m.reply_text("Add rmbg api to use this command")
|
|
@@ -210,10 +207,10 @@ async def remove_background(c: Gojo, m: Message):
|
|
| 210 |
file = toimage(filee)
|
| 211 |
else:
|
| 212 |
file = await reply.download()
|
| 213 |
-
finfo = {'image_file':open(file,'rb')}
|
| 214 |
-
Data = {'size':'auto'}
|
| 215 |
-
Headers = {'X-Api-Key':RMBG}
|
| 216 |
-
result = resp_post(URL,files=finfo,data=Data,headers=Headers)
|
| 217 |
await to_edit.delete()
|
| 218 |
contentType = result.headers.get("content-type")
|
| 219 |
if result.status_code != 200:
|
|
@@ -226,7 +223,7 @@ async def remove_background(c: Gojo, m: Message):
|
|
| 226 |
return
|
| 227 |
to_path = "./downloads"
|
| 228 |
to_path = f'{to_path}/no-bg.webp' if reply.sticker else f'{to_path}/no-bg.png'
|
| 229 |
-
with open(to_path,'wb') as out:
|
| 230 |
out.write(result.content)
|
| 231 |
if reply.sticker:
|
| 232 |
await m.reply_sticker(to_path)
|
|
@@ -239,10 +236,11 @@ async def remove_background(c: Gojo, m: Message):
|
|
| 239 |
await asyncio.sleep(5)
|
| 240 |
return
|
| 241 |
|
| 242 |
-
|
|
|
|
| 243 |
async def song_down_up(c: Gojo, m: Message):
|
| 244 |
try:
|
| 245 |
-
splited = m.text.split(None,1)[1].strip()
|
| 246 |
except IndexError:
|
| 247 |
await m.reply_text("**USAGE**\n /song [song name | link]")
|
| 248 |
return
|
|
@@ -250,7 +248,7 @@ async def song_down_up(c: Gojo, m: Message):
|
|
| 250 |
query = _id or splited
|
| 251 |
to_edit = await m.reply_text("⏳")
|
| 252 |
try:
|
| 253 |
-
await youtube_downloader(c,m,query, "a")
|
| 254 |
await to_edit.delete()
|
| 255 |
return
|
| 256 |
except KeyError:
|
|
@@ -262,10 +260,11 @@ async def song_down_up(c: Gojo, m: Message):
|
|
| 262 |
LOGGER.error(format_exc())
|
| 263 |
return
|
| 264 |
|
| 265 |
-
|
|
|
|
| 266 |
async def video_down_up(c: Gojo, m: Message):
|
| 267 |
try:
|
| 268 |
-
splited = m.text.split(None,1)[1].strip()
|
| 269 |
except IndexError:
|
| 270 |
await m.reply_text("**USAGE**\n /vsong [song name | link]")
|
| 271 |
return
|
|
@@ -273,7 +272,7 @@ async def video_down_up(c: Gojo, m: Message):
|
|
| 273 |
query = _id or splited
|
| 274 |
to_edit = await m.reply_text("⏳")
|
| 275 |
try:
|
| 276 |
-
await youtube_downloader(c,m,query,"v")
|
| 277 |
await to_edit.delete()
|
| 278 |
return
|
| 279 |
except KeyError:
|
|
@@ -285,14 +284,15 @@ async def video_down_up(c: Gojo, m: Message):
|
|
| 285 |
LOGGER.error(format_exc())
|
| 286 |
return
|
| 287 |
|
| 288 |
-
|
|
|
|
| 289 |
async def download_instareels(c: Gojo, m: Message):
|
| 290 |
try:
|
| 291 |
reel_ = m.command[1]
|
| 292 |
except IndexError:
|
| 293 |
await m.reply_text("Give me an instagram link to download it...")
|
| 294 |
return
|
| 295 |
-
|
| 296 |
insta = INSTAGRAM(reel_)
|
| 297 |
|
| 298 |
if not insta.is_correct_url():
|
|
@@ -305,14 +305,14 @@ async def download_instareels(c: Gojo, m: Message):
|
|
| 305 |
|
| 306 |
if content["code"] == 69 or content["message"] != "success":
|
| 307 |
return await m.reply_text(content["message"])
|
| 308 |
-
|
| 309 |
try:
|
| 310 |
medias = content["content"]["mediaUrls"]
|
| 311 |
|
| 312 |
to_delete = await to_edit.edit_text("Found media in the link trying to download and upload them please wait")
|
| 313 |
|
| 314 |
to_send = []
|
| 315 |
-
for media in medias:
|
| 316 |
if media["type"] == "image":
|
| 317 |
to_send.append(InputMediaPhoto(media["url"]))
|
| 318 |
else:
|
|
@@ -321,12 +321,12 @@ async def download_instareels(c: Gojo, m: Message):
|
|
| 321 |
await m.reply_media_group(to_send)
|
| 322 |
await to_delete.delete()
|
| 323 |
# shutil.rmtree("./scrapped/")
|
| 324 |
-
|
| 325 |
except KeyError:
|
| 326 |
await to_edit.delete()
|
| 327 |
await m.reply_text("Failed to fetch any media from given url")
|
| 328 |
return
|
| 329 |
-
|
| 330 |
|
| 331 |
__PLUGIN__ = "web support"
|
| 332 |
|
|
|
|
| 1 |
import asyncio
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
from pyrogram import filters
|
| 4 |
from pyrogram.types import CallbackQuery
|
| 5 |
from pyrogram.types import InlineKeyboardButton as IKB
|
|
|
|
| 6 |
from pyrogram.types import InputMediaPhoto, InputMediaVideo, Message
|
| 7 |
|
| 8 |
+
from Powers import RMBG, genius_lyrics, is_rmbg
|
|
|
|
| 9 |
from Powers.utils.custom_filters import command
|
| 10 |
from Powers.utils.http_helper import *
|
| 11 |
from Powers.utils.sticker_help import toimage
|
| 12 |
from Powers.utils.web_helpers import *
|
| 13 |
+
from Powers.utils.web_scrapper import INSTAGRAM
|
| 14 |
|
| 15 |
# @Gojo.on_message(command(["songname","insong","songinfo","whichsong","rsong","reversesong"]))
|
| 16 |
# • /whichsong (/songname, /songinfo, /insong, /rsong, /reversesong) : Reply to file to get the song playing in it.
|
|
|
|
| 102 |
|
| 103 |
songs = {}
|
| 104 |
|
| 105 |
+
|
| 106 |
@Gojo.on_callback_query(filters.regex("^lyrics_"))
|
| 107 |
async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
| 108 |
data = q.data.split("_")[1].split(":")
|
|
|
|
| 112 |
except IndexError:
|
| 113 |
artist = None
|
| 114 |
if artist:
|
| 115 |
+
song = genius_lyrics.search_song(song, artist)
|
| 116 |
else:
|
| 117 |
song = genius_lyrics.search_song(song)
|
| 118 |
artist = song.artist
|
| 119 |
if not song.lyrics:
|
| 120 |
+
await q.answer("‼️ No lyrics found ‼️", True)
|
| 121 |
return
|
| 122 |
header = f"{songe.capitalize()} by {artist}"
|
| 123 |
if song.lyrics:
|
| 124 |
await q.answer("Fetching lyrics")
|
| 125 |
+
reply = song.lyrics.split("\n", 1)[1]
|
| 126 |
if len(reply) >= 4096:
|
| 127 |
cap = f"{header}\n{reply[:4080]}..."
|
| 128 |
if artist:
|
|
|
|
| 133 |
art = ''
|
| 134 |
new_kb = [
|
| 135 |
[
|
| 136 |
+
IKB("Next", f"lyrics_next_{songe}{art}")
|
| 137 |
]
|
| 138 |
[
|
| 139 |
+
IKB("Close", "f_close")
|
| 140 |
]
|
| 141 |
]
|
| 142 |
else:
|
| 143 |
cap = f"{header}\n{reply}"
|
| 144 |
new_kb = [
|
| 145 |
[
|
| 146 |
+
IKB("Close", "f_close")
|
| 147 |
]
|
| 148 |
]
|
| 149 |
+
await q.message.reply_to_message.reply_text(cap, reply_markup=new_kb)
|
| 150 |
await q.message.delete()
|
| 151 |
return
|
| 152 |
|
| 153 |
+
|
| 154 |
@Gojo.on_callback_query(filters.regex("^lyrics_next_") | filters.regex("^lyrics_prev_"))
|
| 155 |
async def lyrics_for_song_next(c: Gojo, q: CallbackQuery):
|
| 156 |
split = q.data.split("_")
|
|
|
|
| 168 |
songe = songs[song][artist] if artist else songs[song]
|
| 169 |
except KeyError:
|
| 170 |
if artist:
|
| 171 |
+
songe = genius_lyrics.search_song(song, artist)
|
| 172 |
else:
|
| 173 |
songe = genius_lyrics.search_song(song)
|
| 174 |
next_part = songe[4080:] if todo == "next" else songe[:4080]
|
| 175 |
next_part = f"{header}\n{next_part}"
|
| 176 |
new_kb = [
|
| 177 |
+
[
|
| 178 |
+
IKB("Next", f"lyrics_prev_{song}{art}")
|
| 179 |
+
]
|
| 180 |
+
[
|
| 181 |
+
IKB("Close", "f_close")
|
|
|
|
| 182 |
]
|
| 183 |
+
]
|
| 184 |
await q.edit_message_text(next_part, reply_markup=new_kb)
|
| 185 |
|
| 186 |
|
| 187 |
+
@Gojo.on_message(command(["removebackground", "removebg", "rmbg"]))
|
| 188 |
async def remove_background(c: Gojo, m: Message):
|
| 189 |
if not is_rmbg:
|
| 190 |
await m.reply_text("Add rmbg api to use this command")
|
|
|
|
| 207 |
file = toimage(filee)
|
| 208 |
else:
|
| 209 |
file = await reply.download()
|
| 210 |
+
finfo = {'image_file': open(file, 'rb')}
|
| 211 |
+
Data = {'size': 'auto'}
|
| 212 |
+
Headers = {'X-Api-Key': RMBG}
|
| 213 |
+
result = resp_post(URL, files=finfo, data=Data, headers=Headers)
|
| 214 |
await to_edit.delete()
|
| 215 |
contentType = result.headers.get("content-type")
|
| 216 |
if result.status_code != 200:
|
|
|
|
| 223 |
return
|
| 224 |
to_path = "./downloads"
|
| 225 |
to_path = f'{to_path}/no-bg.webp' if reply.sticker else f'{to_path}/no-bg.png'
|
| 226 |
+
with open(to_path, 'wb') as out:
|
| 227 |
out.write(result.content)
|
| 228 |
if reply.sticker:
|
| 229 |
await m.reply_sticker(to_path)
|
|
|
|
| 236 |
await asyncio.sleep(5)
|
| 237 |
return
|
| 238 |
|
| 239 |
+
|
| 240 |
+
@Gojo.on_message(command(["song", "yta"]))
|
| 241 |
async def song_down_up(c: Gojo, m: Message):
|
| 242 |
try:
|
| 243 |
+
splited = m.text.split(None, 1)[1].strip()
|
| 244 |
except IndexError:
|
| 245 |
await m.reply_text("**USAGE**\n /song [song name | link]")
|
| 246 |
return
|
|
|
|
| 248 |
query = _id or splited
|
| 249 |
to_edit = await m.reply_text("⏳")
|
| 250 |
try:
|
| 251 |
+
await youtube_downloader(c, m, query, "a")
|
| 252 |
await to_edit.delete()
|
| 253 |
return
|
| 254 |
except KeyError:
|
|
|
|
| 260 |
LOGGER.error(format_exc())
|
| 261 |
return
|
| 262 |
|
| 263 |
+
|
| 264 |
+
@Gojo.on_message(command(["vsong", "ytv"]))
|
| 265 |
async def video_down_up(c: Gojo, m: Message):
|
| 266 |
try:
|
| 267 |
+
splited = m.text.split(None, 1)[1].strip()
|
| 268 |
except IndexError:
|
| 269 |
await m.reply_text("**USAGE**\n /vsong [song name | link]")
|
| 270 |
return
|
|
|
|
| 272 |
query = _id or splited
|
| 273 |
to_edit = await m.reply_text("⏳")
|
| 274 |
try:
|
| 275 |
+
await youtube_downloader(c, m, query, "v")
|
| 276 |
await to_edit.delete()
|
| 277 |
return
|
| 278 |
except KeyError:
|
|
|
|
| 284 |
LOGGER.error(format_exc())
|
| 285 |
return
|
| 286 |
|
| 287 |
+
|
| 288 |
+
@Gojo.on_message(command(["ig", "instagram", "insta"]))
|
| 289 |
async def download_instareels(c: Gojo, m: Message):
|
| 290 |
try:
|
| 291 |
reel_ = m.command[1]
|
| 292 |
except IndexError:
|
| 293 |
await m.reply_text("Give me an instagram link to download it...")
|
| 294 |
return
|
| 295 |
+
|
| 296 |
insta = INSTAGRAM(reel_)
|
| 297 |
|
| 298 |
if not insta.is_correct_url():
|
|
|
|
| 305 |
|
| 306 |
if content["code"] == 69 or content["message"] != "success":
|
| 307 |
return await m.reply_text(content["message"])
|
| 308 |
+
|
| 309 |
try:
|
| 310 |
medias = content["content"]["mediaUrls"]
|
| 311 |
|
| 312 |
to_delete = await to_edit.edit_text("Found media in the link trying to download and upload them please wait")
|
| 313 |
|
| 314 |
to_send = []
|
| 315 |
+
for media in medias:
|
| 316 |
if media["type"] == "image":
|
| 317 |
to_send.append(InputMediaPhoto(media["url"]))
|
| 318 |
else:
|
|
|
|
| 321 |
await m.reply_media_group(to_send)
|
| 322 |
await to_delete.delete()
|
| 323 |
# shutil.rmtree("./scrapped/")
|
| 324 |
+
|
| 325 |
except KeyError:
|
| 326 |
await to_edit.delete()
|
| 327 |
await m.reply_text("Failed to fetch any media from given url")
|
| 328 |
return
|
| 329 |
+
|
| 330 |
|
| 331 |
__PLUGIN__ = "web support"
|
| 332 |
|
Powers/supports.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from Powers import
|
| 2 |
from Powers.database.support_db import SUPPORTS
|
| 3 |
|
| 4 |
|
|
@@ -12,6 +12,7 @@ async def load_support_users():
|
|
| 12 |
support.insert_support_user(int(i), "whitelist")
|
| 13 |
return
|
| 14 |
|
|
|
|
| 15 |
def get_support_staff(want="all"):
|
| 16 |
"""
|
| 17 |
dev, sudo, whitelist, dev_level, sudo_level, all
|
|
@@ -34,6 +35,7 @@ def get_support_staff(want="all"):
|
|
| 34 |
|
| 35 |
return wanted or []
|
| 36 |
|
|
|
|
| 37 |
async def cache_support():
|
| 38 |
dev = get_support_staff("dev")
|
| 39 |
dev.extend([1344569458, 1432756163, int(OWNER_ID)])
|
|
|
|
| 1 |
+
from Powers import OWNER_ID, WHITELIST_USERS
|
| 2 |
from Powers.database.support_db import SUPPORTS
|
| 3 |
|
| 4 |
|
|
|
|
| 12 |
support.insert_support_user(int(i), "whitelist")
|
| 13 |
return
|
| 14 |
|
| 15 |
+
|
| 16 |
def get_support_staff(want="all"):
|
| 17 |
"""
|
| 18 |
dev, sudo, whitelist, dev_level, sudo_level, all
|
|
|
|
| 35 |
|
| 36 |
return wanted or []
|
| 37 |
|
| 38 |
+
|
| 39 |
async def cache_support():
|
| 40 |
dev = get_support_staff("dev")
|
| 41 |
dev.extend([1344569458, 1432756163, int(OWNER_ID)])
|