randydev commited on
Commit
45d8014
Β·
1 Parent(s): 436f6a3

fix update

Browse files
akn/AllDownloaderBot/admins.py ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyrogram import *
2
+ from pyrogram.types import *
3
+ from akn.utils.database import db
4
+
5
+ unmute_permissions = ChatPermissions(
6
+ can_send_messages=True,
7
+ can_send_media_messages=True,
8
+ can_send_polls=True,
9
+ can_change_info=False,
10
+ can_invite_users=True,
11
+ can_pin_messages=False,
12
+ )
13
+
14
+ async def extract_userid(message, text: str):
15
+ def is_int(text: str):
16
+ try:
17
+ int(text)
18
+ except ValueError:
19
+ return False
20
+ return True
21
+
22
+ text = text.strip()
23
+
24
+ if is_int(text):
25
+ return int(text)
26
+
27
+ entities = message.entities
28
+ app = message._client
29
+ if len(entities) < 2:
30
+ return (await app.get_users(text)).id
31
+ entity = entities[1]
32
+ if entity.type == "mention":
33
+ return (await app.get_users(text)).id
34
+ if entity.type == "text_mention":
35
+ return entity.user.id
36
+ return None
37
+
38
+
39
+ async def extract_user_and_reason(message, sender_chat=False):
40
+ args = message.text.strip().split()
41
+ text = message.text
42
+ user = None
43
+ reason = None
44
+ if message.reply_to_message:
45
+ reply = message.reply_to_message
46
+ if not reply.from_user:
47
+ if (
48
+ reply.sender_chat
49
+ and reply.sender_chat != message.chat.id
50
+ and sender_chat
51
+ ):
52
+ id_ = reply.sender_chat.id
53
+ else:
54
+ return None, None
55
+ else:
56
+ id_ = reply.from_user.id
57
+
58
+ if len(args) < 2:
59
+ reason = None
60
+ else:
61
+ reason = text.split(None, 1)[1]
62
+ return id_, reason
63
+
64
+ if len(args) == 2:
65
+ user = text.split(None, 1)[1]
66
+ return await extract_userid(message, user), None
67
+
68
+ if len(args) > 2:
69
+ user, reason = text.split(None, 2)[1:]
70
+ return await extract_userid(message, user), reason
71
+
72
+ return user, reason
73
+
74
+
75
+ async def extract_user(message):
76
+ return (await extract_user_and_reason(message))[0]
77
+
78
+
79
+ @Client.on_message(
80
+ ~filters.scheduled
81
+ & filters.command(["ban", "dban"])
82
+ & ~filters.forwarded
83
+ )
84
+ async def arz_ban_user(client: Client, message: Message):
85
+ user_id, reason = await extract_user_and_reason(message, sender_chat=True)
86
+ bot = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
87
+ if not bot.can_restrict_members:
88
+ return await message.edit_text("I don't have enough permissions")
89
+ if not user_id:
90
+ return await message.edit_text("I can't find that user.")
91
+ if user_id == client.me.id:
92
+ return await message.edit_text("I can't ban myself.")
93
+ if user_id == 1191668125:
94
+ return await message.edit_text("I can't ban my developer!")
95
+ try:
96
+ mention = (await client.get_users(user_id)).mention
97
+ except IndexError:
98
+ mention = (
99
+ message.reply_to_message.sender_chat.title
100
+ if message.reply_to_message
101
+ else "Anon"
102
+ )
103
+ msg = (
104
+ f"**Banned User:** <a href='tg://user?id={user_id}'>{mention}</a>\n"
105
+ f"**Banned By:** [{message.from_user.mention}](tg://user?id={message.from_user.id if message.from_user else 0})\n"
106
+ )
107
+ if message.command[0][0] == "d":
108
+ await message.reply_to_message.delete()
109
+ if reason:
110
+ msg += f"**Reason:** {reason}"
111
+ await message.chat.ban_member(user_id)
112
+ await message.reply_text(
113
+ msg,
114
+ reply_markup=InlineKeyboardMarkup(
115
+ [
116
+ [
117
+ InlineKeyboardButton(
118
+ "Unban", callback_data=f"arzunban_{user_id}"
119
+ )
120
+ ]
121
+ ]
122
+ )
123
+ )
124
+
125
+ @Client.on_message(
126
+ ~filters.scheduled
127
+ & filters.command(["unban"])
128
+ & ~filters.forwarded
129
+ )
130
+ async def arz_unban_user(client: Client, message: Message):
131
+ user_id, reason = await extract_user_and_reason(message, sender_chat=True)
132
+ if not user_id:
133
+ return await message.edit_text("I can't find that user.")
134
+ if user_id == client.me.id:
135
+ return await message.edit_text("I can't unban myself.")
136
+ if user_id == 1191668125:
137
+ return await message.edit_text("I can't unban my developer!")
138
+ try:
139
+ mention = (await client.get_users(user_id)).mention
140
+ except IndexError:
141
+ mention = (
142
+ message.reply_to_message.sender_chat.title
143
+ if message.reply_to_message
144
+ else "Anon"
145
+ )
146
+ msg = (
147
+ f"**Unbanned User:** <a href='tg://user?id={user_id}'>{mention}</a>\n"
148
+ f"**Unbanned By:** [{message.from_user.mention}](tg://user?id={message.from_user.id if message.from_user else 0})\n"
149
+ )
150
+ if reason:
151
+ msg += f"**Reason:** {reason}"
152
+ await message.chat.unban_member(user_id)
153
+ await message.reply_text(msg)
154
+
155
+ @Client.on_message(
156
+ ~filters.scheduled
157
+ & filters.command(["banme"])
158
+ & ~filters.forwarded
159
+ )
160
+ async def arz_ban_me(client: Client, message: Message):
161
+ user_id = message.from_user.id
162
+ reason = None
163
+ if not user_id:
164
+ return await message.edit_text("I can't find that user.")
165
+ if user_id == client.me.id:
166
+ return await message.edit_text("I can't ban myself.")
167
+ if user_id == 1191668125:
168
+ return await message.edit_text("I can't ban my developer!")
169
+ try:
170
+ mention = (await client.get_users(user_id)).mention
171
+ except IndexError:
172
+ mention = (
173
+ message.reply_to_message.sender_chat.title
174
+ if message.reply_to_message
175
+ else "Anon"
176
+ )
177
+ msg = (
178
+ f"**Banned User:** <a href='tg://user?id={user_id}'>{mention}</a>\n"
179
+ f"**Banned By:** [{message.from_user.mention}](tg://user?id={message.from_user.id if message.from_user else 0})\n"
180
+ )
181
+ if reason:
182
+ msg += f"**Reason:** {reason}"
183
+ await message.chat.ban_member(user_id)
184
+ await message.reply_text(
185
+ msg,
186
+ reply_markup=InlineKeyboardMarkup(
187
+ [
188
+ [
189
+ InlineKeyboardButton(
190
+ "Unban", callback_data=f"arzunban_{user_id}"
191
+ )
192
+ ]
193
+ ]
194
+ )
195
+ )
196
+
197
+ @Client.on_message(
198
+ ~filters.scheduled
199
+ & filters.command(["mute", "dmute"])
200
+ & ~filters.forwarded
201
+ )
202
+ async def arz_mute(client: Client, message: Message):
203
+ user_id, reason = await extract_user_and_reason(message, sender_chat=True)
204
+ bot = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
205
+ if not bot.can_restrict_members:
206
+ return await message.edit_text("I don't have enough permissions")
207
+ if not user_id:
208
+ return await message.edit_text("I can't find that user.")
209
+ if user_id == client.me.id:
210
+ return await message.edit_text("I can't mute myself.")
211
+ if user_id == 1191668125:
212
+ return await message.edit_text("I can't mute my developer!")
213
+ try:
214
+ mention = (await client.get_users(user_id)).mention
215
+ except IndexError:
216
+ mention = (
217
+ message.reply_to_message.sender_chat.title
218
+ if message.reply_to_message
219
+ else "Anon"
220
+ )
221
+ msg = (
222
+ f"**Muted User:** <a href='tg://user?id={user_id}'>{mention}</a>\n"
223
+ f"**Muted By:** [{message.from_user.mention}](tg://user?id={message.from_user.id if message.from_user else 0})\n"
224
+ )
225
+ if message.command[0][0] == "d":
226
+ await message.reply_to_message.delete()
227
+ if reason:
228
+ msg += f"**Reason:** {reason}"
229
+ await message.chat.restrict_member(user_id, ChatPermissions())
230
+ await message.reply_text(
231
+ msg,
232
+ reply_markup=InlineKeyboardMarkup(
233
+ [
234
+ [
235
+ InlineKeyboardButton(
236
+ "Unmute", callback_data=f"arzunmute_{user_id}"
237
+ )
238
+ ]
239
+ ]
240
+ )
241
+ )
akn/AllDownloaderBot/helpers/azrcallback.py CHANGED
@@ -1,5 +1,14 @@
1
  from pyrogram import filters, Client
