Captain Ezio commited on
Commit
d9f5db7
·
1 Parent(s): 66e0581
Powers/plugins/admin.py CHANGED
@@ -16,7 +16,7 @@ from Powers.bot_class import Gojo
16
  from Powers.database.approve_db import Approve
17
  from Powers.database.reporting_db import Reporting
18
  from Powers.supports import get_support_staff
19
- from Powers.utils.caching import admin_cache_reload
20
  from Powers.utils.custom_filters import admin_filter, command, promote_filter
21
  from Powers.utils.extract_user import extract_user
22
  from Powers.utils.parser import mention_html
 
16
  from Powers.database.approve_db import Approve
17
  from Powers.database.reporting_db import Reporting
18
  from Powers.supports import get_support_staff
19
+ from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
20
  from Powers.utils.custom_filters import admin_filter, command, promote_filter
21
  from Powers.utils.extract_user import extract_user
22
  from Powers.utils.parser import mention_html
Powers/plugins/birthday.py CHANGED
@@ -30,11 +30,11 @@ async def remember_me(c: Gojo, m: Message):
30
  splited = m.text.split()
31
  if len(splited) == 1:
32
  await m.reply_text(
33
- "**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")
34
  return
35
  if len(splited) != 2 and m.reply_to_message:
36
  await m.reply_text(
37
- "**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")
38
  return
39
  DOB = splited[1] if len(splited) == 2 else splited[2]
40
  if len(splited) == 2 and m.reply_to_message:
@@ -65,7 +65,7 @@ async def remember_me(c: Gojo, m: Message):
65
 
66
  data = {"user_id": user, "dob": DOB, "is_year": is_year}
67
  try:
68
- if result := bday_info.find_one({"user_id": user}):
69
  await m.reply_text("User is already in my database")
70
  return
71
  except Exception as e:
@@ -90,7 +90,7 @@ async def who_are_you_again(c: Gojo, m: Message):
90
  return
91
  user = m.from_user.id
92
  try:
93
- if result := bday_info.find_one({"user_id": user}):
94
  bday_info.delete_one({"user_id": user})
95
  await m.reply_text("Removed your birthday")
96
  else:
@@ -128,10 +128,18 @@ async def who_is_next(c: Gojo, m: Message):
128
  return
129
  txt = "🎊 Upcomming Birthdays Are 🎊\n"
130
  for i in users:
 
 
 
 
 
 
 
 
131
  DOB = give_date(i["dob"])
132
  dete = date(curr.year, DOB.month, DOB.day)
133
  leff = (dete - curr).days
134
- txt += f"`{i['user_id']}` : {leff} days left\n"
135
  txt += "\n\nYou can use /info [user id] to get info about the user"
136
  await xx.delete()
137
  await m.reply_text(txt)
@@ -151,6 +159,8 @@ async def cant_recall_it(c: Gojo, m: Message):
151
  try:
152
  result = bday_info.find_one({"user_id": user})
153
  if not result:
 
 
154
  await m.reply_text("User is not in my database")
155
  return
156
  except Exception as e:
 
30
  splited = m.text.split()
31
  if len(splited) == 1:
32
  await m.reply_text(
33
+ "**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")
34
  return
35
  if len(splited) != 2 and m.reply_to_message:
36
  await m.reply_text(
37
+ "**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")
38
  return
39
  DOB = splited[1] if len(splited) == 2 else splited[2]
40
  if len(splited) == 2 and m.reply_to_message:
 
65
 
66
  data = {"user_id": user, "dob": DOB, "is_year": is_year}
67
  try:
68
+ if bday_info.find_one({"user_id": user}):
69
  await m.reply_text("User is already in my database")
70
  return
71
  except Exception as e:
 
90
  return
91
  user = m.from_user.id
92
  try:
93
+ if bday_info.find_one({"user_id": user}):
94
  bday_info.delete_one({"user_id": user})
95
  await m.reply_text("Removed your birthday")
96
  else:
 
128
  return
129
  txt = "🎊 Upcomming Birthdays Are 🎊\n"
130
  for i in users:
