Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
7eeba00
1
Parent(s):
aee3bb4
...
Browse files- Powers/plugins/__init__.py +9 -8
- Powers/plugins/admin.py +5 -1
- Powers/plugins/birthday.py +9 -4
- Powers/plugins/start.py +13 -13
- Powers/utils/start_utils.py +7 -4
Powers/plugins/__init__.py
CHANGED
@@ -20,12 +20,13 @@ from pymongo.errors import PyMongoError
|
|
20 |
|
21 |
from Powers import BDB_URI, LOGGER
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
bday_info = Birth_main_db['users_bday']
|
31 |
-
bday_cinfo = Birth_main_db["chat_bday"]
|
|
|
20 |
|
21 |
from Powers import BDB_URI, LOGGER
|
22 |
|
23 |
+
if BDB_URI:
|
24 |
+
try:
|
25 |
+
BIRTHDAY_DB = MongoClient(BDB_URI)
|
26 |
+
except PyMongoError as f:
|
27 |
+
LOGGER.error(f"Error in Mongodb2: {f}")
|
28 |
+
exiter(1)
|
29 |
+
Birth_main_db = BIRTHDAY_DB["birthdays"]
|
30 |
|
31 |
+
bday_info = Birth_main_db['users_bday']
|
32 |
+
bday_cinfo = Birth_main_db["chat_bday"]
|
Powers/plugins/admin.py
CHANGED
@@ -533,8 +533,11 @@ async def setgpic(c: Gojo, m: Message):
|
|
533 |
if not m.reply_to_message.photo and not m.reply_to_message.document:
|
534 |
return await m.reply_text("Reply to a photo to set it as chat photo")
|
535 |
photo = await m.reply_to_message.download()
|
|
|
|
|
|
|
536 |
try:
|
537 |
-
await m.chat.set_photo(photo)
|
538 |
except Exception as e:
|
539 |
remove(photo)
|
540 |
return await m.reply_text(f"Error: {e}")
|
@@ -567,6 +570,7 @@ __HELP__ = """
|
|
567 |
• /promote: Promotes the user replied to or tagged (supports with title).
|
568 |
• /fullpromote: Fully Promotes the user replied to or tagged (supports with title).
|
569 |
• /demote: Demotes the user replied to or tagged.
|
|
|
570 |
• /admincache: Reloads the List of all the admins in the Group.
|
571 |
• /zombies: Bans all the deleted accounts. (owner only)
|
572 |
• /title: sets a custom title for an admin that the bot promoted.
|
|
|
533 |
if not m.reply_to_message.photo and not m.reply_to_message.document:
|
534 |
return await m.reply_text("Reply to a photo to set it as chat photo")
|
535 |
photo = await m.reply_to_message.download()
|
536 |
+
is_vid = False
|
537 |
+
if m.reply_to_message.video:
|
538 |
+
is_vid = True
|
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}")
|
|
|
570 |
• /promote: Promotes the user replied to or tagged (supports with title).
|
571 |
• /fullpromote: Fully Promotes the user replied to or tagged (supports with title).
|
572 |
• /demote: Demotes the user replied to or tagged.
|
573 |
+
• /setgpic: Set group picture.
|
574 |
• /admincache: Reloads the List of all the admins in the Group.
|
575 |
• /zombies: Bans all the deleted accounts. (owner only)
|
576 |
• /title: sets a custom title for an admin that the bot promoted.
|
Powers/plugins/birthday.py
CHANGED
@@ -13,7 +13,10 @@ from pyrogram.types import Message
|
|
13 |
from Powers import BDB_URI, LOGGER, TIME_ZONE
|
14 |
from Powers.bot_class import Gojo
|
15 |
from Powers.database.chats_db import Chats
|
16 |
-
|
|
|
|
|
|
|
17 |
from Powers.utils.custom_filters import command
|
18 |
from Powers.utils.extras import birthday_wish
|
19 |
|
@@ -133,7 +136,7 @@ async def who_is_next(c: Gojo, m: Message):
|
|
133 |
if Chats(m.chat.id).user_is_in_chat(i["user_id"]):
|
134 |
dob = give_date(i["dob"])
|
135 |
if dob.month >= curr.month:
|
136 |
-
if (dob.month == curr.month and not dob.day < curr.day) or dob.month
|
137 |
users.append(i)
|
138 |
elif dob.month < curr.month:
|
139 |
pass
|
@@ -154,14 +157,16 @@ async def who_is_next(c: Gojo, m: Message):
|
|
154 |
await m.reply_text(txt)
|
155 |
return
|
156 |
|
157 |
-
@Gojo.on_message(command(["getbday","gbday","mybirthday","
|
158 |
async def cant_recall_it(c: Gojo, m: Message):
|
159 |
if not BDB_URI:
|
160 |
await m.reply_text("BDB_URI is not configured")
|
161 |
return
|
162 |
user = m.from_user.id
|
|
|
163 |
if m.reply_to_message:
|
164 |
user = m.reply_to_message.from_user.id
|
|
|
165 |
try:
|
166 |
result = bday_info.find_one({"user_id":user})
|
167 |
if not result:
|
@@ -176,7 +181,7 @@ async def cant_recall_it(c: Gojo, m: Message):
|
|
176 |
if u_dob.month < curr.month:
|
177 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
178 |
days_left = (next_b - curr).days
|
179 |
-
txt = f"
|
180 |
else:
|
181 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
182 |
days_left = (u_dobm - curr).days
|
|
|
13 |
from Powers import BDB_URI, LOGGER, TIME_ZONE
|
14 |
from Powers.bot_class import Gojo
|
15 |
from Powers.database.chats_db import Chats
|
16 |
+
|
17 |
+
if BDB_URI:
|
18 |
+
from Powers.plugins import bday_cinfo, bday_info
|
19 |
+
|
20 |
from Powers.utils.custom_filters import command
|
21 |
from Powers.utils.extras import birthday_wish
|
22 |
|
|
|
136 |
if Chats(m.chat.id).user_is_in_chat(i["user_id"]):
|
137 |
dob = give_date(i["dob"])
|
138 |
if dob.month >= curr.month:
|
139 |
+
if (dob.month == curr.month and not dob.day < curr.day) or dob.month >= curr.month:
|
140 |
users.append(i)
|
141 |
elif dob.month < curr.month:
|
142 |
pass
|
|
|
157 |
await m.reply_text(txt)
|
158 |
return
|
159 |
|
160 |
+
@Gojo.on_message(command(["getbday","gbday","mybirthday","mybday"]))
|
161 |
async def cant_recall_it(c: Gojo, m: Message):
|
162 |
if not BDB_URI:
|
163 |
await m.reply_text("BDB_URI is not configured")
|
164 |
return
|
165 |
user = m.from_user.id
|
166 |
+
men = m.from_user.mention
|
167 |
if m.reply_to_message:
|
168 |
user = m.reply_to_message.from_user.id
|
169 |
+
men = m.reply_to_message.from_user.mention
|
170 |
try:
|
171 |
result = bday_info.find_one({"user_id":user})
|
172 |
if not result:
|
|
|
181 |
if u_dob.month < curr.month:
|
182 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
183 |
days_left = (next_b - curr).days
|
184 |
+
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {days_left}"
|
185 |
else:
|
186 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
187 |
days_left = (u_dobm - curr).days
|
Powers/plugins/start.py
CHANGED
@@ -66,7 +66,7 @@ async def close_admin_callback(_, q: CallbackQuery):
|
|
66 |
async def start(c: Gojo, m: Message):
|
67 |
|
68 |
if m.chat.type == ChatType.PRIVATE:
|
69 |
-
if len(m.text.split()) > 1:
|
70 |
help_option = (m.text.split(None, 1)[1]).lower()
|
71 |
|
72 |
if help_option.startswith("note") and (
|
@@ -84,7 +84,16 @@ async def start(c: Gojo, m: Message):
|
|
84 |
|
85 |
if not help_msg:
|
86 |
return
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
if help_option.split("_")[1] == "help":
|
89 |
await m.reply_photo(
|
90 |
photo=str(choice(StartPic)),
|
@@ -94,15 +103,6 @@ async def start(c: Gojo, m: Message):
|
|
94 |
quote=True,
|
95 |
)
|
96 |
return
|
97 |
-
else:
|
98 |
-
await m.reply_photo(
|
99 |
-
photo=str(choice(StartPic)),
|
100 |
-
caption=help_msg,
|
101 |
-
parse_mode=enums.ParseMode.MARKDOWN,
|
102 |
-
reply_markup=help_kb,
|
103 |
-
quote=True,
|
104 |
-
)
|
105 |
-
return
|
106 |
try:
|
107 |
cpt = f"""
|
108 |
Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! I am Gojo ✨.
|
@@ -193,8 +193,8 @@ You can use `$` and `!` in placec of `/` as your prefix handler
|
|
193 |
@Gojo.on_message(command("help"))
|
194 |
async def help_menu(_, m: Message):
|
195 |
if len(m.text.split()) >= 2:
|
196 |
-
textt = m.text.replace(" ","_")
|
197 |
-
help_option = (textt.split(None
|
198 |
help_msg, help_kb = await get_help_msg(m, help_option)
|
199 |
|
200 |
if not help_msg:
|
|
|
66 |
async def start(c: Gojo, m: Message):
|
67 |
|
68 |
if m.chat.type == ChatType.PRIVATE:
|
69 |
+
if len(m.text.strip().split()) > 1:
|
70 |
help_option = (m.text.split(None, 1)[1]).lower()
|
71 |
|
72 |
if help_option.startswith("note") and (
|
|
|
84 |
|
85 |
if not help_msg:
|
86 |
return
|
87 |
+
elif help_msg:
|
88 |
+
await m.reply_photo(
|
89 |
+
photo=str(choice(StartPic)),
|
90 |
+
caption=help_msg,
|
91 |
+
parse_mode=enums.ParseMode.MARKDOWN,
|
92 |
+
reply_markup=help_kb,
|
93 |
+
quote=True,
|
94 |
+
)
|
95 |
+
return
|
96 |
+
if len(help_option.split("_",1)) == 2:
|
97 |
if help_option.split("_")[1] == "help":
|
98 |
await m.reply_photo(
|
99 |
photo=str(choice(StartPic)),
|
|
|
103 |
quote=True,
|
104 |
)
|
105 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
try:
|
107 |
cpt = f"""
|
108 |
Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! I am Gojo ✨.
|
|
|
193 |
@Gojo.on_message(command("help"))
|
194 |
async def help_menu(_, m: Message):
|
195 |
if len(m.text.split()) >= 2:
|
196 |
+
textt = m.text.replace(" ","_",).replace("_"," ",1)
|
197 |
+
help_option = (textt.split(None)[1]).lower()
|
198 |
help_msg, help_kb = await get_help_msg(m, help_option)
|
199 |
|
200 |
if not help_msg:
|
Powers/utils/start_utils.py
CHANGED
@@ -267,13 +267,16 @@ async def get_help_msg(m: Message or CallbackQuery, help_option: str):
|
|
267 |
f"{m.from_user.id} fetched help for {help_option} in {m.chat.id}",
|
268 |
)
|
269 |
else:
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
|
|
272 |
I'm here to help you manage your groups!
|
273 |
Commands available:
|
274 |
× /start: Start the bot
|
275 |
-
× /help: Give's you this message.
|
276 |
-
"""
|
277 |
ou = await gen_cmds_kb(m)
|
278 |
help_kb = ikb(ou, True)
|
279 |
|
|
|
267 |
f"{m.from_user.id} fetched help for {help_option} in {m.chat.id}",
|
268 |
)
|
269 |
else:
|
270 |
+
if isinstance(m,CallbackQuery):
|
271 |
+
mes = m.message
|
272 |
+
else:
|
273 |
+
mes = m
|
274 |
+
help_msg = f"""
|
275 |
+
Hey **[{mes.from_user.first_name}](http://t.me/{mes.from_user.username})**!I am Gojo✨.
|
276 |
I'm here to help you manage your groups!
|
277 |
Commands available:
|
278 |
× /start: Start the bot
|
279 |
+
× /help: Give's you this message."""
|
|
|
280 |
ou = await gen_cmds_kb(m)
|
281 |
help_kb = ikb(ou, True)
|
282 |
|