Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/pillow-11.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgojoof6eyes authored Jan 7, 2025
2 parents 4bd30c4 + 2efe8f3 commit cde9410
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Powers/plugins/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions Powers/plugins/birthday.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
84 changes: 58 additions & 26 deletions Powers/plugins/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -136,26 +151,27 @@ async def user_info(c: Gojo, user, already=False):
<b><i><u>⚡️ Extracted User info From Telegram ⚡️</b></i></u>
<b>🆔 User ID</b>: <code>{user_id}</code>
<b>📎 Link To Profile</b>: <a href='tg://user?id={user_id}'>Click Here🚪</a>
<b>🫵 Mention</b>: {mention}
<b>🗣 First Name</b>: <code>{first_name}</code>
<b>🔅 Second Name</b>: <code>{last_name}</code>
<b>🗣 Full Name</b>: <code>{full_name}</code>
<b>🔍 Username</b>: {("@" + username) if username else "NA"}
<b>✍️ Bio</b>: `{about}`
<b>🧑‍💻 Support</b>: {is_support}\n"""
<b>✍️ Bio</b>: `{about}`\n"""
if dob:
caption += f"<b>🎂 Birthday<b>: {dob}\n<b>🧑‍💻 Support</b>: {is_support}\n"
else:
caption += f"<b>🧑‍💻 Support</b>: {is_support}\n"
if is_support:
caption += f"<b>🥷 Support user type</b>: <code>{omp}</code>\n<b>💣 Gbanned</b>: {gban}\n"
else:
caption += f"<b>💣 Gbanned</b>: {gban}\n"

if gban:
caption += f"<b>☠️ Gban reason</b>: <code>{reason}</code>\n"
caption += f"<b>☠️ Gban reason</b>: <code>{reason}</code>"
caption += f"""
<b>🌐 DC ID</b>: {dc_id}
<b>✋ RESTRICTED</b>: {is_restricted}
<b>✅ VERIFIED</b>: {is_verified}
<b>❌ FAKE</b> : {is_fake}
<b>⚠️ SCAM</b> : {is_scam}
<b>⚠️ SCAM</b> : {is_scam}
<b>🤖 BOT</b>: {is_bot}
<b>👀 Last seen</b>: <code>{last_date}</code>
"""
Expand Down Expand Up @@ -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"<b>👥 Status </b>: {status}"

if not photo_id:
await m.delete()
Expand Down
42 changes: 22 additions & 20 deletions Powers/plugins/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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"]
Expand All @@ -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."""
3 changes: 3 additions & 0 deletions Powers/plugins/scheduled_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion Powers/utils/custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
8 changes: 2 additions & 6 deletions Powers/utils/web_scrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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}",
Expand Down

0 comments on commit cde9410

Please sign in to comment.