131
+ try:
132
+ user = await c.get_users(i["user_id"])
133
+ if user.is_deleted:
134
+ bday_info.delete_one({"user_id": i["user_id"]})
135
+ continue
136
+ name = user.full_name
137
+ except:
138
+ name = i["user_id"]
139
  DOB = give_date(i["dob"])
140
  dete = date(curr.year, DOB.month, DOB.day)
141
  leff = (dete - curr).days
142
+ txt += f"{name} : {leff} days left\n"
143
  txt += "\n\nYou can use /info [user id] to get info about the user"
144
  await xx.delete()
145
  await m.reply_text(txt)
 
159
  try:
160
  result = bday_info.find_one({"user_id": user})
161
  if not result:
162
+ if not m.reply_to_message:
163
+ await m.reply_text("You are not registered in my database\nUse `/remember` to register your birth day so I can wish you")
164
  await m.reply_text("User is not in my database")
165
  return
166
  except Exception as e:
Powers/plugins/info.py CHANGED
@@ -7,11 +7,14 @@ from pyrogram import enums
7
  from pyrogram.errors import EntityBoundsInvalid, MediaCaptionTooLong, RPCError
8
  from pyrogram.raw.functions.channels import GetFullChannel
9
  from pyrogram.raw.functions.users import GetFullUser
 
10
  from pyrogram.types import Message
11
 
12
- from Powers import LOGGER, OWNER_ID
13
  from Powers.bot_class import Gojo
14
  from Powers.database.antispam_db import GBan
 
 
15
  from Powers.supports import get_support_staff
16
  from Powers.utils.custom_filters import command
17
  from Powers.utils.extract_user import extract_user
@@ -57,11 +60,18 @@ async def count(c: Gojo, chat):
57
 
58
 
59
  async def user_info(c: Gojo, user, already=False):
60
- if not already:
61
- user = await c.get_users(user_ids=user)
62
- if not user.first_name:
63
- return ["Deleted account", None]
 
 
 
 
 
 
64
 
 
65
  gbanned, reason_gban = gban_db.get_gban(user.id)
66
  if gbanned:
67
  gban = True
@@ -71,24 +81,28 @@ async def user_info(c: Gojo, user, already=False):
71
  reason = "User is not gbanned"
72
 
73
  user_id = user.id
74
- userrr = await c.resolve_peer(user_id)
75
- about = "NA"
76
- try:
77
- ll = await c.invoke(
78
- GetFullUser(
79
- id=userrr
80
- )
81
- )
82
- about = ll.full_user.about
83
- except Exception:
84
- pass
85
  SUPPORT_STAFF = get_support_staff()
86
  username = user.username
87
- first_name = user.first_name
88
- last_name = user.last_name
89
- mention = user.mention(f"{first_name}")
90
  dc_id = user.dc_id
91
  is_verified = user.is_verified
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  is_restricted = user.is_restricted
93
  photo_id = user.photo.big_file_id if user.photo else None
94
  is_support = user_id in SUPPORT_STAFF
@@ -136,26 +150,27 @@ async def user_info(c: Gojo, user, already=False):
136
  <b><i><u>⚡️ Extracted User info From Telegram ⚡️</b></i></u>
137
 
138
  <b>🆔 User ID</b>: <code>{user_id}</code>
139
- <b>📎 Link To Profile</b>: <a href='tg://user?id={user_id}'>Click Here🚪</a>
140
  <b>🫵 Mention</b>: {mention}
141
- <b>🗣 First Name</b>: <code>{first_name}</code>
142
- <b>🔅 Second Name</b>: <code>{last_name}</code>
143
  <b>🔍 Username</b>: {("@" + username) if username else "NA"}
144
- <b>✍️ Bio</b>: `{about}`
145
- <b>🧑‍💻 Support</b>: {is_support}\n"""
 
 
 
146
  if is_support:
147
  caption += f"<b>🥷 Support user type</b>: <code>{omp}</code>\n<b>💣 Gbanned</b>: {gban}\n"
148
  else:
149
  caption += f"<b>💣 Gbanned</b>: {gban}\n"
150
 
151
  if gban:
152
- caption += f"<b>☠️ Gban reason</b>: <code>{reason}</code>\n"
153
  caption += f"""
