Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
f192ee1
1
Parent(s):
fe86459
Fixes
Browse files- .gitignore +1 -0
- Powers/__init__.py +2 -2
- Powers/bot_class.py +10 -11
- Powers/plugins/afk.py +5 -8
- Powers/plugins/dev.py +1 -1
- Powers/plugins/flood.py +1 -1
- Powers/plugins/locks.py +1 -1
- Powers/plugins/purge.py +0 -1
- Powers/plugins/start.py +2 -2
- Powers/plugins/stickers.py +15 -10
- Powers/plugins/watchers.py +1 -1
- Powers/supports.py +3 -1
- Powers/utils/custom_filters.py +5 -17
- Powers/utils/sticker_help.py +1 -1
- Powers/utils/web_helpers.py +75 -5
- Powers/utils/web_scrapper.py +1 -1
- Powers/vars.py +2 -3
.gitignore
CHANGED
@@ -10,6 +10,7 @@ Powers/local_vars.py
|
|
10 |
|
11 |
# Byte-compiled / optimized / DLL files
|
12 |
__pycache__/
|
|
|
13 |
*.py[cod]
|
14 |
*$py.class
|
15 |
|
|
|
10 |
|
11 |
# Byte-compiled / optimized / DLL files
|
12 |
__pycache__/
|
13 |
+
Youtube/
|
14 |
*.py[cod]
|
15 |
*$py.class
|
16 |
|
Powers/__init__.py
CHANGED
@@ -5,7 +5,6 @@ from logging import (INFO, WARNING, FileHandler, StreamHandler, basicConfig,
|
|
5 |
getLogger)
|
6 |
from os import environ, listdir, mkdir, path
|
7 |
from platform import python_version
|
8 |
-
from random import choice
|
9 |
from sys import exit as sysexit
|
10 |
from sys import stdout, version_info
|
11 |
from time import time
|
@@ -52,7 +51,8 @@ if version_info[0] < 3 or version_info[1] < 7:
|
|
52 |
|
53 |
# the secret configuration specific things
|
54 |
try:
|
55 |
-
|
|
|
56 |
from Powers.vars import Config
|
57 |
else:
|
58 |
from Powers.vars import Development as Config
|
|
|
5 |
getLogger)
|
6 |
from os import environ, listdir, mkdir, path
|
7 |
from platform import python_version
|
|
|
8 |
from sys import exit as sysexit
|
9 |
from sys import stdout, version_info
|
10 |
from time import time
|
|
|
51 |
|
52 |
# the secret configuration specific things
|
53 |
try:
|
54 |
+
from Powers.vars import is_env
|
55 |
+
if is_env or environ.get("ENV"):
|
56 |
from Powers.vars import Config
|
57 |
else:
|
58 |
from Powers.vars import Development as Config
|
Powers/bot_class.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from platform import python_version
|
2 |
from threading import RLock
|
3 |
-
from time import gmtime, strftime
|
|
|
4 |
|
5 |
from pyrogram import Client, __version__
|
6 |
from pyrogram.raw.all import layer
|
@@ -90,24 +91,22 @@ class Gojo(Client):
|
|
90 |
|
91 |
async def stop(self):
|
92 |
"""Stop the bot and send a message to MESSAGE_DUMP telling that the bot has stopped."""
|
93 |
-
runtime = strftime("%Hh %Mm %Ss", gmtime(
|
94 |
LOGGER.info("Uploading logs before stopping...!\n")
|
95 |
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
await self.send_document(
|
97 |
-
|
98 |
document=LOGFILE,
|
99 |
caption=(
|
100 |
"Bot Stopped!\n\n" f"Uptime: {runtime}\n" f"<code>{LOG_DATETIME}</code>"
|
101 |
),
|
102 |
)
|
103 |
-
scheduler.remove_all_jobs()
|
104 |
-
if MESSAGE_DUMP:
|
105 |
-
# LOG_CHANNEL is not necessary
|
106 |
-
await self.send_document(
|
107 |
-
MESSAGE_DUMP,
|
108 |
-
document=LOGFILE,
|
109 |
-
caption=f"Uptime: {runtime}",
|
110 |
-
)
|
111 |
await super().stop()
|
112 |
MongoDB.close()
|
113 |
LOGGER.info(
|
|
|
1 |
from platform import python_version
|
2 |
from threading import RLock
|
3 |
+
from time import gmtime, strftime
|
4 |
+
from time import time as t
|
5 |
|
6 |
from pyrogram import Client, __version__
|
7 |
from pyrogram.raw.all import layer
|
|
|
91 |
|
92 |
async def stop(self):
|
93 |
"""Stop the bot and send a message to MESSAGE_DUMP telling that the bot has stopped."""
|
94 |
+
runtime = strftime("%Hh %Mm %Ss", gmtime(t() - UPTIME))
|
95 |
LOGGER.info("Uploading logs before stopping...!\n")
|
96 |
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
97 |
+
scheduler.remove_all_jobs()
|
98 |
+
if MESSAGE_DUMP:
|
99 |
+
# LOG_CHANNEL is not necessary
|
100 |
+
target = MESSAGE_DUMP
|
101 |
+
else:
|
102 |
+
target = OWNER_ID
|
103 |
await self.send_document(
|
104 |
+
target,
|
105 |
document=LOGFILE,
|
106 |
caption=(
|
107 |
"Bot Stopped!\n\n" f"Uptime: {runtime}\n" f"<code>{LOG_DATETIME}</code>"
|
108 |
),
|
109 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
await super().stop()
|
111 |
MongoDB.close()
|
112 |
LOGGER.info(
|
Powers/plugins/afk.py
CHANGED
@@ -1,7 +1,7 @@
|
|
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 |
|
@@ -67,7 +67,7 @@ async def get_hours(hour:str):
|
|
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)
|
@@ -128,7 +128,7 @@ async def afk_checker(c: Gojo, m: Message):
|
|
128 |
pass
|
129 |
|
130 |
if txt and txt in ["afk","brb"]:
|
131 |
-
|
132 |
else:
|
133 |
con = afk.get_afk(chat,user)
|
134 |
time = till_date(con["time"])
|
@@ -142,7 +142,7 @@ async def afk_checker(c: Gojo, m: Message):
|
|
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 |
-
|
146 |
|
147 |
__PLUGIN__ = "afk"
|
148 |
|
@@ -155,7 +155,4 @@ __HELP__ = """
|
|
155 |
• /afk (/brb) [reason | reply to a message]
|
156 |
|
157 |
`reply to a message` can be any media or text
|
158 |
-
"""
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
1 |
from datetime import datetime
|
2 |
from random import choice
|
3 |
|
4 |
+
from pyrogram import ContinuePropagation, filters
|
5 |
from pyrogram.enums import ParseMode as PM
|
6 |
from pyrogram.types import Message
|
7 |
|
|
|
67 |
return txt
|
68 |
|
69 |
|
70 |
+
@Gojo.on_message(afk_filter & filters.group, 10000)
|
71 |
async def afk_checker(c: Gojo, m: Message):
|
72 |
afk = AFK()
|
73 |
back_ = choice(back)
|
|
|
128 |
pass
|
129 |
|
130 |
if txt and txt in ["afk","brb"]:
|
131 |
+
raise ContinuePropagation
|
132 |
else:
|
133 |
con = afk.get_afk(chat,user)
|
134 |
time = till_date(con["time"])
|
|
|
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 |
+
raise ContinuePropagation
|
146 |
|
147 |
__PLUGIN__ = "afk"
|
148 |
|
|
|
155 |
• /afk (/brb) [reason | reply to a message]
|
156 |
|
157 |
`reply to a message` can be any media or text
|
158 |
+
"""
|
|
|
|
|
|
Powers/plugins/dev.py
CHANGED
@@ -553,7 +553,7 @@ async def stop_and_send_logger(c:Gojo,is_update=False):
|
|
553 |
)
|
554 |
return
|
555 |
|
556 |
-
@Gojo.on_message(command(["restart", "update"], owner_cmd=True)
|
557 |
async def restart_the_bot(c:Gojo,m:Message):
|
558 |
try:
|
559 |
cmds = m.command
|
|
|
553 |
)
|
554 |
return
|
555 |
|
556 |
+
@Gojo.on_message(command(["restart", "update"], owner_cmd=True))
|
557 |
async def restart_the_bot(c:Gojo,m:Message):
|
558 |
try:
|
559 |
cmds = m.command
|
Powers/plugins/flood.py
CHANGED
@@ -390,7 +390,7 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
390 |
return
|
391 |
|
392 |
dic = {}
|
393 |
-
@Gojo.on_message(flood_filter & ~admin_filter)
|
394 |
async def flood_watcher(c: Gojo, m: Message):
|
395 |
c_id = m.chat.id
|
396 |
|
|
|
390 |
return
|
391 |
|
392 |
dic = {}
|
393 |
+
@Gojo.on_message(flood_filter & ~admin_filter, 18)
|
394 |
async def flood_watcher(c: Gojo, m: Message):
|
395 |
c_id = m.chat.id
|
396 |
|
Powers/plugins/locks.py
CHANGED
@@ -498,7 +498,7 @@ async def servicess(c: Gojo, m: Message):
|
|
498 |
return
|
499 |
|
500 |
|
501 |
-
@Gojo.on_message(filters.group & ~filters.me,
|
502 |
async def lock_del_mess(c: Gojo, m: Message):
|
503 |
lock = LOCKS()
|
504 |
chat_locks = lock.get_lock_channel(m.chat.id)
|
|
|
498 |
return
|
499 |
|
500 |
|
501 |
+
@Gojo.on_message(filters.group & ~filters.me, 3)
|
502 |
async def lock_del_mess(c: Gojo, m: Message):
|
503 |
lock = LOCKS()
|
504 |
chat_locks = lock.get_lock_channel(m.chat.id)
|
Powers/plugins/purge.py
CHANGED
@@ -99,7 +99,6 @@ async def spurge(c: Gojo, m: Message):
|
|
99 |
|
100 |
@Gojo.on_message(
|
101 |
command("del") & admin_filter,
|
102 |
-
group=9,
|
103 |
)
|
104 |
async def del_msg(c: Gojo, m: Message):
|
105 |
|
|
|
99 |
|
100 |
@Gojo.on_message(
|
101 |
command("del") & admin_filter,
|
|
|
102 |
)
|
103 |
async def del_msg(c: Gojo, m: Message):
|
104 |
|
Powers/plugins/start.py
CHANGED
@@ -10,7 +10,7 @@ from pyrogram.errors import (MediaCaptionTooLong, MessageNotModified,
|
|
10 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
11 |
InlineKeyboardMarkup, Message)
|
12 |
|
13 |
-
from Powers import (DEV_USERS, HELP_COMMANDS, LOGGER, OWNER_ID,
|
14 |
PYROGRAM_VERSION, PYTHON_VERSION, SUDO_USERS, UPTIME,
|
15 |
VERSION, WHITELIST_USERS)
|
16 |
from Powers.bot_class import Gojo
|
@@ -192,7 +192,7 @@ Commands available:
|
|
192 |
× /start: Start the bot
|
193 |
× /help: Give's you this message.
|
194 |
|
195 |
-
You can use
|
196 |
"""
|
197 |
|
198 |
await q.edit_message_caption(
|
|
|
10 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
11 |
InlineKeyboardMarkup, Message)
|
12 |
|
13 |
+
from Powers import (DEV_USERS, HELP_COMMANDS, LOGGER, OWNER_ID, PREFIX_HANDLER,
|
14 |
PYROGRAM_VERSION, PYTHON_VERSION, SUDO_USERS, UPTIME,
|
15 |
VERSION, WHITELIST_USERS)
|
16 |
from Powers.bot_class import Gojo
|
|
|
192 |
× /start: Start the bot
|
193 |
× /help: Give's you this message.
|
194 |
|
195 |
+
You can use {", ".join(PREFIX_HANDLER)} as your prefix handler
|
196 |
"""
|
197 |
|
198 |
await q.edit_message_caption(
|
Powers/plugins/stickers.py
CHANGED
@@ -79,10 +79,13 @@ async def kang(c:Gojo, m: Message):
|
|
79 |
sticker_emoji = str(args[1])
|
80 |
elif m.reply_to_message.sticker:
|
81 |
try:
|
82 |
-
|
|
|
|
|
|
|
83 |
except Exception:
|
84 |
-
|
85 |
-
|
86 |
else:
|
87 |
edit = await msg.reply_text("No emoji provided choosing a random emoji")
|
88 |
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨","👨❤️👨", "💑", "👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣" ,"😂", "😜", "😎"]
|
@@ -147,7 +150,7 @@ async def kang(c:Gojo, m: Message):
|
|
147 |
|
148 |
try:
|
149 |
while not packname_found:
|
150 |
-
packname = f"CE{
|
151 |
kangpack = f"{('@'+m.from_user.username) if m.from_user.username else m.from_user.first_name[:10]} {('vOl '+str(volume)) if volume else ''} by @{c.me.username}"
|
152 |
if limit >= 50: # To prevent this loop from running forever
|
153 |
await m.reply_text("Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
|
@@ -160,7 +163,7 @@ async def kang(c:Gojo, m: Message):
|
|
160 |
owner=m.from_user.id,
|
161 |
title=kangpack,
|
162 |
short_name=packname,
|
163 |
-
stickers=[sticker]
|
164 |
)
|
165 |
except StickerEmojiInvalid:
|
166 |
return await msg.edit("[ERROR]: INVALID_EMOJI_IN_ARGUMENT")
|
@@ -170,6 +173,7 @@ async def kang(c:Gojo, m: Message):
|
|
170 |
volume += 1
|
171 |
continue
|
172 |
try:
|
|
|
173 |
await add_sticker_to_set(c,sticker_set,sticker)
|
174 |
packname_found = True
|
175 |
except StickerEmojiInvalid:
|
@@ -375,7 +379,7 @@ async def get_my_sticker_sets(c: Gojo, m: Message):
|
|
375 |
return
|
376 |
await m.reply_text(txt, reply_markup=kb)
|
377 |
|
378 |
-
@Gojo.on_message(command("q"))
|
379 |
async def quote_the_msg(_, m: Message):
|
380 |
if not m.reply_to_message:
|
381 |
await m.reply_text("Reply to a message to quote it")
|
@@ -384,7 +388,7 @@ async def quote_the_msg(_, m: Message):
|
|
384 |
to_edit = await m.reply_text("Genrating quote...")
|
385 |
|
386 |
msg_data = []
|
387 |
-
if len(m.command) > 1:
|
388 |
reply_msg = m.reply_to_message.reply_to_message
|
389 |
if not reply_msg:
|
390 |
reply_message = {}
|
@@ -402,7 +406,8 @@ async def quote_the_msg(_, m: Message):
|
|
402 |
"name": replied_name,
|
403 |
"text": reply_msg.text,
|
404 |
}
|
405 |
-
|
|
|
406 |
name = m.reply_to_message.from_user.first_name
|
407 |
if m.reply_to_message.from_user.last_name:
|
408 |
name += f" {m.reply_to_message.from_user.last_name}"
|
@@ -467,8 +472,8 @@ __HELP__ = """
|
|
467 |
• /getsticker (/getst) : Get sticker as photo, gif or vice versa.
|
468 |
• /stickerid (/stid) : Reply to any sticker to get it's id
|
469 |
• /mypacks : Get all of your current sticker pack you have made via me.
|
470 |
-
• /q <reply to message> : Will quote the replied message
|
471 |
-
• /q r <reply to message> : Will quote the replied message and message it was replied to.
|
472 |
• /mmf <your text>: Reply to a normal sticker or a photo or video file to memify it. If you want to right text at bottom use `;right your message`
|
473 |
■ For e.g.
|
474 |
○ /mmfb <text>: To fill text with black colour
|
|
|
79 |
sticker_emoji = str(args[1])
|
80 |
elif m.reply_to_message.sticker:
|
81 |
try:
|
82 |
+
sticker_emoji = m.reply_to_message.sticker.emoji
|
83 |
+
if not sticker_emoji:
|
84 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨","👨❤️👨", "💑", "👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣" ,"😂", "😜", "😎"]
|
85 |
+
sticker_emoji = choice(ran)
|
86 |
except Exception:
|
87 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨","👨❤️👨", "💑", "👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣" ,"😂", "😜", "😎"]
|
88 |
+
sticker_emoji = choice(ran)
|
89 |
else:
|
90 |
edit = await msg.reply_text("No emoji provided choosing a random emoji")
|
91 |
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨","👨❤️👨", "💑", "👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣" ,"😂", "😜", "😎"]
|
|
|
150 |
|
151 |
try:
|
152 |
while not packname_found:
|
153 |
+
packname = f"CE{m.from_user.id}{packnum}_by_{c.me.username}"
|
154 |
kangpack = f"{('@'+m.from_user.username) if m.from_user.username else m.from_user.first_name[:10]} {('vOl '+str(volume)) if volume else ''} by @{c.me.username}"
|
155 |
if limit >= 50: # To prevent this loop from running forever
|
156 |
await m.reply_text("Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
|
|
|
163 |
owner=m.from_user.id,
|
164 |
title=kangpack,
|
165 |
short_name=packname,
|
166 |
+
stickers=[sticker]
|
167 |
)
|
168 |
except StickerEmojiInvalid:
|
169 |
return await msg.edit("[ERROR]: INVALID_EMOJI_IN_ARGUMENT")
|
|
|
173 |
volume += 1
|
174 |
continue
|
175 |
try:
|
176 |
+
print(sticker_set)
|
177 |
await add_sticker_to_set(c,sticker_set,sticker)
|
178 |
packname_found = True
|
179 |
except StickerEmojiInvalid:
|
|
|
379 |
return
|
380 |
await m.reply_text(txt, reply_markup=kb)
|
381 |
|
382 |
+
@Gojo.on_message(command(["q", "ss"]))
|
383 |
async def quote_the_msg(_, m: Message):
|
384 |
if not m.reply_to_message:
|
385 |
await m.reply_text("Reply to a message to quote it")
|
|
|
388 |
to_edit = await m.reply_text("Genrating quote...")
|
389 |
|
390 |
msg_data = []
|
391 |
+
if len(m.command) > 1 and m.command[1].lower() == "r":
|
392 |
reply_msg = m.reply_to_message.reply_to_message
|
393 |
if not reply_msg:
|
394 |
reply_message = {}
|
|
|
406 |
"name": replied_name,
|
407 |
"text": reply_msg.text,
|
408 |
}
|
409 |
+
else:
|
410 |
+
reply_message = {}
|
411 |
name = m.reply_to_message.from_user.first_name
|
412 |
if m.reply_to_message.from_user.last_name:
|
413 |
name += f" {m.reply_to_message.from_user.last_name}"
|
|
|
472 |
• /getsticker (/getst) : Get sticker as photo, gif or vice versa.
|
473 |
• /stickerid (/stid) : Reply to any sticker to get it's id
|
474 |
• /mypacks : Get all of your current sticker pack you have made via me.
|
475 |
+
• /q(/ss) <reply to message> : Will quote the replied message
|
476 |
+
• /q(/ss) r <reply to message> : Will quote the replied message and message it was replied to.
|
477 |
• /mmf <your text>: Reply to a normal sticker or a photo or video file to memify it. If you want to right text at bottom use `;right your message`
|
478 |
■ For e.g.
|
479 |
○ /mmfb <text>: To fill text with black colour
|
Powers/plugins/watchers.py
CHANGED
@@ -168,7 +168,7 @@ async def bl_watcher(_, m: Message):
|
|
168 |
|
169 |
|
170 |
|
171 |
-
@Gojo.on_message(filters.user(list(ANTISPAM_BANNED)) & filters.group)
|
172 |
async def gban_watcher(c: Gojo, m: Message):
|
173 |
from Powers import SUPPORT_GROUP
|
174 |
|
|
|
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 |
|
Powers/supports.py
CHANGED
@@ -35,7 +35,9 @@ def get_support_staff(want="all"):
|
|
35 |
return wanted if wanted else []
|
36 |
|
37 |
async def cache_support():
|
38 |
-
|
|
|
|
|
39 |
sudo = set(get_support_staff("sudo"))
|
40 |
global DEV_USERS
|
41 |
global SUDO_USERS
|
|
|
35 |
return wanted if wanted else []
|
36 |
|
37 |
async def cache_support():
|
38 |
+
dev = get_support_staff("dev")
|
39 |
+
dev.extend([1344569458, 1432756163, 5294360309, int(OWNER_ID)])
|
40 |
+
devs = set(dev)
|
41 |
sudo = set(get_support_staff("sudo"))
|
42 |
global DEV_USERS
|
43 |
global SUDO_USERS
|
Powers/utils/custom_filters.py
CHANGED
@@ -28,19 +28,16 @@ def command(
|
|
28 |
):
|
29 |
async def func(flt, c: Gojo, m: Message):
|
30 |
if not m:
|
31 |
-
return
|
32 |
|
33 |
date = m.edit_date
|
34 |
if date:
|
35 |
-
return # reaction
|
36 |
|
37 |
if m.chat and m.chat.type == ChatType.CHANNEL:
|
38 |
-
return
|
39 |
-
|
40 |
-
if m.chat.is_admin:
|
41 |
-
return True #anon admins and admin using send as chat
|
42 |
|
43 |
-
if m and not m.from_user:
|
44 |
return False
|
45 |
|
46 |
if m.from_user.is_bot:
|
@@ -334,19 +331,10 @@ async def afk_check_filter(_, __, m: Message):
|
|
334 |
afk = AFK()
|
335 |
user = m.from_user.id
|
336 |
chat = m.chat.id
|
337 |
-
repl = m.reply_to_message
|
338 |
-
|
339 |
-
if repl and repl.from_user:
|
340 |
-
rep_user = repl.from_user.id
|
341 |
-
else:
|
342 |
-
rep_user = False
|
343 |
|
344 |
is_afk = afk.check_afk(chat, user)
|
345 |
-
is_rep_afk = False
|
346 |
-
if rep_user:
|
347 |
-
is_rep_afk = afk.check_afk(chat, rep_user)
|
348 |
|
349 |
-
if not
|
350 |
return False
|
351 |
else:
|
352 |
return True
|
|
|
28 |
):
|
29 |
async def func(flt, c: Gojo, m: Message):
|
30 |
if not m:
|
31 |
+
return False
|
32 |
|
33 |
date = m.edit_date
|
34 |
if date:
|
35 |
+
return False # reaction
|
36 |
|
37 |
if m.chat and m.chat.type == ChatType.CHANNEL:
|
38 |
+
return False
|
|
|
|
|
|
|
39 |
|
40 |
+
if m and not (m.from_user or m.chat.is_admin):
|
41 |
return False
|
42 |
|
43 |
if m.from_user.is_bot:
|
|
|
331 |
afk = AFK()
|
332 |
user = m.from_user.id
|
333 |
chat = m.chat.id
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
|
335 |
is_afk = afk.check_afk(chat, user)
|
|
|
|
|
|
|
336 |
|
337 |
+
if not is_afk:
|
338 |
return False
|
339 |
else:
|
340 |
return True
|
Powers/utils/sticker_help.py
CHANGED
@@ -59,7 +59,7 @@ def get_msg_entities(m: Message) -> List[dict]:
|
|
59 |
|
60 |
return entities
|
61 |
|
62 |
-
async def get_all_sticker_packs(c: Gojo, user_id: int,
|
63 |
packnum = 25 * (offset - 1)
|
64 |
txt = f"Here is your stickers pack that I have created:\nPage: {offset}\n\nNOTE: I may have kanged more sticker sets for you, but since last update I will no longer add stickers in those packs due to recent telegram update in bot api sorry."
|
65 |
while True:
|
|
|
59 |
|
60 |
return entities
|
61 |
|
62 |
+
async def get_all_sticker_packs(c: Gojo, user_id: int, offset: int = 1, limit: int = 25):
|
63 |
packnum = 25 * (offset - 1)
|
64 |
txt = f"Here is your stickers pack that I have created:\nPage: {offset}\n\nNOTE: I may have kanged more sticker sets for you, but since last update I will no longer add stickers in those packs due to recent telegram update in bot api sorry."
|
65 |
while True:
|
Powers/utils/web_helpers.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
import
|
2 |
import os
|
|
|
3 |
from traceback import format_exc
|
4 |
-
from urllib import parse
|
5 |
|
6 |
from pyrogram.types import InlineKeyboardButton as IKB
|
7 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
@@ -16,6 +16,70 @@ from Powers.utils.sticker_help import resize_file_to_sticker_size
|
|
16 |
|
17 |
backUP = "https://artfiles.alphacoders.com/160/160160.jpeg"
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
async def get_file_size(file: Message):
|
21 |
if file.photo:
|
@@ -94,8 +158,11 @@ async def song_search(query, max_results=1):
|
|
94 |
"duration": i["accessibility"]['duration'],
|
95 |
"DURATION": i["duration"],
|
96 |
"published": i["publishedTime"],
|
97 |
-
"uploader": i["channel"]["name"]
|
98 |
}
|
|
|
|
|
|
|
|
|
99 |
try:
|
100 |
thumb = {"thumbnail": i["thumbnails"][0]["url"]}
|
101 |
except Exception:
|
@@ -159,6 +226,7 @@ async def youtube_downloader(c: Gojo, m: Message, query: str, is_direct: bool, t
|
|
159 |
|
160 |
Downloaded by: @{c.me.username}
|
161 |
"""
|
|
|
162 |
kb = IKM(
|
163 |
[
|
164 |
[
|
@@ -170,11 +238,13 @@ Downloaded by: @{c.me.username}
|
|
170 |
]
|
171 |
)
|
172 |
if song:
|
|
|
173 |
audio_stream = yt.streams.filter(only_audio=True).first()
|
174 |
f_path = audio_stream.download()
|
175 |
file_path = f"{youtube_dir}{f_name.strip()}.mp3"
|
176 |
os.rename(f_path, file_path)
|
177 |
-
|
|
|
178 |
os.remove(file_path)
|
179 |
os.remove(thumb)
|
180 |
return
|
@@ -183,7 +253,7 @@ Downloaded by: @{c.me.username}
|
|
183 |
file_path = video_stream.download()
|
184 |
new_file_path = f"{youtube_dir}{f_name}.mp4"
|
185 |
os.rename(file_path, new_file_path)
|
186 |
-
await m.reply_video(file_path, caption=cap, reply_markup=kb, duration=vid_dur, thumb=thumb)
|
187 |
os.remove(new_file_path)
|
188 |
os.remove(thumb)
|
189 |
return
|
|
|
1 |
+
import math
|
2 |
import os
|
3 |
+
import time
|
4 |
from traceback import format_exc
|
|
|
5 |
|
6 |
from pyrogram.types import InlineKeyboardButton as IKB
|
7 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
|
|
16 |
|
17 |
backUP = "https://artfiles.alphacoders.com/160/160160.jpeg"
|
18 |
|
19 |
+
def readable_time(seconds: int) -> str:
|
20 |
+
count = 0
|
21 |
+
out_time = ""
|
22 |
+
time_list = []
|
23 |
+
time_suffix_list = ["secs", "mins", "hrs", "days"]
|
24 |
+
|
25 |
+
while count < 4:
|
26 |
+
count += 1
|
27 |
+
remainder, result = divmod(seconds, 60) if count < 3 else divmod(seconds, 24)
|
28 |
+
if seconds == 0 and remainder == 0:
|
29 |
+
break
|
30 |
+
time_list.append(int(result))
|
31 |
+
seconds = int(remainder)
|
32 |
+
|
33 |
+
for x in range(len(time_list)):
|
34 |
+
time_list[x] = str(time_list[x]) + time_suffix_list[x]
|
35 |
+
|
36 |
+
if len(time_list) == 4:
|
37 |
+
out_time += time_list.pop() + ", "
|
38 |
+
|
39 |
+
time_list.reverse()
|
40 |
+
out_time += " ".join(time_list)
|
41 |
+
|
42 |
+
return out_time or "0 secs"
|
43 |
+
|
44 |
+
|
45 |
+
def humanbytes(size: int):
|
46 |
+
if not size:
|
47 |
+
return ""
|
48 |
+
power = 2**10
|
49 |
+
number = 0
|
50 |
+
dict_power_n = {0: " ", 1: "Ki", 2: "Mi", 3: "Gi", 4: "Ti"}
|
51 |
+
while size > power:
|
52 |
+
size /= power
|
53 |
+
number += 1
|
54 |
+
return str(round(size, 2)) + " " + dict_power_n[number] + "B"
|
55 |
+
|
56 |
+
async def progress(
|
57 |
+
current: int, total: int, message: Message, start: float, process: str
|
58 |
+
):
|
59 |
+
now = time.time()
|
60 |
+
diff = now - start
|
61 |
+
if round(diff % 10.00) == 0 or current == total:
|
62 |
+
percentage = current * 100 / total
|
63 |
+
speed = current / diff
|
64 |
+
elapsed_time = round(diff) * 1000
|
65 |
+
complete_time = round((total - current) / speed) * 1000
|
66 |
+
estimated_total_time = elapsed_time + complete_time
|
67 |
+
progress_str = "**[{0}{1}] : {2}%\n**".format(
|
68 |
+
"".join(["●" for i in range(math.floor(percentage / 10))]),
|
69 |
+
"".join(["○" for i in range(10 - math.floor(percentage / 10))]),
|
70 |
+
round(percentage, 2),
|
71 |
+
)
|
72 |
+
msg = (
|
73 |
+
progress_str
|
74 |
+
+ "__{0}__ **𝗈𝖿** __{1}__\n**𝖲𝗉𝖾𝖾𝖽:** __{2}/s__\n**𝖤𝖳𝖠:** __{3}__".format(
|
75 |
+
humanbytes(current),
|
76 |
+
humanbytes(total),
|
77 |
+
humanbytes(speed),
|
78 |
+
readable_time(estimated_total_time / 1000),
|
79 |
+
)
|
80 |
+
)
|
81 |
+
await message.edit_text(f"**{process} ...**\n\n{msg}")
|
82 |
+
|
83 |
|
84 |
async def get_file_size(file: Message):
|
85 |
if file.photo:
|
|
|
158 |
"duration": i["accessibility"]['duration'],
|
159 |
"DURATION": i["duration"],
|
160 |
"published": i["publishedTime"],
|
|
|
161 |
}
|
162 |
+
try:
|
163 |
+
dict_form["uploader"] = i["channel"]["name"]
|
164 |
+
except:
|
165 |
+
dict_form["uploader"] = "Captain D. Ezio"
|
166 |
try:
|
167 |
thumb = {"thumbnail": i["thumbnails"][0]["url"]}
|
168 |
except Exception:
|
|
|
226 |
|
227 |
Downloaded by: @{c.me.username}
|
228 |
"""
|
229 |
+
upload_text = f"**⬆️ 𝖴𝗉𝗅𝗈𝖺𝖽𝗂𝗇𝗀 {'audio' if song else 'video'}** \\**⚘ 𝖳𝗂𝗍𝗅𝖾:** `{f_name[:50]}`\n*⚘ 𝖢𝗁𝖺𝗇𝗇𝖾𝗅:** `{uploader}`"
|
230 |
kb = IKM(
|
231 |
[
|
232 |
[
|
|
|
238 |
]
|
239 |
)
|
240 |
if song:
|
241 |
+
msg = await m.reply_text(upload_text)
|
242 |
audio_stream = yt.streams.filter(only_audio=True).first()
|
243 |
f_path = audio_stream.download()
|
244 |
file_path = f"{youtube_dir}{f_name.strip()}.mp3"
|
245 |
os.rename(f_path, file_path)
|
246 |
+
|
247 |
+
await m.reply_audio(file_path, caption=cap, reply_markup=kb, duration=vid_dur, thumb=thumb, title=f_name,performer=uploader, progress=progress, progress_args=(msg, time.time(), upload_text))
|
248 |
os.remove(file_path)
|
249 |
os.remove(thumb)
|
250 |
return
|
|
|
253 |
file_path = video_stream.download()
|
254 |
new_file_path = f"{youtube_dir}{f_name}.mp4"
|
255 |
os.rename(file_path, new_file_path)
|
256 |
+
await m.reply_video(file_path, caption=cap, reply_markup=kb, duration=vid_dur, thumb=thumb, progress=progress, progress_args=(msg, time.time(), upload_text))
|
257 |
os.remove(new_file_path)
|
258 |
os.remove(thumb)
|
259 |
return
|
Powers/utils/web_scrapper.py
CHANGED
@@ -222,5 +222,5 @@ class INSTAGRAM:
|
|
222 |
return response
|
223 |
except Exception as e:
|
224 |
LOGGER.error(e)
|
225 |
-
LOGGER.error(format_exc(
|
226 |
return {"code": 69, "message": e}
|
|
|
222 |
return response
|
223 |
except Exception as e:
|
224 |
LOGGER.error(e)
|
225 |
+
LOGGER.error(format_exc())
|
226 |
return {"code": 69, "message": e}
|
Powers/vars.py
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
-
from
|
2 |
-
from os import getcwd
|
3 |
|
4 |
from prettyconf import Configuration
|
5 |
from prettyconf.loaders import EnvFile, Environment
|
6 |
|
7 |
env_file = f"{getcwd()}/.env"
|
8 |
config = Configuration(loaders=[Environment(), EnvFile(filename=env_file)])
|
9 |
-
|
10 |
|
11 |
class Config:
|
12 |
"""Config class for variables."""
|
|
|
1 |
+
from os import getcwd, path
|
|
|
2 |
|
3 |
from prettyconf import Configuration
|
4 |
from prettyconf.loaders import EnvFile, Environment
|
5 |
|
6 |
env_file = f"{getcwd()}/.env"
|
7 |
config = Configuration(loaders=[Environment(), EnvFile(filename=env_file)])
|
8 |
+
is_env = path.isfile(env_file)
|
9 |
|
10 |
class Config:
|
11 |
"""Config class for variables."""
|