diff --git a/Powers/plugins/admin.py b/Powers/plugins/admin.py
index beb90630..c5aa3278 100644
--- a/Powers/plugins/admin.py
+++ b/Powers/plugins/admin.py
@@ -16,7 +16,7 @@
from Powers.database.approve_db import Approve
from Powers.database.reporting_db import Reporting
from Powers.supports import get_support_staff
-from Powers.utils.caching import admin_cache_reload
+from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
from Powers.utils.custom_filters import admin_filter, command, promote_filter
from Powers.utils.extract_user import extract_user
from Powers.utils.parser import mention_html
diff --git a/Powers/plugins/birthday.py b/Powers/plugins/birthday.py
index 9c772900..ebbd5931 100644
--- a/Powers/plugins/birthday.py
+++ b/Powers/plugins/birthday.py
@@ -30,11 +30,11 @@ async def remember_me(c: Gojo, m: Message):
splited = m.text.split()
if len(splited) == 1:
await m.reply_text(
- "**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")
+ "**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\nIf not replied to user then register the birthday of the one who have given the command")
return
if len(splited) != 2 and m.reply_to_message:
await m.reply_text(
- "**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")
+ "**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\nIf not replied to user then register the birthday of the one who have given the command")
return
DOB = splited[1] if len(splited) == 2 else splited[2]
if len(splited) == 2 and m.reply_to_message:
@@ -65,7 +65,7 @@ async def remember_me(c: Gojo, m: Message):
data = {"user_id": user, "dob": DOB, "is_year": is_year}
try:
- if result := bday_info.find_one({"user_id": user}):
+ if bday_info.find_one({"user_id": user}):
await m.reply_text("User is already in my database")
return
except Exception as e:
@@ -90,7 +90,7 @@ async def who_are_you_again(c: Gojo, m: Message):
return
user = m.from_user.id
try:
- if result := bday_info.find_one({"user_id": user}):
+ if bday_info.find_one({"user_id": user}):
bday_info.delete_one({"user_id": user})
await m.reply_text("Removed your birthday")
else:
@@ -128,10 +128,18 @@ async def who_is_next(c: Gojo, m: Message):
return
txt = "π Upcomming Birthdays Are π\n"
for i in users:
+ try:
+ user = await c.get_users(i["user_id"])
+ if user.is_deleted:
+ bday_info.delete_one({"user_id": i["user_id"]})
+ continue
+ name = user.full_name
+ except:
+ name = i["user_id"]
DOB = give_date(i["dob"])
dete = date(curr.year, DOB.month, DOB.day)
leff = (dete - curr).days
- txt += f"`{i['user_id']}` : {leff} days left\n"
+ txt += f"{name} : {leff} days left\n"
txt += "\n\nYou can use /info [user id] to get info about the user"
await xx.delete()
await m.reply_text(txt)
@@ -151,6 +159,8 @@ async def cant_recall_it(c: Gojo, m: Message):
try:
result = bday_info.find_one({"user_id": user})
if not result:
+ if not m.reply_to_message:
+ await m.reply_text("You are not registered in my database\nUse `/remember` to register your birth day so I can wish you")
await m.reply_text("User is not in my database")
return
except Exception as e:
diff --git a/Powers/plugins/info.py b/Powers/plugins/info.py
index 095c87ab..e869124c 100644
--- a/Powers/plugins/info.py
+++ b/Powers/plugins/info.py
@@ -7,17 +7,21 @@
from pyrogram.errors import EntityBoundsInvalid, MediaCaptionTooLong, RPCError
from pyrogram.raw.functions.channels import GetFullChannel
from pyrogram.raw.functions.users import GetFullUser
+from pyrogram.raw.types import Channel, UserFull, users
from pyrogram.types import Message
-from Powers import LOGGER, OWNER_ID
+from Powers import BDB_URI, LOGGER, OWNER_ID
from Powers.bot_class import Gojo
from Powers.database.antispam_db import GBan
+from Powers.database.approve_db import Approve
from Powers.supports import get_support_staff
from Powers.utils.custom_filters import command
from Powers.utils.extract_user import extract_user
gban_db = GBan()
+if BDB_URI:
+ from Powers.plugins import bday_info
async def count(c: Gojo, chat):
try:
@@ -57,11 +61,18 @@ async def count(c: Gojo, chat):
async def user_info(c: Gojo, user, already=False):
- if not already:
- user = await c.get_users(user_ids=user)
- if not user.first_name:
- return ["Deleted account", None]
+ user_all: users.UserFull = await c.invoke(
+ GetFullUser(
+ id=await c.resolve_peer(user)
+ )
+ )
+ user = await c.get_users(user)
+ full_user: UserFull = user_all.full_user
+ channel: Channel = user_all.chats
+ if user.is_deleted:
+ return "Deleted account", None
+
gbanned, reason_gban = gban_db.get_gban(user.id)
if gbanned:
gban = True
@@ -71,24 +82,28 @@ async def user_info(c: Gojo, user, already=False):
reason = "User is not gbanned"
user_id = user.id
- userrr = await c.resolve_peer(user_id)
- about = "NA"
- try:
- ll = await c.invoke(
- GetFullUser(
- id=userrr
- )
- )
- about = ll.full_user.about
- except Exception:
- pass
+ about = full_user.about
SUPPORT_STAFF = get_support_staff()
username = user.username
- first_name = user.first_name
- last_name = user.last_name
- mention = user.mention(f"{first_name}")
+ full_name = user.full_name
dc_id = user.dc_id
is_verified = user.is_verified
+ mention = user.mention
+ dob = False
+ if dob := full_user.birthday:
+ dob = datetime(int(dob.year), int(dob.month), int(dob.day)).strftime("%d %B %Y")
+ else:
+ if BDB_URI:
+ try:
+ if result := bday_info.find_one({"user_id": user}):
+ u_dob = datetime.strptime(result["dob"], "%d/%m/%Y")
+ day = u_dob.day
+ formatted = u_dob.strftime("%B %Y")
+ suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
+ dob = f"{day}{suffix} {formatted}"
+ except:
+ pass
+
is_restricted = user.is_restricted
photo_id = user.photo.big_file_id if user.photo else None
is_support = user_id in SUPPORT_STAFF
@@ -136,26 +151,27 @@ async def user_info(c: Gojo, user, already=False):
β‘οΈ Extracted User info From Telegram β‘οΈ
π User ID: {user_id}
-π Link To Profile: Click Hereπͺ
π«΅ Mention: {mention}
-π£ First Name: {first_name}
-π
Second Name: {last_name}
+π£ Full Name: {full_name}
π Username: {("@" + username) if username else "NA"}
-βοΈ Bio: `{about}`
-π§βπ» Support: {is_support}\n"""
+βοΈ Bio: `{about}`\n"""
+ if dob:
+ caption += f"π Birthday: {dob}\nπ§βπ» Support: {is_support}\n"
+ else:
+ caption += f"π§βπ» Support: {is_support}\n"
if is_support:
caption += f"π₯· Support user type: {omp}
\nπ£ Gbanned: {gban}\n"
else:
caption += f"π£ Gbanned: {gban}\n"
if gban:
- caption += f"β οΈ Gban reason: {reason}
\n"
+ caption += f"β οΈ Gban reason: {reason}
"
caption += f"""
π DC ID: {dc_id}
β RESTRICTED: {is_restricted}
β
VERIFIED: {is_verified}
β FAKE : {is_fake}
-β οΈ SCAM : {is_scam}
+β οΈ SCAM : {is_scam}
π€ BOT: {is_bot}
π Last seen: {last_date}
"""
@@ -258,6 +274,22 @@ async def info_func(c: Gojo, message: Message):
LOGGER.error(e)
LOGGER.error(format_exc())
return await m.edit(str(e))
+
+
+ status = False
+ if m.chat.id != m.from_user.id:
+ try:
+ if status:= await m.chat.get_member(user):
+ status = str(status.status.value).capitalize()
+ except:
+ pass
+ if not status:
+ approved_users = Approve(m.chat.id).list_approved()
+ if user in approved_users:
+ status = "Approved"
+
+ if status:
+ info_caption += f"π₯ Status : {status}"
if not photo_id:
await m.delete()
diff --git a/Powers/plugins/locks.py b/Powers/plugins/locks.py
index 97b4a085..45146b57 100644
--- a/Powers/plugins/locks.py
+++ b/Powers/plugins/locks.py
@@ -5,7 +5,8 @@
from pyrogram import filters
from pyrogram.enums import MessageEntityType as MET
from pyrogram.enums import MessageServiceType as MST
-from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
+from pyrogram.errors import (ChatAdminRequired, ChatNotModified, RPCError,
+ UserAdminInvalid)
from pyrogram.types import CallbackQuery, ChatPermissions, Message
from Powers import LOGGER
@@ -495,6 +496,8 @@ async def servicess(c: Gojo, m: Message):
timee = datetime.now() + timedelta(minutes=5)
await m.chat.ban_member(i.id, until_date=timee)
sleep(1)
+ except UserAdminInvalid:
+ continue
except Exception as ef:
LOGGER.error(ef)
LOGGER.error(format_exc())
@@ -551,6 +554,23 @@ async def prevent_approved(m: Message):
return
+@Gojo.on_callback_query(filters.regex("^LOCK_TYPES"))
+async def lock_types_callback(c: Gojo, q: CallbackQuery):
+ data = q.data
+
+ if data == "LOCK_TYPES":
+ kb = ikb([[("Back", "LOCK_TYPES_back")]])
+ await q.edit_message_caption(
+ l_t,
+ reply_markup=kb
+ )
+ else:
+ kb = ikb([[("Lock Types", "LOCK_TYPES")]])
+ await q.edit_message_caption(
+ __HELP__,
+ reply_markup=kb
+ )
+
__PLUGIN__ = "locks"
__alt_name__ = ["grouplock", "lock", "grouplocks"]
@@ -573,22 +593,4 @@ async def prevent_approved(m: Message):
β’ /locktypes: Check available lock types!
**Example:**
-`/lock media`: this locks all the media messages in the chat."""
-
-
-@Gojo.on_callback_query(filters.regex("^LOCK_TYPES"))
-async def lock_types_callback(c: Gojo, q: CallbackQuery):
- data = q.data
-
- if data == "LOCK_TYPES":
- kb = ikb([[("Back", "LOCK_TYPES_back")]])
- await q.edit_message_caption(
- l_t,
- reply_markup=kb
- )
- else:
- kb = ikb([[("Lock Types", "LOCK_TYPES")]])
- await q.edit_message_caption(
- __HELP__,
- reply_markup=kb
- )
+`/lock media`: this locks all the media messages in the chat."""
\ No newline at end of file
diff --git a/Powers/plugins/scheduled_jobs.py b/Powers/plugins/scheduled_jobs.py
index fc2da31f..05d5c729 100644
--- a/Powers/plugins/scheduled_jobs.py
+++ b/Powers/plugins/scheduled_jobs.py
@@ -47,6 +47,9 @@ async def send_wishish(JJK: Client):
suffix.get((agee % 10), "th")
agee = f"{agee}{suf}"
U = await JJK.get_chat_member(chat_id=j, user_id=i["user_id"])
+ if U.user.is_deleted:
+ bday_info.delete_one({"user_id": i["user_id"]})
+ continue
wish = choice(birthday_wish)
if U.status in [ChatMemberStatus.MEMBER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
xXx = await JJK.send_message(j, f"Happy {agee} birthday {U.user.mention}π₯³\n{wish}")
diff --git a/Powers/utils/custom_filters.py b/Powers/utils/custom_filters.py
index 54ae32e0..85cf4635 100644
--- a/Powers/utils/custom_filters.py
+++ b/Powers/utils/custom_filters.py
@@ -42,7 +42,7 @@ async def func(flt, c: Gojo, m: Message):
if m and not m.from_user and not m.chat.is_admin:
return False
- if m.from_user.is_bot:
+ if m.from_user and m.from_user.is_bot:
return False
if any([m.forward_from_chat, m.forward_from]):
diff --git a/Powers/utils/web_scrapper.py b/Powers/utils/web_scrapper.py
index 29ff3fa5..5c1ef24f 100644
--- a/Powers/utils/web_scrapper.py
+++ b/Powers/utils/web_scrapper.py
@@ -209,8 +209,6 @@ def get_videos(self) -> list:
# else:
# return {}
-curr_timeout = 20
-timeout = httpx.Timeout(curr_timeout)
class INSTAGRAM:
def __init__(self, url):
@@ -220,15 +218,13 @@ def is_correct_url(self):
return bool((re.compile(r"^https?://(?:www\.)?instagram\.com/")).match(self.url))
def get_media(self):
- global curr_timeout
try:
return httpx.post(
- f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}",
- timeout=timeout
+ f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}"
).json()
except httpx.ReadTimeout:
try:
- curr_timeout += 10
+ curr_timeout = 10
timeout = httpx.Timeout(curr_timeout)
return httpx.post(
f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}",