Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
9ab31c1
1
Parent(s):
4f37112
Pre planned features for `V 2.2.0`
Browse files- Powers/__init__.py +6 -6
- Powers/plugins/afk.py +161 -0
- Powers/plugins/auto_join.py +146 -0
- Powers/plugins/botstaff.py +0 -57
- Powers/plugins/flood.py +4 -28
- Powers/plugins/start.py +55 -4
- Powers/plugins/stickers.py +26 -0
- Powers/plugins/utils.py +55 -4
- Powers/utils/custom_filters.py +73 -1
- Powers/utils/extract_user.py +1 -0
- Powers/utils/start_utils.py +2 -3
- Powers/utils/sticker_help.py +34 -117
- Powers/vars.py +1 -1
Powers/__init__.py
CHANGED
|
@@ -96,12 +96,12 @@ elif not Config.GENIUS_API_TOKEN:
|
|
| 96 |
is_genius_lyrics = False
|
| 97 |
genius_lyrics = False
|
| 98 |
|
| 99 |
-
is_audd = False
|
| 100 |
-
Audd = None
|
| 101 |
-
if Config.AuDD_API:
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
|
| 106 |
is_rmbg = False
|
| 107 |
RMBG = None
|
|
|
|
| 96 |
is_genius_lyrics = False
|
| 97 |
genius_lyrics = False
|
| 98 |
|
| 99 |
+
# is_audd = False
|
| 100 |
+
# Audd = None
|
| 101 |
+
# if Config.AuDD_API:
|
| 102 |
+
# is_audd = True
|
| 103 |
+
# Audd = Config.AuDD_API
|
| 104 |
+
# LOGGER.info("Found Audd api")
|
| 105 |
|
| 106 |
is_rmbg = False
|
| 107 |
RMBG = None
|
Powers/plugins/afk.py
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
+
from random import choice
|
| 3 |
+
|
| 4 |
+
from pyrogram import filters
|
| 5 |
+
from pyrogram.enums import ParseMode as PM
|
| 6 |
+
from pyrogram.types import Message
|
| 7 |
+
|
| 8 |
+
from Powers.bot_class import Gojo
|
| 9 |
+
from Powers.database.afk_db import AFK
|
| 10 |
+
from Powers.plugins import till_date
|
| 11 |
+
from Powers.utils.cmd_senders import send_cmd
|
| 12 |
+
from Powers.utils.custom_filters import afk_filter, command
|
| 13 |
+
from Powers.utils.msg_types import Types, get_afk_type
|
| 14 |
+
|
| 15 |
+
res = [
|
| 16 |
+
"{first} is resting for a while...",
|
| 17 |
+
"{first} living his real life, go and live yours.",
|
| 18 |
+
"{first} is quite busy now-a-days.",
|
| 19 |
+
"I am looking for {first} too...tell me if you see him/her around",
|
| 20 |
+
"{first} ran away from the chat...",
|
| 21 |
+
"{first} is busy in his/her work ||simping||",
|
| 22 |
+
"{first} is busy saving the world",
|
| 23 |
+
"{first} is now tired fighting all the curses"
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
back = [
|
| 27 |
+
"{first} is finally back to life",
|
| 28 |
+
"{first} welcome back",
|
| 29 |
+
"{first} the spy is back watch what you talk about"
|
| 30 |
+
"{first} is now finally back from the dead"
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
@Gojo.on_message(command(["afk","brb"]) & ~filters.private)
|
| 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 |
+
async def get_hours(hour:str):
|
| 58 |
+
tim = hour.strip().split(":")
|
| 59 |
+
txt = ""
|
| 60 |
+
if int(tim[0]):
|
| 61 |
+
txt += tim[0] + " hours "
|
| 62 |
+
if int(tim[1]):
|
| 63 |
+
txt += tim[1] + " minutes "
|
| 64 |
+
if int(round(float(tim[2]))):
|
| 65 |
+
txt += str(round(float(tim[2]))) + " seconds"
|
| 66 |
+
|
| 67 |
+
return txt
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
@Gojo.on_message(afk_filter)
|
| 71 |
+
async def afk_checker(c: Gojo, m: Message):
|
| 72 |
+
afk = AFK()
|
| 73 |
+
back_ = choice(back)
|
| 74 |
+
user = m.from_user.id
|
| 75 |
+
chat = m.chat.id
|
| 76 |
+
repl = m.reply_to_message
|
| 77 |
+
|
| 78 |
+
if repl and repl.from_user:
|
| 79 |
+
rep_user = repl.from_user.id
|
| 80 |
+
else:
|
| 81 |
+
rep_user = False
|
| 82 |
+
|
| 83 |
+
is_afk = afk.check_afk(chat,user)
|
| 84 |
+
is_rep_afk = False
|
| 85 |
+
if rep_user:
|
| 86 |
+
is_rep_afk = afk.check_afk(chat,rep_user)
|
| 87 |
+
|
| 88 |
+
if is_rep_afk and rep_user != user:
|
| 89 |
+
con = afk.get_afk(chat,rep_user)
|
| 90 |
+
time = till_date(con["time"])
|
| 91 |
+
media = con["media"]
|
| 92 |
+
media_type = con["media_type"]
|
| 93 |
+
tim_ = datetime.now() - time
|
| 94 |
+
tim_ = str(tim_).split(",")
|
| 95 |
+
tim = await get_hours(tim_[-1])
|
| 96 |
+
if len(tim_) == 1:
|
| 97 |
+
tims = tim
|
| 98 |
+
elif len(tim_) == 2:
|
| 99 |
+
tims = tim_[0] + " " + tim
|
| 100 |
+
reason = f"{repl.from_user.first_name} is afk since {tims}\n"
|
| 101 |
+
if con['reason'] not in res:
|
| 102 |
+
reason += f"\nDue to: {con['reason'].format(first=repl.from_user.first_name)}"
|
| 103 |
+
else:
|
| 104 |
+
reason += f"\n{con['reason'].format(first=repl.from_user.first_name)}"
|
| 105 |
+
txt = reason
|
| 106 |
+
|
| 107 |
+
if media_type == Types.TEXT:
|
| 108 |
+
await (await send_cmd(c,media_type))(
|
| 109 |
+
chat,
|
| 110 |
+
txt,
|
| 111 |
+
parse_mode=PM.MARKDOWN,
|
| 112 |
+
reply_to_message_id=m.id,
|
| 113 |
+
)
|
| 114 |
+
else:
|
| 115 |
+
await (await send_cmd(c,media_type))(
|
| 116 |
+
chat,
|
| 117 |
+
media,
|
| 118 |
+
txt,
|
| 119 |
+
parse_mode=PM.MARKDOWN,
|
| 120 |
+
reply_to_message_id=repl.id
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
if is_afk:
|
| 124 |
+
txt = False
|
| 125 |
+
try:
|
| 126 |
+
txt = m.command[0]
|
| 127 |
+
except Exception:
|
| 128 |
+
pass
|
| 129 |
+
|
| 130 |
+
if txt and txt in ["afk","brb"]:
|
| 131 |
+
return
|
| 132 |
+
else:
|
| 133 |
+
con = afk.get_afk(chat,user)
|
| 134 |
+
time = till_date(con["time"])
|
| 135 |
+
tim_ = datetime.now() - time
|
| 136 |
+
tim_ = str(tim_).split(",")
|
| 137 |
+
tim = await get_hours(tim_[-1])
|
| 138 |
+
if len(tim_) == 1:
|
| 139 |
+
tims = tim
|
| 140 |
+
elif len(tim_) == 2:
|
| 141 |
+
tims = tim_[0] + " " + tim
|
| 142 |
+
txt = back_.format(first=m.from_user.mention) + f"\n\nAfk for: {tims}"
|
| 143 |
+
await m.reply_text(txt)
|
| 144 |
+
afk.delete_afk(chat,user)
|
| 145 |
+
return
|
| 146 |
+
|
| 147 |
+
__PLUGIN__ = "afk"
|
| 148 |
+
|
| 149 |
+
_DISABLE_CMDS_ = ["afk","brb"]
|
| 150 |
+
|
| 151 |
+
__alt_name__ = ["brb"]
|
| 152 |
+
|
| 153 |
+
__HELP__ = """
|
| 154 |
+
**AFK**
|
| 155 |
+
• /afk (/brb) [reason | reply to a message]
|
| 156 |
+
|
| 157 |
+
`reply to a message` can be any media or text
|
| 158 |
+
"""
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
|
Powers/plugins/auto_join.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pyrogram import filters
|
| 2 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
| 3 |
+
from pyrogram.types import CallbackQuery, ChatJoinRequest
|
| 4 |
+
from pyrogram.types import InlineKeyboardButton as ikb
|
| 5 |
+
from pyrogram.types import InlineKeyboardMarkup as ikm
|
| 6 |
+
from pyrogram.types import Message
|
| 7 |
+
|
| 8 |
+
from Powers.bot_class import Gojo
|
| 9 |
+
from Powers.database.autojoin_db import AUTOJOIN
|
| 10 |
+
from Powers.supports import get_support_staff
|
| 11 |
+
from Powers.utils.custom_filters import admin_filter, auto_join_filter, command
|
| 12 |
+
|
| 13 |
+
SUPPORT_STAFF = get_support_staff()
|
| 14 |
+
|
| 15 |
+
@Gojo.on_message(command(["joinreq"]) & admin_filter)
|
| 16 |
+
async def accept_join_requests(c: Gojo, m: Message):
|
| 17 |
+
if m.chat.id == m.from_user.id:
|
| 18 |
+
await m.reply_text("Use it in groups")
|
| 19 |
+
return
|
| 20 |
+
|
| 21 |
+
split = m.command
|
| 22 |
+
a_j = AUTOJOIN()
|
| 23 |
+
|
| 24 |
+
if len(split) == 1:
|
| 25 |
+
txt = "**USAGE**\n/joinreq [on | off]"
|
| 26 |
+
await m.reply_text(txt)
|
| 27 |
+
return
|
| 28 |
+
else:
|
| 29 |
+
yes_no = split[1].lower()
|
| 30 |
+
if yes_no not in ["on","off"]:
|
| 31 |
+
txt = "**USAGE**\n/joinreq [on | off]"
|
| 32 |
+
await m.reply_text(txt)
|
| 33 |
+
return
|
| 34 |
+
|
| 35 |
+
else:
|
| 36 |
+
if yes_no == "on":
|
| 37 |
+
is_al = a_j.load_autojoin(m.chat.id)
|
| 38 |
+
|
| 39 |
+
if is_al:
|
| 40 |
+
txt = "Now I will approve all the join request of the chat\nIf you want that I will just notify admins about the join request use command\n//joinreqmode [manual | auto]"
|
| 41 |
+
await m.reply_text(txt)
|
| 42 |
+
return
|
| 43 |
+
else:
|
| 44 |
+
txt = "Auto approve join request is already on for this chat\nIf you want that I will just notify admins about the join request use command\n/joinreqmode [manual | auto]"
|
| 45 |
+
await m.reply_text(txt)
|
| 46 |
+
return
|
| 47 |
+
|
| 48 |
+
elif yes_no == "off":
|
| 49 |
+
a_j.remove_autojoin(m.chat.id)
|
| 50 |
+
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
| 51 |
+
await m.reply_text(txt)
|
| 52 |
+
return
|
| 53 |
+
|
| 54 |
+
@Gojo.on_message(command("joinreqmode") & admin_filter)
|
| 55 |
+
async def join_request_mode(c: Gojo, m: Message):
|
| 56 |
+
if m.chat.id == m.from_user.id:
|
| 57 |
+
await m.reply_text("Use it in groups")
|
| 58 |
+
return
|
| 59 |
+
u_text = "**USAGE**\n/joinreqmode [auto | manual]\nauto: auto approve joins\nmanual: will notify admin about the join request"
|
| 60 |
+
|
| 61 |
+
split = m.command
|
| 62 |
+
a_j = AUTOJOIN()
|
| 63 |
+
|
| 64 |
+
if len(split) == 1:
|
| 65 |
+
await m.reply_text(u_text)
|
| 66 |
+
return
|
| 67 |
+
|
| 68 |
+
else:
|
| 69 |
+
auto_manual = split[1]
|
| 70 |
+
if auto_manual not in ["auto","manual"]:
|
| 71 |
+
await m.reply_text(u_text)
|
| 72 |
+
return
|
| 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 |
+
return
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
@Gojo.on_chat_join_request(auto_join_filter)
|
| 81 |
+
async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
| 82 |
+
user = j.from_user.id
|
| 83 |
+
userr = j.from_user
|
| 84 |
+
chat = j.chat.id
|
| 85 |
+
aj = AUTOJOIN()
|
| 86 |
+
join_type = aj.get_autojoin(chat)
|
| 87 |
+
|
| 88 |
+
if not join_type:
|
| 89 |
+
return
|
| 90 |
+
if join_type == "auto" or user in SUPPORT_STAFF:
|
| 91 |
+
await c.approve_chat_join_request(chat,user)
|
| 92 |
+
|
| 93 |
+
elif join_type == "manual":
|
| 94 |
+
txt = "New join request is available\n**USER's INFO**\n"
|
| 95 |
+
txt += f"Name: {userr.first_name} {userr.last_name if userr.last_name else ''}"
|
| 96 |
+
txt += f"Mention: {userr.mention}"
|
| 97 |
+
txt += f"Id: {user}"
|
| 98 |
+
txt += f"Scam: {'True' if userr.is_scam else 'False'}"
|
| 99 |
+
if userr.username:
|
| 100 |
+
txt+= f"Username: @{userr.username}"
|
| 101 |
+
kb = [
|
| 102 |
+
[
|
| 103 |
+
ikb("Accept",f"accept_joinreq_uest_{user}"),
|
| 104 |
+
ikb("Decline",f"decline_joinreq_uest_{user}")
|
| 105 |
+
]
|
| 106 |
+
]
|
| 107 |
+
await c.send_message(chat,txt,reply_markup=ikm(kb))
|
| 108 |
+
return
|
| 109 |
+
|
| 110 |
+
@Gojo.on_callback_query(filters.regex("^accept_joinreq_uest_") | filters.regex("^decline_joinreq_uest_"))
|
| 111 |
+
async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
| 112 |
+
user_id = q.from_user.id
|
| 113 |
+
user_status = (await q.message.chat.get_member(user_id)).status
|
| 114 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
| 115 |
+
await q.answer(
|
| 116 |
+
"You're not even an admin, don't try this explosive shit!",
|
| 117 |
+
show_alert=True,
|
| 118 |
+
)
|
| 119 |
+
return
|
| 120 |
+
|
| 121 |
+
split = q.data.split("_")
|
| 122 |
+
chat = q.message.chat.id
|
| 123 |
+
user = int(split[-1])
|
| 124 |
+
data = split[0]
|
| 125 |
+
|
| 126 |
+
if data == "accept":
|
| 127 |
+
await c.approve_chat_join_request(chat,user)
|
| 128 |
+
await q.answer(f"APPROVED: {user}",True)
|
| 129 |
+
elif data == "decline":
|
| 130 |
+
await c.decline_chat_join_request(chat,user)
|
| 131 |
+
await q.answer(f"DECLINED: {user}")
|
| 132 |
+
|
| 133 |
+
return
|
| 134 |
+
|
| 135 |
+
__PLUGIN__ = "auto join"
|
| 136 |
+
|
| 137 |
+
__alt_name__ = ["join_request"]
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
__HELP__ = """
|
| 141 |
+
**Auto join request**
|
| 142 |
+
|
| 143 |
+
**Admin commands:**
|
| 144 |
+
• /joinreq [on | off]: To switch on auto accept join request
|
| 145 |
+
• /joinreqmode [auto | manual]: `auto` to accept join request automatically and `manual` to get notified when new join request is available
|
| 146 |
+
"""
|
Powers/plugins/botstaff.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
from pyrogram.errors import RPCError
|
| 2 |
-
from pyrogram.types import Message
|
| 3 |
-
|
| 4 |
-
from Powers import LOGGER, OWNER_ID, WHITELIST_USERS
|
| 5 |
-
from Powers.bot_class import Gojo
|
| 6 |
-
from Powers.supports import get_support_staff
|
| 7 |
-
from Powers.utils.custom_filters import command
|
| 8 |
-
from Powers.utils.parser import mention_html
|
| 9 |
-
|
| 10 |
-
DEV_USERS = get_support_staff("dev")
|
| 11 |
-
SUDO_USERS = get_support_staff("sudo")
|
| 12 |
-
|
| 13 |
-
@Gojo.on_message(command("botstaff", dev_cmd=True))
|
| 14 |
-
async def botstaff(c: Gojo, m: Message):
|
| 15 |
-
try:
|
| 16 |
-
owner = await c.get_users(OWNER_ID)
|
| 17 |
-
reply = f"<b>🌟 Owner:</b> {(await mention_html(owner.first_name, OWNER_ID))} (<code>{OWNER_ID}</code>)\n"
|
| 18 |
-
except RPCError:
|
| 19 |
-
pass
|
| 20 |
-
true_dev = list(set(DEV_USERS) - {OWNER_ID})
|
| 21 |
-
reply += "\n<b>Developers ⚡️:</b>\n"
|
| 22 |
-
if not true_dev:
|
| 23 |
-
reply += "No Dev Users\n"
|
| 24 |
-
else:
|
| 25 |
-
for each_user in true_dev:
|
| 26 |
-
user_id = int(each_user)
|
| 27 |
-
try:
|
| 28 |
-
user = await c.get_users(user_id)
|
| 29 |
-
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 30 |
-
except RPCError:
|
| 31 |
-
pass
|
| 32 |
-
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
| 33 |
-
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
| 34 |
-
if true_sudo == []:
|
| 35 |
-
reply += "No Sudo Users\n"
|
| 36 |
-
else:
|
| 37 |
-
for each_user in true_sudo:
|
| 38 |
-
user_id = int(each_user)
|
| 39 |
-
try:
|
| 40 |
-
user = await c.get_users(user_id)
|
| 41 |
-
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 42 |
-
except RPCError:
|
| 43 |
-
pass
|
| 44 |
-
reply += "\n<b>Whitelisted Users 🐺:</b>\n"
|
| 45 |
-
if WHITELIST_USERS == []:
|
| 46 |
-
reply += "No additional whitelisted users\n"
|
| 47 |
-
else:
|
| 48 |
-
for each_user in WHITELIST_USERS:
|
| 49 |
-
user_id = int(each_user)
|
| 50 |
-
try:
|
| 51 |
-
user = await c.get_users(user_id)
|
| 52 |
-
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 53 |
-
except RPCError:
|
| 54 |
-
pass
|
| 55 |
-
await m.reply_text(reply)
|
| 56 |
-
LOGGER.info(f"{m.from_user.id} fetched botstaff in {m.chat.id}")
|
| 57 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powers/plugins/flood.py
CHANGED
|
@@ -15,7 +15,7 @@ from Powers.bot_class import Gojo
|
|
| 15 |
from Powers.database.approve_db import Approve
|
| 16 |
from Powers.database.flood_db import Floods
|
| 17 |
from Powers.supports import get_support_staff
|
| 18 |
-
from Powers.utils.custom_filters import admin_filter, command
|
| 19 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
| 20 |
from Powers.utils.kbhelpers import ikb
|
| 21 |
from Powers.vars import Config
|
|
@@ -330,41 +330,17 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
| 330 |
return
|
| 331 |
|
| 332 |
dic = {}
|
| 333 |
-
@Gojo.on_message(
|
| 334 |
async def flood_watcher(c: Gojo, m: Message):
|
| 335 |
c_id = m.chat.id
|
| 336 |
|
| 337 |
-
if not m.chat:
|
| 338 |
-
return
|
| 339 |
-
|
| 340 |
Flood = Floods()
|
| 341 |
|
| 342 |
-
|
| 343 |
-
u_id = m.from_user.id
|
| 344 |
-
except AttributeError:
|
| 345 |
-
return # Get this error when the message received is not by an user and return
|
| 346 |
|
| 347 |
is_flood = Flood.is_chat(c_id)
|
| 348 |
|
| 349 |
-
|
| 350 |
-
return # return of chat is not in anti flood protection
|
| 351 |
-
|
| 352 |
-
app_users = Approve(m.chat.id).list_approved()
|
| 353 |
-
|
| 354 |
-
if u_id in {i[0] for i in app_users}:
|
| 355 |
-
return #return if the user is approved
|
| 356 |
-
|
| 357 |
-
if not is_flood or u_id in SUPPORT_STAFF:
|
| 358 |
-
return #return if the user is in support_staff
|
| 359 |
-
|
| 360 |
-
try:
|
| 361 |
-
user_status = (await m.chat.get_member(m.from_user.id)).status
|
| 362 |
-
except Exception:
|
| 363 |
-
return
|
| 364 |
-
|
| 365 |
-
if user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
| 366 |
-
return #return if the user is owner or admin
|
| 367 |
-
|
| 368 |
action = is_flood[2]
|
| 369 |
limit = int(is_flood[0])
|
| 370 |
within = int(is_flood[1])
|
|
|
|
| 15 |
from Powers.database.approve_db import Approve
|
| 16 |
from Powers.database.flood_db import Floods
|
| 17 |
from Powers.supports import get_support_staff
|
| 18 |
+
from Powers.utils.custom_filters import admin_filter, command, flood_filter
|
| 19 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
| 20 |
from Powers.utils.kbhelpers import ikb
|
| 21 |
from Powers.vars import Config
|
|
|
|
| 330 |
return
|
| 331 |
|
| 332 |
dic = {}
|
| 333 |
+
@Gojo.on_message(flood_filter & ~admin_filter)
|
| 334 |
async def flood_watcher(c: Gojo, m: Message):
|
| 335 |
c_id = m.chat.id
|
| 336 |
|
|
|
|
|
|
|
|
|
|
| 337 |
Flood = Floods()
|
| 338 |
|
| 339 |
+
u_id = m.from_user.id
|
|
|
|
|
|
|
|
|
|
| 340 |
|
| 341 |
is_flood = Flood.is_chat(c_id)
|
| 342 |
|
| 343 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
action = is_flood[2]
|
| 345 |
limit = int(is_flood[0])
|
| 346 |
within = int(is_flood[1])
|
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 |
|
|
@@ -6,16 +5,18 @@ from pyrogram import enums, filters
|
|
| 6 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 7 |
from pyrogram.enums import ChatType
|
| 8 |
from pyrogram.errors import (MediaCaptionTooLong, MessageNotModified,
|
| 9 |
-
QueryIdInvalid, UserIsBlocked)
|
| 10 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
| 11 |
InlineKeyboardMarkup, Message)
|
| 12 |
|
| 13 |
-
from Powers import (HELP_COMMANDS, LOGGER,
|
| 14 |
-
UPTIME, VERSION)
|
| 15 |
from Powers.bot_class import Gojo
|
|
|
|
| 16 |
from Powers.utils.custom_filters import command
|
| 17 |
from Powers.utils.extras import StartPic
|
| 18 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
| 19 |
from Powers.utils.start_utils import (gen_cmds_kb, gen_start_kb, get_help_msg,
|
| 20 |
get_private_note, get_private_rules)
|
| 21 |
from Powers.vars import Config
|
|
@@ -301,3 +302,53 @@ async def get_module_info(c: Gojo, q: CallbackQuery):
|
|
| 301 |
await c.send_message(chat_id=q.message.chat.id,text=help_msg,)
|
| 302 |
await q.answer()
|
| 303 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from random import choice
|
| 2 |
from time import gmtime, strftime, time
|
| 3 |
|
|
|
|
| 5 |
from pyrogram.enums import ChatMemberStatus as CMS
|
| 6 |
from pyrogram.enums import ChatType
|
| 7 |
from pyrogram.errors import (MediaCaptionTooLong, MessageNotModified,
|
| 8 |
+
QueryIdInvalid, RPCError, UserIsBlocked)
|
| 9 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
| 10 |
InlineKeyboardMarkup, Message)
|
| 11 |
|
| 12 |
+
from Powers import (HELP_COMMANDS, LOGGER, OWNER_ID, PYROGRAM_VERSION,
|
| 13 |
+
PYTHON_VERSION, UPTIME, VERSION, WHITELIST_USERS)
|
| 14 |
from Powers.bot_class import Gojo
|
| 15 |
+
from Powers.supports import get_support_staff
|
| 16 |
from Powers.utils.custom_filters import command
|
| 17 |
from Powers.utils.extras import StartPic
|
| 18 |
from Powers.utils.kbhelpers import ikb
|
| 19 |
+
from Powers.utils.parser import mention_html
|
| 20 |
from Powers.utils.start_utils import (gen_cmds_kb, gen_start_kb, get_help_msg,
|
| 21 |
get_private_note, get_private_rules)
|
| 22 |
from Powers.vars import Config
|
|
|
|
| 302 |
await c.send_message(chat_id=q.message.chat.id,text=help_msg,)
|
| 303 |
await q.answer()
|
| 304 |
return
|
| 305 |
+
|
| 306 |
+
DEV_USERS = get_support_staff("dev")
|
| 307 |
+
SUDO_USERS = get_support_staff("sudo")
|
| 308 |
+
|
| 309 |
+
@Gojo.on_callback_query(filters.regex("^give_bot_staffs$"))
|
| 310 |
+
async def give_bot_staffs(c: Gojo, q: CallbackQuery):
|
| 311 |
+
try:
|
| 312 |
+
owner = await c.get_users(OWNER_ID)
|
| 313 |
+
reply = f"<b>🌟 Owner:</b> {(await mention_html(owner.first_name, OWNER_ID))} (<code>{OWNER_ID}</code>)\n"
|
| 314 |
+
except RPCError:
|
| 315 |
+
pass
|
| 316 |
+
true_dev = list(set(DEV_USERS) - {OWNER_ID})
|
| 317 |
+
reply += "\n<b>Developers ⚡️:</b>\n"
|
| 318 |
+
if not true_dev:
|
| 319 |
+
reply += "No Dev Users\n"
|
| 320 |
+
else:
|
| 321 |
+
for each_user in true_dev:
|
| 322 |
+
user_id = int(each_user)
|
| 323 |
+
try:
|
| 324 |
+
user = await c.get_users(user_id)
|
| 325 |
+
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 326 |
+
except RPCError:
|
| 327 |
+
pass
|
| 328 |
+
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
| 329 |
+
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
| 330 |
+
if true_sudo == []:
|
| 331 |
+
reply += "No Sudo Users\n"
|
| 332 |
+
else:
|
| 333 |
+
for each_user in true_sudo:
|
| 334 |
+
user_id = int(each_user)
|
| 335 |
+
try:
|
| 336 |
+
user = await c.get_users(user_id)
|
| 337 |
+
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 338 |
+
except RPCError:
|
| 339 |
+
pass
|
| 340 |
+
reply += "\n<b>Whitelisted Users 🐺:</b>\n"
|
| 341 |
+
if WHITELIST_USERS == []:
|
| 342 |
+
reply += "No additional whitelisted users\n"
|
| 343 |
+
else:
|
| 344 |
+
for each_user in WHITELIST_USERS:
|
| 345 |
+
user_id = int(each_user)
|
| 346 |
+
try:
|
| 347 |
+
user = await c.get_users(user_id)
|
| 348 |
+
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 349 |
+
except RPCError:
|
| 350 |
+
pass
|
| 351 |
+
|
| 352 |
+
await q.edit_message_caption(reply,reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("« Back","start_back")]]))
|
| 353 |
+
return
|
| 354 |
+
|
Powers/plugins/stickers.py
CHANGED
|
@@ -241,6 +241,32 @@ async def kang(c:Gojo, m: Message):
|
|
| 241 |
LOGGER.error(format_exc())
|
| 242 |
return
|
| 243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
@Gojo.on_message(command(["mmfb","mmfw","mmf"]))
|
| 246 |
async def memify_it(c: Gojo, m: Message):
|
|
|
|
| 241 |
LOGGER.error(format_exc())
|
| 242 |
return
|
| 243 |
|
| 244 |
+
@Gojo.on_message(command(["rmsticker", "removesticker"]))
|
| 245 |
+
async def remove_sticker_from_pack(c: Gojo, m: Message):
|
| 246 |
+
if not m.reply_to_message or not m.reply_to_message.sticker:
|
| 247 |
+
return await m.reply_text(
|
| 248 |
+
"Reply to a sticker to remove it from the pack."
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
sticker = m.reply_to_message.sticker
|
| 252 |
+
|
| 253 |
+
to_modify = await m.reply_text(f"Removing the sticker from your pack")
|
| 254 |
+
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
| 255 |
+
|
| 256 |
+
if not sticker_set:
|
| 257 |
+
await to_modify.edit_text("This sticker is not part for your pack")
|
| 258 |
+
return
|
| 259 |
+
|
| 260 |
+
try:
|
| 261 |
+
await remove_sticker(c, sticker.file_id)
|
| 262 |
+
await to_modify.edit_text(f"Successfully removed [sticker]({m.reply_to_message.link}) from {sticker_set.set.title}")
|
| 263 |
+
except Exception as e:
|
| 264 |
+
await to_modify.delete()
|
| 265 |
+
await m.reply_text(f"Failed to remove sticker due to:\n{e}\nPlease report this bug using `/bug`")
|
| 266 |
+
LOGGER.error(e)
|
| 267 |
+
LOGGER.error(format_exc())
|
| 268 |
+
return
|
| 269 |
+
|
| 270 |
|
| 271 |
@Gojo.on_message(command(["mmfb","mmfw","mmf"]))
|
| 272 |
async def memify_it(c: Gojo, m: Message):
|
Powers/plugins/utils.py
CHANGED
|
@@ -6,7 +6,7 @@ from os import remove
|
|
| 6 |
import aiofiles
|
| 7 |
from gpytranslate import Translator
|
| 8 |
from pyrogram import enums, filters
|
| 9 |
-
from pyrogram.errors import MessageTooLong, PeerIdInvalid
|
| 10 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
| 11 |
from wikipedia import summary
|
| 12 |
from wikipedia.exceptions import DisambiguationError, PageError
|
|
@@ -21,6 +21,9 @@ from Powers.utils.extract_user import extract_user
|
|
| 21 |
from Powers.utils.http_helper import *
|
| 22 |
from Powers.utils.parser import mention_html
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
@Gojo.on_message(command("wiki"))
|
| 26 |
async def wiki(_, m: Message):
|
|
@@ -331,8 +334,8 @@ async def paste_func(_, message: Message):
|
|
| 331 |
content = r.text
|
| 332 |
exe = "txt"
|
| 333 |
if r.document:
|
| 334 |
-
if r.document.file_size > 40000:
|
| 335 |
-
|
| 336 |
|
| 337 |
if not pattern.search(r.document.mime_type):
|
| 338 |
return await m.edit("Only text files can be pasted.")
|
|
@@ -419,6 +422,54 @@ async def reporting_query(c: Gojo, m: Message):
|
|
| 419 |
await c.send_message(OWNER_ID,f"New bug report\n{ppost}",disable_web_page_preview=True)
|
| 420 |
return
|
| 421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
__PLUGIN__ = "utils"
|
| 423 |
_DISABLE_CMDS_ = ["paste", "wiki", "id", "gifid", "tr", "github", "git", "bug"]
|
| 424 |
__alt_name__ = ["util", "misc", "tools"]
|
|
@@ -429,7 +480,6 @@ __HELP__ = """
|
|
| 429 |
Some utils provided by bot to make your tasks easy!
|
| 430 |
|
| 431 |
• /id: Get the current group id. If used by replying to a message, get that user's id.
|
| 432 |
-
• /info: Get information about a user.
|
| 433 |
• /gifid: Reply to a gif to me to tell you its file ID.
|
| 434 |
• /lyrics `<song name>`-`<artist name>` : Find your song and give the lyrics of the song
|
| 435 |
• /wiki: `<query>`: wiki your query.
|
|
@@ -437,6 +487,7 @@ Some utils provided by bot to make your tasks easy!
|
|
| 437 |
• /git `<username>`: Search for the user using github api!
|
| 438 |
• /weebify `<text>` or `<reply to message>`: To weebify the text.
|
| 439 |
• /bug <reply to text message> : To report a bug
|
|
|
|
| 440 |
|
| 441 |
**Example:**
|
| 442 |
`/git iamgojoof6eyes`: this fetches the information about a user from the database."""
|
|
|
|
| 6 |
import aiofiles
|
| 7 |
from gpytranslate import Translator
|
| 8 |
from pyrogram import enums, filters
|
| 9 |
+
from pyrogram.errors import MessageTooLong, PeerIdInvalid, RPCError
|
| 10 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
| 11 |
from wikipedia import summary
|
| 12 |
from wikipedia.exceptions import DisambiguationError, PageError
|
|
|
|
| 21 |
from Powers.utils.http_helper import *
|
| 22 |
from Powers.utils.parser import mention_html
|
| 23 |
|
| 24 |
+
DEV_USERS = get_support_staff("dev")
|
| 25 |
+
SUDO_USERS = get_support_staff("sudo")
|
| 26 |
+
|
| 27 |
|
| 28 |
@Gojo.on_message(command("wiki"))
|
| 29 |
async def wiki(_, m: Message):
|
|
|
|
| 334 |
content = r.text
|
| 335 |
exe = "txt"
|
| 336 |
if r.document:
|
| 337 |
+
# if r.document.file_size > 40000:
|
| 338 |
+
# return await m.edit("You can only paste files smaller than 40KB.")
|
| 339 |
|
| 340 |
if not pattern.search(r.document.mime_type):
|
| 341 |
return await m.edit("Only text files can be pasted.")
|
|
|
|
| 422 |
await c.send_message(OWNER_ID,f"New bug report\n{ppost}",disable_web_page_preview=True)
|
| 423 |
return
|
| 424 |
|
| 425 |
+
|
| 426 |
+
@Gojo.on_message(command("botstaffs"))
|
| 427 |
+
async def botstaff(c: Gojo, m: Message):
|
| 428 |
+
try:
|
| 429 |
+
owner = await c.get_users(OWNER_ID)
|
| 430 |
+
reply = f"<b>🌟 Owner:</b> {(await mention_html(owner.first_name, OWNER_ID))} (<code>{OWNER_ID}</code>)\n"
|
| 431 |
+
except RPCError:
|
| 432 |
+
pass
|
| 433 |
+
true_dev = list(set(DEV_USERS) - {OWNER_ID})
|
| 434 |
+
reply += "\n<b>Developers ⚡️:</b>\n"
|
| 435 |
+
if not true_dev:
|
| 436 |
+
reply += "No Dev Users\n"
|
| 437 |
+
else:
|
| 438 |
+
for each_user in true_dev:
|
| 439 |
+
user_id = int(each_user)
|
| 440 |
+
try:
|
| 441 |
+
user = await c.get_users(user_id)
|
| 442 |
+
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 443 |
+
except RPCError:
|
| 444 |
+
pass
|
| 445 |
+
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
| 446 |
+
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
| 447 |
+
if true_sudo == []:
|
| 448 |
+
reply += "No Sudo Users\n"
|
| 449 |
+
else:
|
| 450 |
+
for each_user in true_sudo:
|
| 451 |
+
user_id = int(each_user)
|
| 452 |
+
try:
|
| 453 |
+
user = await c.get_users(user_id)
|
| 454 |
+
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 455 |
+
except RPCError:
|
| 456 |
+
pass
|
| 457 |
+
reply += "\n<b>Whitelisted Users 🐺:</b>\n"
|
| 458 |
+
if WHITELIST_USERS == []:
|
| 459 |
+
reply += "No additional whitelisted users\n"
|
| 460 |
+
else:
|
| 461 |
+
for each_user in WHITELIST_USERS:
|
| 462 |
+
user_id = int(each_user)
|
| 463 |
+
try:
|
| 464 |
+
user = await c.get_users(user_id)
|
| 465 |
+
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
| 466 |
+
except RPCError:
|
| 467 |
+
pass
|
| 468 |
+
await m.reply_text(reply)
|
| 469 |
+
LOGGER.info(f"{m.from_user.id} fetched botstaff in {m.chat.id}")
|
| 470 |
+
return
|
| 471 |
+
|
| 472 |
+
|
| 473 |
__PLUGIN__ = "utils"
|
| 474 |
_DISABLE_CMDS_ = ["paste", "wiki", "id", "gifid", "tr", "github", "git", "bug"]
|
| 475 |
__alt_name__ = ["util", "misc", "tools"]
|
|
|
|
| 480 |
Some utils provided by bot to make your tasks easy!
|
| 481 |
|
| 482 |
• /id: Get the current group id. If used by replying to a message, get that user's id.
|
|
|
|
| 483 |
• /gifid: Reply to a gif to me to tell you its file ID.
|
| 484 |
• /lyrics `<song name>`-`<artist name>` : Find your song and give the lyrics of the song
|
| 485 |
• /wiki: `<query>`: wiki your query.
|
|
|
|
| 487 |
• /git `<username>`: Search for the user using github api!
|
| 488 |
• /weebify `<text>` or `<reply to message>`: To weebify the text.
|
| 489 |
• /bug <reply to text message> : To report a bug
|
| 490 |
+
• /botstaffs : Give the list of the bot staffs.
|
| 491 |
|
| 492 |
**Example:**
|
| 493 |
`/git iamgojoof6eyes`: this fetches the information about a user from the database."""
|
Powers/utils/custom_filters.py
CHANGED
|
@@ -7,10 +7,14 @@ from pyrogram.enums import ChatMemberStatus as CMS
|
|
| 7 |
from pyrogram.enums import ChatType
|
| 8 |
from pyrogram.errors import RPCError, UserNotParticipant
|
| 9 |
from pyrogram.filters import create
|
| 10 |
-
from pyrogram.types import CallbackQuery, Message
|
| 11 |
|
| 12 |
from Powers import DEV_USERS, OWNER_ID, SUDO_USERS
|
|
|
|
|
|
|
|
|
|
| 13 |
from Powers.database.disable_db import Disabling
|
|
|
|
| 14 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 15 |
from Powers.vars import Config
|
| 16 |
|
|
@@ -302,7 +306,75 @@ async def can_pin_message_func(_, __, m):
|
|
| 302 |
|
| 303 |
return status
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
|
|
|
|
|
|
|
|
|
| 306 |
admin_filter = create(admin_check_func)
|
| 307 |
owner_filter = create(owner_check_func)
|
| 308 |
restrict_filter = create(restrict_check_func)
|
|
|
|
| 7 |
from pyrogram.enums import ChatType
|
| 8 |
from pyrogram.errors import RPCError, UserNotParticipant
|
| 9 |
from pyrogram.filters import create
|
| 10 |
+
from pyrogram.types import CallbackQuery, ChatJoinRequest, Message
|
| 11 |
|
| 12 |
from Powers import DEV_USERS, OWNER_ID, SUDO_USERS
|
| 13 |
+
from Powers.database.afk_db import AFK
|
| 14 |
+
from Powers.database.approve_db import Approve
|
| 15 |
+
from Powers.database.autojoin_db import AUTOJOIN
|
| 16 |
from Powers.database.disable_db import Disabling
|
| 17 |
+
from Powers.database.flood_db import Floods
|
| 18 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 19 |
from Powers.vars import Config
|
| 20 |
|
|
|
|
| 306 |
|
| 307 |
return status
|
| 308 |
|
| 309 |
+
async def auto_join_check_filter(_, __, j: ChatJoinRequest):
|
| 310 |
+
chat = j.chat.id
|
| 311 |
+
aj = AUTOJOIN()
|
| 312 |
+
join_type = aj.get_autojoin(chat)
|
| 313 |
+
|
| 314 |
+
if not join_type:
|
| 315 |
+
return False
|
| 316 |
+
else:
|
| 317 |
+
return True
|
| 318 |
+
|
| 319 |
+
async def afk_check_filter(_, __, m: Message):
|
| 320 |
+
if not m.from_user:
|
| 321 |
+
return False
|
| 322 |
+
|
| 323 |
+
if m.from_user.is_bot:
|
| 324 |
+
return False
|
| 325 |
+
|
| 326 |
+
if m.chat.type == ChatType.PRIVATE:
|
| 327 |
+
return False
|
| 328 |
+
|
| 329 |
+
afk = AFK()
|
| 330 |
+
user = m.from_user.id
|
| 331 |
+
chat = m.chat.id
|
| 332 |
+
repl = m.reply_to_message
|
| 333 |
+
|
| 334 |
+
if repl and repl.from_user:
|
| 335 |
+
rep_user = repl.from_user.id
|
| 336 |
+
else:
|
| 337 |
+
rep_user = False
|
| 338 |
+
|
| 339 |
+
is_afk = afk.check_afk(chat,user)
|
| 340 |
+
is_rep_afk = False
|
| 341 |
+
if rep_user:
|
| 342 |
+
is_rep_afk = afk.check_afk(chat,rep_user)
|
| 343 |
+
|
| 344 |
+
if not is_rep_afk and not is_afk:
|
| 345 |
+
return False
|
| 346 |
+
else:
|
| 347 |
+
return True
|
| 348 |
+
|
| 349 |
+
async def flood_check_filter(_, __, m: Message):
|
| 350 |
+
Flood = Floods()
|
| 351 |
+
if not m.chat:
|
| 352 |
+
return False
|
| 353 |
+
|
| 354 |
+
if not m.from_user:
|
| 355 |
+
return False
|
| 356 |
+
|
| 357 |
+
if m.chat.type == ChatType.PRIVATE:
|
| 358 |
+
return False
|
| 359 |
+
|
| 360 |
+
u_id = m.from_user.id
|
| 361 |
+
c_id = m.chat.id
|
| 362 |
+
is_flood = Flood.is_chat(c_id)
|
| 363 |
+
|
| 364 |
+
app_users = Approve(m.chat.id).list_approved()
|
| 365 |
+
|
| 366 |
+
if not is_flood or u_id in SUDO_LEVEL:
|
| 367 |
+
return False
|
| 368 |
+
|
| 369 |
+
elif u_id in {i[0] for i in app_users}:
|
| 370 |
+
return False
|
| 371 |
+
|
| 372 |
+
else:
|
| 373 |
+
return True
|
| 374 |
|
| 375 |
+
flood_filter = create(flood_check_filter)
|
| 376 |
+
afk_filter = create(afk_check_filter)
|
| 377 |
+
auto_join_filter = create(auto_join_check_filter)
|
| 378 |
admin_filter = create(admin_check_func)
|
| 379 |
owner_filter = create(owner_check_func)
|
| 380 |
restrict_filter = create(restrict_check_func)
|
Powers/utils/extract_user.py
CHANGED
|
@@ -98,6 +98,7 @@ async def extract_user(c: Gojo, m: Message) -> Tuple[int, str, str]:
|
|
| 98 |
user = await c.get_users(user_r.user_id)
|
| 99 |
except Exception as ef:
|
| 100 |
return await m.reply_text(f"User not found ! Error: {ef}")
|
|
|
|
| 101 |
user_first_name = user.first_name
|
| 102 |
user_name = user.username
|
| 103 |
LOGGER.error(ef)
|
|
|
|
| 98 |
user = await c.get_users(user_r.user_id)
|
| 99 |
except Exception as ef:
|
| 100 |
return await m.reply_text(f"User not found ! Error: {ef}")
|
| 101 |
+
user_id = user.id
|
| 102 |
user_first_name = user.first_name
|
| 103 |
user_name = user.username
|
| 104 |
LOGGER.error(ef)
|
Powers/utils/start_utils.py
CHANGED
|
@@ -44,9 +44,8 @@ async def gen_start_kb(q: Message or CallbackQuery):
|
|
| 44 |
"url",
|
| 45 |
),
|
| 46 |
(
|
| 47 |
-
"
|
| 48 |
-
f"
|
| 49 |
-
"url",
|
| 50 |
),
|
| 51 |
],
|
| 52 |
[
|
|
|
|
| 44 |
"url",
|
| 45 |
),
|
| 46 |
(
|
| 47 |
+
"Bot Staffs 🚔",
|
| 48 |
+
f"give_bot_staffs",
|
|
|
|
| 49 |
),
|
| 50 |
],
|
| 51 |
[
|
Powers/utils/sticker_help.py
CHANGED
|
@@ -3,12 +3,14 @@ import math
|
|
| 3 |
import os
|
| 4 |
import shlex
|
| 5 |
import textwrap
|
|
|
|
| 6 |
from typing import List, Tuple
|
| 7 |
|
| 8 |
from PIL import Image, ImageDraw, ImageFont
|
| 9 |
from pyrogram import errors, raw
|
| 10 |
from pyrogram.file_id import FileId
|
| 11 |
from pyrogram.types import Message
|
|
|
|
| 12 |
|
| 13 |
from Powers.bot_class import Gojo
|
| 14 |
|
|
@@ -181,6 +183,10 @@ async def get_document_from_file_id(
|
|
| 181 |
file_reference=decoded.file_reference,
|
| 182 |
)
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
async def draw_meme(image_path: str, text: str, sticker: bool, fiill: str) -> list:
|
| 186 |
_split = text.split(";", 1)
|
|
@@ -194,19 +200,36 @@ async def draw_meme(image_path: str, text: str, sticker: bool, fiill: str) -> li
|
|
| 194 |
image = Image.open(image_path)
|
| 195 |
width, height = image.size
|
| 196 |
|
| 197 |
-
font_size = int(
|
| 198 |
font = ImageFont.truetype("./extras/comic.ttf", font_size)
|
| 199 |
|
| 200 |
draw = ImageDraw.Draw(image)
|
| 201 |
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
if sticker:
|
| 212 |
stick_path = image_path
|
|
@@ -214,7 +237,7 @@ async def draw_meme(image_path: str, text: str, sticker: bool, fiill: str) -> li
|
|
| 214 |
stick_path = await resize_file_to_sticker_size(image_path)
|
| 215 |
|
| 216 |
image1 = image_path
|
| 217 |
-
image2 = tosticker(stick_path,"@
|
| 218 |
|
| 219 |
image.save(image1)
|
| 220 |
image.save(image2)
|
|
@@ -224,113 +247,7 @@ async def draw_meme(image_path: str, text: str, sticker: bool, fiill: str) -> li
|
|
| 224 |
return [image1, image2]
|
| 225 |
|
| 226 |
|
| 227 |
-
|
| 228 |
-
# """Hellbot se churaya hai hue hue hue..."""
|
| 229 |
-
# img = Image.open(image_path)
|
| 230 |
-
# i_width, i_height = img.size
|
| 231 |
-
# m_font = ImageFont.truetype(
|
| 232 |
-
# "./extras/comic.ttf", int(i_width / 11)
|
| 233 |
-
# )
|
| 234 |
-
# if ";" in text:
|
| 235 |
-
# upper_text, lower_text = text.split(";")
|
| 236 |
-
# else:
|
| 237 |
-
# upper_text = text
|
| 238 |
-
# lower_text = ""
|
| 239 |
-
# draw = ImageDraw.Draw(img)
|
| 240 |
-
# current_h, pad = 10, 5
|
| 241 |
-
# if upper_text:
|
| 242 |
-
# for u_text in textwrap.wrap(upper_text,width=15,subsequent_indent=" "):
|
| 243 |
-
# u_width, u_height = draw.textsize(u_text, font=m_font)
|
| 244 |
-
# draw.text(
|
| 245 |
-
# xy=(((i_width - u_width) / 2) - 1, int((current_h / 640) * i_width)),
|
| 246 |
-
# text=u_text,
|
| 247 |
-
# font=m_font,
|
| 248 |
-
# fill=(0, 0, 0),
|
| 249 |
-
# )
|
| 250 |
-
# draw.text(
|
| 251 |
-
# xy=(((i_width - u_width) / 2) + 1, int((current_h / 640) * i_width)),
|
| 252 |
-
# text=u_text,
|
| 253 |
-
# font=m_font,
|
| 254 |
-
# fill=(0, 0, 0),
|
| 255 |
-
# )
|
| 256 |
-
# draw.text(
|
| 257 |
-
# xy=((i_width - u_width) / 2, int(((current_h / 640) * i_width)) - 1),
|
| 258 |
-
# text=u_text,
|
| 259 |
-
# font=m_font,
|
| 260 |
-
# fill=(0, 0, 0),
|
| 261 |
-
# )
|
| 262 |
-
# draw.text(
|
| 263 |
-
# xy=(((i_width - u_width) / 2), int(((current_h / 640) * i_width)) + 1),
|
| 264 |
-
# text=u_text,
|
| 265 |
-
# font=m_font,
|
| 266 |
-
# fill=(0, 0, 0),
|
| 267 |
-
# )
|
| 268 |
-
# draw.text(
|
| 269 |
-
# xy=((i_width - u_width) / 2, int((current_h / 640) * i_width)),
|
| 270 |
-
# text=u_text,
|
| 271 |
-
# font=m_font,
|
| 272 |
-
# fill=(255, 255, 255),
|
| 273 |
-
# )
|
| 274 |
-
# current_h += u_height + pad
|
| 275 |
-
# if lower_text:
|
| 276 |
-
# for l_text in textwrap.wrap(upper_text,width=15,subsequent_indent=" "):
|
| 277 |
-
# u_width, u_height = draw.textsize(l_text, font=m_font)
|
| 278 |
-
# draw.text(
|
| 279 |
-
# xy=(
|
| 280 |
-
# ((i_width - u_width) / 2) - 1,
|
| 281 |
-
# i_height - u_height - int((20 / 640) * i_width),
|
| 282 |
-
# ),
|
| 283 |
-
# text=l_text,
|
| 284 |
-
# font=m_font,
|
| 285 |
-
# fill=(0, 0, 0),
|
| 286 |
-
# )
|
| 287 |
-
# draw.text(
|
| 288 |
-
# xy=(
|
| 289 |
-
# ((i_width - u_width) / 2) + 1,
|
| 290 |
-
# i_height - u_height - int((20 / 640) * i_width),
|
| 291 |
-
# ),
|
| 292 |
-
# text=l_text,
|
| 293 |
-
# font=m_font,
|
| 294 |
-
# fill=(0, 0, 0),
|
| 295 |
-
# )
|
| 296 |
-
# draw.text(
|
| 297 |
-
# xy=(
|
| 298 |
-
# (i_width - u_width) / 2,
|
| 299 |
-
# (i_height - u_height - int((20 / 640) * i_width)) - 1,
|
| 300 |
-
# ),
|
| 301 |
-
# text=l_text,
|
| 302 |
-
# font=m_font,
|
| 303 |
-
# fill=(0, 0, 0),
|
| 304 |
-
# )
|
| 305 |
-
# draw.text(
|
| 306 |
-
# xy=(
|
| 307 |
-
# (i_width - u_width) / 2,
|
| 308 |
-
# (i_height - u_height - int((20 / 640) * i_width)) + 1,
|
| 309 |
-
# ),
|
| 310 |
-
# text=l_text,
|
| 311 |
-
# font=m_font,
|
| 312 |
-
# fill=(0, 0, 0),
|
| 313 |
-
# )
|
| 314 |
-
# draw.text(
|
| 315 |
-
# xy=(
|
| 316 |
-
# (i_width - u_width) / 2,
|
| 317 |
-
# i_height - u_height - int((20 / 640) * i_width),
|
| 318 |
-
# ),
|
| 319 |
-
# text=l_text,
|
| 320 |
-
# font=m_font,
|
| 321 |
-
# fill=(255, 255, 255),
|
| 322 |
-
# )
|
| 323 |
-
# current_h += u_height + pad
|
| 324 |
-
|
| 325 |
-
# hue = image_path
|
| 326 |
-
# if stick:
|
| 327 |
-
# stick_path = image_path
|
| 328 |
-
# else:
|
| 329 |
-
# stick_path = await resize_file_to_sticker_size(hue)
|
| 330 |
-
# mee = tosticker(stick_path,"@memesofdank_memer_hu_vai.webp")
|
| 331 |
-
# img.save(hue)
|
| 332 |
-
# img.save(mee)
|
| 333 |
-
# return hue, mee
|
| 334 |
|
| 335 |
def toimage(image, filename=None, is_direc=False):
|
| 336 |
filename = filename if filename else "gojo.jpg"
|
|
|
|
| 3 |
import os
|
| 4 |
import shlex
|
| 5 |
import textwrap
|
| 6 |
+
from time import time
|
| 7 |
from typing import List, Tuple
|
| 8 |
|
| 9 |
from PIL import Image, ImageDraw, ImageFont
|
| 10 |
from pyrogram import errors, raw
|
| 11 |
from pyrogram.file_id import FileId
|
| 12 |
from pyrogram.types import Message
|
| 13 |
+
from unidecode import unidecode
|
| 14 |
|
| 15 |
from Powers.bot_class import Gojo
|
| 16 |
|
|
|
|
| 183 |
file_reference=decoded.file_reference,
|
| 184 |
)
|
| 185 |
|
| 186 |
+
async def remove_sticker(c: Gojo, stickerid: str) -> raw.base.messages.StickerSet:
|
| 187 |
+
sticker = await get_document_from_file_id(stickerid)
|
| 188 |
+
return await c.invoke(raw.functions.stickers.RemoveStickerFromSet(sticker=sticker))
|
| 189 |
+
|
| 190 |
|
| 191 |
async def draw_meme(image_path: str, text: str, sticker: bool, fiill: str) -> list:
|
| 192 |
_split = text.split(";", 1)
|
|
|
|
| 200 |
image = Image.open(image_path)
|
| 201 |
width, height = image.size
|
| 202 |
|
| 203 |
+
font_size = int((30 / 500) * width)
|
| 204 |
font = ImageFont.truetype("./extras/comic.ttf", font_size)
|
| 205 |
|
| 206 |
draw = ImageDraw.Draw(image)
|
| 207 |
|
| 208 |
+
curr_height, padding = 20, 5
|
| 209 |
+
for utext in textwrap.wrap(upper_text, 25):
|
| 210 |
+
upper_width = draw.textlength(utext, font=font)
|
| 211 |
+
draw.text(
|
| 212 |
+
((width - upper_width) / 2, curr_height),
|
| 213 |
+
unidecode(utext),
|
| 214 |
+
(255, 255, 255),
|
| 215 |
+
font,
|
| 216 |
+
stroke_width=3,
|
| 217 |
+
stroke_fill=fiill,
|
| 218 |
+
)
|
| 219 |
+
curr_height += font_size + padding
|
| 220 |
+
|
| 221 |
+
curr_height = height - font_size
|
| 222 |
+
for ltext in reversed(textwrap.wrap(lower_text, 25)):
|
| 223 |
+
lower_width = draw.textlength(ltext, font=font)
|
| 224 |
+
draw.text(
|
| 225 |
+
((width - lower_width) / 2, curr_height - font_size),
|
| 226 |
+
ltext,
|
| 227 |
+
(255, 255, 255),
|
| 228 |
+
font,
|
| 229 |
+
stroke_width=3,
|
| 230 |
+
stroke_fill=fiill,
|
| 231 |
+
)
|
| 232 |
+
curr_height -= font_size + padding
|
| 233 |
|
| 234 |
if sticker:
|
| 235 |
stick_path = image_path
|
|
|
|
| 237 |
stick_path = await resize_file_to_sticker_size(image_path)
|
| 238 |
|
| 239 |
image1 = image_path
|
| 240 |
+
image2 = tosticker(stick_path,f"@GojoSuperbot_{int(time())}.webp")
|
| 241 |
|
| 242 |
image.save(image1)
|
| 243 |
image.save(image2)
|
|
|
|
| 247 |
return [image1, image2]
|
| 248 |
|
| 249 |
|
| 250 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
def toimage(image, filename=None, is_direc=False):
|
| 253 |
filename = filename if filename else "gojo.jpg"
|
Powers/vars.py
CHANGED
|
@@ -38,7 +38,7 @@ class Config:
|
|
| 38 |
).split(None)
|
| 39 |
]
|
| 40 |
GENIUS_API_TOKEN = config("GENIUS_API",default=None)
|
| 41 |
-
AuDD_API = config("AuDD_API",default=None)
|
| 42 |
RMBG_API = config("RMBG_API",default=None)
|
| 43 |
DB_URI = config("DB_URI", default="")
|
| 44 |
DB_NAME = config("DB_NAME", default="gojo_satarou")
|
|
|
|
| 38 |
).split(None)
|
| 39 |
]
|
| 40 |
GENIUS_API_TOKEN = config("GENIUS_API",default=None)
|
| 41 |
+
# AuDD_API = config("AuDD_API",default=None)
|
| 42 |
RMBG_API = config("RMBG_API",default=None)
|
| 43 |
DB_URI = config("DB_URI", default="")
|
| 44 |
DB_NAME = config("DB_NAME", default="gojo_satarou")
|