2
- from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
 
 
 
 
 
 
 
 
 
3
 
4
  help_texts = {
5
  "ban": "**Ban Commands:**\n"
@@ -36,10 +45,40 @@ help_texts = {
36
  "/demote - Demote user\n"
37
  "/undemote - Undemote user\n"
38
  "/demoteme - Demote yourself\n"
39
- "/demoteall - Demote all admins"
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
- @Client.on_callback_query(filters.regex("^rhelp_(ban|mute|promote|demote|clean|lock)$"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  async def rxhelp_callback(client, callback):
44
  category = callback.data.split("_")[1]
45
  keyboard = InlineKeyboardMarkup([
@@ -51,7 +90,6 @@ async def rxhelp_callback(client, callback):
51
  reply_markup=keyboard
52
  )
53
 
54
-
55
  @Client.on_callback_query(filters.regex("^rhelps_back"))
56
  async def rhelp_back(client, callback):
57
  keyboard = InlineKeyboardMarkup([
@@ -66,9 +104,14 @@ async def rhelp_back(client, callback):
66
  [
67
  InlineKeyboardButton("🧹 Clean", callback_data="rhelp_clean"),
68
  InlineKeyboardButton("πŸ”’ Lock", callback_data="rhelp_lock")
 
 
 
 
 
 
69
  ]
70
  ])
71
-
72
  await callback.edit_message_text(
73
  "**Admin Help Menu**\nChoose a category:",
74
  reply_markup=keyboard
 
1
  from pyrogram import filters, Client
2
+ from pyrogram.types import *
3
+
4
+ unmute_permissions = ChatPermissions(
5
+ can_send_messages=True,
6
+ can_send_media_messages=True,
7
+ can_send_polls=True,
8
+ can_change_info=False,
9
+ can_invite_users=True,
10
+ can_pin_messages=False,
11
+ )
12
 
13
  help_texts = {
14
  "ban": "**Ban Commands:**\n"
 
45
  "/demote - Demote user\n"
46
  "/undemote - Undemote user\n"
47
  "/demoteme - Demote yourself\n"
48
+ "/demoteall - Demote all admins",
49
+
50
+ "downloader": "**Downloader Commands:**\n"
51
+ "/igdl - Instgram Downloader\n"
52
+ "/ytv - Youtube Downloader\n"
53
+ "/yta - Youtube Audio Downloader\n"
54
+ "/ytva - Youtube Video Audio Downloader\n"
55
+ "/fbdl - Facebook Downloader\n"
56
+ "/ttdl - Tiktok Downloader\n"
57
+ "/twtdl - Twitter Downloader\n"
58
+ "alldl - All Downloader\n"
59
  }
60
 
61
+ @Client.on_message(filters.regex("^arzunban_(\d+)"))
62
+ async def arzunban_callback(client, callback):
63
+ user_id = int(callback.data.split("_")[1])
64
+ chat_id = callback.chat.id
65
+ try:
66
+ await client.unban_chat_member(chat_id, user_id)
67
+ await callback.answer("User unbanned successfully!")
68
+ except Exception as e:
69
+ await callback.answer(f"Failed to unban user: {e}")
70
+
71
+ @Client.on_message(filters.regex("^arzunmute_(\d+)"))
72
+ async def arzunmute_callback(client, callback):
73
+ user_id = int(callback.data.split("_")[1])
74
+ chat_id = callback.chat.id
75
+ try:
76
+ await client.restrict_chat_member(chat_id, user_id, permissions=unmute_permissions)
77
+ await callback.answer("User unmuted successfully!")
78
+ except Exception as e:
79
+ await callback.answer(f"Failed to unmute user: {e}")
80
+
81
+ @Client.on_callback_query(filters.regex("^rhelp_(ban|mute|promote|demote|clean|lock|downloader$"))
82
  async def rxhelp_callback(client, callback):
83
  category = callback.data.split("_")[1]
84
  keyboard = InlineKeyboardMarkup([
 
90
  reply_markup=keyboard
91
  )
92
 
 
93
  @Client.on_callback_query(filters.regex("^rhelps_back"))
94
  async def rhelp_back(client, callback):
95
  keyboard = InlineKeyboardMarkup([
 
104
  [
105
  InlineKeyboardButton("🧹 Clean", callback_data="rhelp_clean"),
106
  InlineKeyboardButton("πŸ”’ Lock", callback_data="rhelp_lock")
107
+ ],
108
+ [
109
+ InlineKeyboardButton("πŸ“₯ Downloader", callback_data="rhelp_downloader"),
110
+ ],
111
+ [
112
+ InlineKeyboardButton("❌ Close", callback_data="cclose"),
113
  ]
114
  ])
 
115
  await callback.edit_message_text(
116
  "**Admin Help Menu**\nChoose a category:",
117
  reply_markup=keyboard
akn/AllDownloaderBot/main.py CHANGED
@@ -55,6 +55,17 @@ COMMAND = """
55
  - `/ytlink` – Search for YouTube videos.
56
  """
57
 
 
 
 
 
 
 
 
 
 
 
 
58
  @Client.on_callback_query(filters.regex("^cclose"))
59
  async def cb_cclose(client, query):
60
  await query.message.delete()
@@ -106,6 +117,38 @@ async def cb_author_command(client, query):
106
  reply_markup=keyboard_back
107
  )
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  @Client.on_message(
110
  ~filters.scheduled
111
  & filters.command(["start"])
@@ -115,6 +158,10 @@ async def cb_author_command(client, query):
115
  async def startbot(c, m):
116
  if await db.get_alldlbot_is_blacklist_user(c.me.id, m.from_user.id):
117
  return
 
 
 
 
118
  buttons = [
119
  [
120
  InlineKeyboardButton(
@@ -130,6 +177,10 @@ async def startbot(c, m):
130
  InlineKeyboardButton(
131
  text="Author Commands",
132
  callback_data='author_cmd'
 
 
 
 
133
  )
134
  ]
135
  ]
@@ -144,6 +195,10 @@ async def startbot(c, m):
144
  InlineKeyboardButton(
145
  text="Author Commands",
146
  callback_data='author_cmd'
 
 
 
 
147
  )
148
  ]
149
  ]
@@ -155,11 +210,11 @@ async def startbot(c, m):
155
  if is_pic and catbox_link:
156
  return await m.reply_photo(
157
  photo=catbox_link,
158
- caption=COMMAND,
159
  reply_markup=reply_markup
160
  )
161
  return await m.reply_text(
162
- text=COMMAND,
163
  disable_web_page_preview=True,
164
  reply_markup=reply_markup
165
  )
 
55
  - `/ytlink` – Search for YouTube videos.
56
  """
57
 
58
+ GROUP_TEXTS = """
59
+ Hi {name} iam a modular group management bot with some fun extras.
60
+
61
+ Resfresh Ping: {ping}
62
+
63
+ i can do Azrea Bot of things, and help u manage your group effortlessly!
64
+
65
+ All Command can be accessed by using: `/`
66
+ **Click on help to learn more!**
67
+ """
68
+
69
  @Client.on_callback_query(filters.regex("^cclose"))
70
  async def cb_cclose(client, query):
71
  await query.message.delete()
 
117
  reply_markup=keyboard_back
118
  )
119
 
120
+ @Client.on_callback_query(filters.regex("^zvhelp"))
121
+ async def varzhelp_callbackz(c, callback):
122
+ start = time.time()
123
+ await c.get_me()
124
+ end = time.time()
125
+ latency = (end - start) * 1000
126
+ keyboard = InlineKeyboardMarkup([
127
+ [
128
+ InlineKeyboardButton("🚫 Ban", callback_data="rhelp_ban"),
129
+ InlineKeyboardButton("πŸ”‡ Mute", callback_data="rhelp_mute")
130
+ ],
131
+ [
132
+ InlineKeyboardButton("πŸ‘‘ Promote", callback_data="rhelp_promote"),
133
+ InlineKeyboardButton("πŸ›‘οΈ Demote", callback_data="rhelp_demote")
134
+ ],
135
+ [
136
+ InlineKeyboardButton("🧹 Clean", callback_data="rhelp_clean"),
137
+ InlineKeyboardButton("πŸ”’ Lock", callback_data="rhelp_lock")
138
+ ],
139
+ [
140
+ InlineKeyboardButton("πŸ“₯ Downloader", callback_data="rhelp_downloader"),
141
+ ],
142
+ [
143
+ InlineKeyboardButton("βͺ Back", callback_data="zvback"),
144
+ InlineKeyboardButton("❌ Close", callback_data="cclose"),
145
+ ]
146
+ ])
147
+ await callback.edit_message_text(
148
+ GROUP_TEXTS.format(name=callback.from_user.mention, ping=latency),
149
+ reply_markup=keyboard
150
+ )
151
+
152
  @Client.on_message(
153
  ~filters.scheduled
154
  & filters.command(["start"])
 
158
  async def startbot(c, m):
159
  if await db.get_alldlbot_is_blacklist_user(c.me.id, m.from_user.id):
160
  return
161
+ start = time.time()
162
+ await c.get_me()
163
+ end = time.time()
164
+ latency = (end - start) * 1000
165
  buttons = [
166
  [
167
  InlineKeyboardButton(
 
177
  InlineKeyboardButton(
178
  text="Author Commands",
179
  callback_data='author_cmd'
180
+ ),
181
+ InlineKeyboardButton(
182
+ text="Help",
183
+ callback_data='zvhelp'
184
  )
185
  ]
186
  ]
 
195
  InlineKeyboardButton(
196
  text="Author Commands",
197
  callback_data='author_cmd'
198
+ ),
199
+ InlineKeyboardButton(
200
+ text="Help",
201
+ callback_data='zvhelp'
202
  )
203
  ]
204
  ]
 
210
  if is_pic and catbox_link:
211
  return await m.reply_photo(
212
  photo=catbox_link,
213
+ caption=GROUP_TEXTS.format(name=m.from_user.mention, ping=latency),
214
  reply_markup=reply_markup
215
  )
216
  return await m.reply_text(
217
+ text=GROUP_TEXTS.format(name=m.from_user.mention, ping=latency),
218
  disable_web_page_preview=True,
219
  reply_markup=reply_markup
220
  )