154
  <b>🌐 DC ID</b>: {dc_id}
155
  <b>✋ RESTRICTED</b>: {is_restricted}
156
  <b>✅ VERIFIED</b>: {is_verified}
157
  <b>❌ FAKE</b> : {is_fake}
158
- <b>⚠️ SCAM</b> : {is_scam}
159
  <b>🤖 BOT</b>: {is_bot}
160
  <b>👀 Last seen</b>: <code>{last_date}</code>
161
  """
@@ -258,6 +273,22 @@ async def info_func(c: Gojo, message: Message):
258
  LOGGER.error(e)
259
  LOGGER.error(format_exc())
260
  return await m.edit(str(e))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
262
  if not photo_id:
263
  await m.delete()
 
7
  from pyrogram.errors import EntityBoundsInvalid, MediaCaptionTooLong, RPCError
8
  from pyrogram.raw.functions.channels import GetFullChannel
9
  from pyrogram.raw.functions.users import GetFullUser
10
+ from pyrogram.raw.types import Channel, UserFull, users
11
  from pyrogram.types import Message
12
 
13
+ from Powers import BDB_URI, LOGGER, OWNER_ID
14
  from Powers.bot_class import Gojo
15
  from Powers.database.antispam_db import GBan
16
+ from Powers.database.approve_db import Approve
17
+ from Powers.plugins import bday_info
18
  from Powers.supports import get_support_staff
19
  from Powers.utils.custom_filters import command
20
  from Powers.utils.extract_user import extract_user
 
60
 
61
 
62
  async def user_info(c: Gojo, user, already=False):
63
+ user_all: users.UserFull = await c.invoke(
64
+ GetFullUser(
65
+ id=await c.resolve_peer(user)
66
+ )
67
+ )
68
+ user = await c.get_users(user)
69
+ full_user: UserFull = user_all.full_user
70
+ channel: Channel = user_all.chats
71
+ if user.is_deleted:
72
+ return "Deleted account", None
73
 
74
+
75
  gbanned, reason_gban = gban_db.get_gban(user.id)
76
  if gbanned:
77
  gban = True
 
81
  reason = "User is not gbanned"
82
 
83
  user_id = user.id
84
+ about = full_user.about
 
 
 
 
 
 
 
 
 
 
85
  SUPPORT_STAFF = get_support_staff()
86
  username = user.username
87
+ full_name = user.full_name
 
 
88
  dc_id = user.dc_id
89
  is_verified = user.is_verified
90
+ mention = user.mention
91
+ dob = False
92
+ if dob := full_user.birthday:
93
+ dob = datetime(int(dob.year), int(dob.month), int(dob.day)).strftime("%d %B %Y")
94
+ else:
95
+ if BDB_URI:
96
+ try:
97
+ if result := bday_info.find_one({"user_id": user}):
98
+ u_dob = datetime.strptime(result["dob"], "%d/%m/%Y")
99
+ day = u_dob.day
100
+ formatted = u_dob.strftime("%B %Y")
101
+ suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
102
+ dob = f"{day}{suffix} {formatted}"
103
+ except:
104
+ pass
105
+
106
  is_restricted = user.is_restricted
107
  photo_id = user.photo.big_file_id if user.photo else None
108
  is_support = user_id in SUPPORT_STAFF
 
150
  <b><i><u>⚡️ Extracted User info From Telegram ⚡️</b></i></u>
151
 
152
  <b>🆔 User ID</b>: <code>{user_id}</code>
 
153
  <b>🫵 Mention</b>: {mention}
154
+ <b>🗣 Full Name</b>: <code>{full_name}</code>
 
155
  <b>🔍 Username</b>: {("@" + username) if username else "NA"}
156
+ <b>✍️ Bio</b>: `{about}`\n"""
157
+ if dob:
158
+ caption += f"<b>🎂 Birthday<b>: {dob}\n<b>🧑‍💻 Support</b>: {is_support}\n"
159
+ else:
160
+ caption += f"<b>🧑‍💻 Support</b>: {is_support}\n"
161
  if is_support:
162
  caption += f"<b>🥷 Support user type</b>: <code>{omp}</code>\n<b>💣 Gbanned</b>: {gban}\n"
163
  else:
164
  caption += f"<b>💣 Gbanned</b>: {gban}\n"
165
 
166
  if gban:
167
+ caption += f"<b>☠️ Gban reason</b>: <code>{reason}</code>"
168
  caption += f"""
169
  <b>🌐 DC ID</b>: {dc_id}
170
  <b>✋ RESTRICTED</b>: {is_restricted}
171
  <b>✅ VERIFIED</b>: {is_verified}
172
  <b>❌ FAKE</b> : {is_fake}
173
+ <b>⚠️ SCAM</b> : {is_scam}
174
  <b>🤖 BOT</b>: {is_bot}
175
  <b>👀 Last seen</b>: <code>{last_date}</code>
176
  """
 
273
  LOGGER.error(e)
274
  LOGGER.error(format_exc())
275
  return await m.edit(str(e))
276
+
277
+
278
+ status = False
279
+ if m.chat.id != m.from_user.id:
280
+ try:
281
+ if status:= await m.chat.get_member(user):
282
+ status = str(status.status.value).capitalize()
283
+ except:
284
+ pass
285
+ if not status:
286
+ approved_users = Approve(m.chat.id).list_approved()
287
+ if user in approved_users:
288
+ status = "Approved"
289
+
290
+ if status:
291
+ info_caption += f"<b>👥 Status </b>: {status}"
292
 
293
  if not photo_id:
294
  await m.delete()
Powers/plugins/locks.py CHANGED
@@ -5,7 +5,8 @@ from traceback import format_exc
5
  from pyrogram import filters
6
  from pyrogram.enums import MessageEntityType as MET
7
  from pyrogram.enums import MessageServiceType as MST
8
- from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
 
9
  from pyrogram.types import CallbackQuery, ChatPermissions, Message
10
 
11
  from Powers import LOGGER
@@ -495,6 +496,8 @@ async def servicess(c: Gojo, m: Message):
495
  timee = datetime.now() + timedelta(minutes=5)
496
  await m.chat.ban_member(i.id, until_date=timee)
497
  sleep(1)
 
 
498
  except Exception as ef:
499
  LOGGER.error(ef)
500
  LOGGER.error(format_exc())
@@ -551,6 +554,23 @@ async def prevent_approved(m: Message):
551
  return
552
 
553
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
  __PLUGIN__ = "locks"
555
 
556
  __alt_name__ = ["grouplock", "lock", "grouplocks"]
@@ -573,22 +593,4 @@ Allows you to lock and unlock permission types in the chat.
573
  • /locktypes: Check available lock types!
574
 
575
  **Example:**
576
- `/lock media`: this locks all the media messages in the chat."""
577
-
578
-
579
- @Gojo.on_callback_query(filters.regex("^LOCK_TYPES"))
580
- async def lock_types_callback(c: Gojo, q: CallbackQuery):
581
- data = q.data
582
-
583
- if data == "LOCK_TYPES":
584
- kb = ikb([[("Back", "LOCK_TYPES_back")]])
585
- await q.edit_message_caption(
586
- l_t,
587
- reply_markup=kb
588
- )
589
- else:
590
- kb = ikb([[("Lock Types", "LOCK_TYPES")]])
591
- await q.edit_message_caption(
592
- __HELP__,
593
- reply_markup=kb
594
- )
 
5
  from pyrogram import filters
6
  from pyrogram.enums import MessageEntityType as MET
7
  from pyrogram.enums import MessageServiceType as MST
8
+ from pyrogram.errors import (ChatAdminRequired, ChatNotModified, RPCError,
9
+ UserAdminInvalid)
10
  from pyrogram.types import CallbackQuery, ChatPermissions, Message
11
 
12
  from Powers import LOGGER
 
496
  timee = datetime.now() + timedelta(minutes=5)
497
  await m.chat.ban_member(i.id, until_date=timee)
498
  sleep(1)
499
+ except UserAdminInvalid:
500
+ continue
501
  except Exception as ef:
502
  LOGGER.error(ef)
503
  LOGGER.error(format_exc())
 
554
  return
555
 
556
 
557
+ @Gojo.on_callback_query(filters.regex("^LOCK_TYPES"))
558
+ async def lock_types_callback(c: Gojo, q: CallbackQuery):
559
+ data = q.data
560
+
561
+ if data == "LOCK_TYPES":
562
+ kb = ikb([[("Back", "LOCK_TYPES_back")]])
563
+ await q.edit_message_caption(
564
+ l_t,
565
+ reply_markup=kb
566
+ )
567
+ else:
568
+ kb = ikb([[("Lock Types", "LOCK_TYPES")]])
569
+ await q.edit_message_caption(
570
+ __HELP__,
571
+ reply_markup=kb
572
+ )
573
+
574
  __PLUGIN__ = "locks"
575
 
576
  __alt_name__ = ["grouplock", "lock", "grouplocks"]
 
593
  • /locktypes: Check available lock types!
594
 
595
  **Example:**
596
+ `/lock media`: this locks all the media messages in the chat."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Powers/plugins/scheduled_jobs.py CHANGED
@@ -47,6 +47,9 @@ async def send_wishish(JJK: Client):
47
  suffix.get((agee % 10), "th")
48
  agee = f"{agee}{suf}"
49
  U = await JJK.get_chat_member(chat_id=j, user_id=i["user_id"])
 
 
 
50
  wish = choice(birthday_wish)
51
  if U.status in [ChatMemberStatus.MEMBER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
52
  xXx = await JJK.send_message(j, f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
 
47
  suffix.get((agee % 10), "th")
48
  agee = f"{agee}{suf}"
49
  U = await JJK.get_chat_member(chat_id=j, user_id=i["user_id"])
50
+ if U.user.is_deleted:
51
+ bday_info.delete_one({"user_id": i["user_id"]})
52
+ continue
53
  wish = choice(birthday_wish)
54
  if U.status in [ChatMemberStatus.MEMBER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
55
  xXx = await JJK.send_message(j, f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
Powers/utils/custom_filters.py CHANGED
@@ -42,7 +42,7 @@ def command(
42
  if m and not m.from_user and not m.chat.is_admin:
43
  return False
44
 
45
- if m.from_user.is_bot:
46
  return False
47
 
48
  if any([m.forward_from_chat, m.forward_from]):
 
42
  if m and not m.from_user and not m.chat.is_admin:
43
  return False
44
 
45
+ if m.from_user and m.from_user.is_bot:
46
  return False
47
 
48
  if any([m.forward_from_chat, m.forward_from]):
Powers/utils/web_scrapper.py CHANGED
@@ -209,8 +209,6 @@ class SCRAP_DATA:
209
 
210
  # else:
211
  # return {}
212
- curr_timeout = 20
213
- timeout = httpx.Timeout(curr_timeout)
214
 
215
  class INSTAGRAM:
216
  def __init__(self, url):
@@ -220,15 +218,13 @@ class INSTAGRAM:
220
  return bool((re.compile(r"^https?://(?:www\.)?instagram\.com/")).match(self.url))
221
 
222
  def get_media(self):
223
- global curr_timeout
224
  try:
225
  return httpx.post(
226
- f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}",
227
- timeout=timeout
228
  ).json()
229
  except httpx.ReadTimeout:
230
  try:
231
- curr_timeout += 10
232
  timeout = httpx.Timeout(curr_timeout)
233
  return httpx.post(
234
  f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}",
 
209
 
210
  # else:
211
  # return {}
 
 
212
 
213
  class INSTAGRAM:
214
  def __init__(self, url):
 
218
  return bool((re.compile(r"^https?://(?:www\.)?instagram\.com/")).match(self.url))
219
 
220
  def get_media(self):
 
221
  try:
222
  return httpx.post(
223
+ f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}"
 
224
  ).json()
225
  except httpx.ReadTimeout:
226
  try:
227
+ curr_timeout = 10
228
  timeout = httpx.Timeout(curr_timeout)
229
  return httpx.post(
230
  f"https://api.qewertyy.dev/downloaders/instagram?url={self.url}",