fix update
Browse files- akn/AllDownloaderBot/__init__.py +26 -0
- akn/AllDownloaderBot/admins.py +44 -0
- akn/AllDownloaderBot/helpers/azrcallback.py +12 -0
- akn/AllDownloaderBot/langs/ en.yml +20 -0
- akn/AllDownloaderBot/langues.py +12 -0
- akn/AllDownloaderBot/main.py +14 -2
- requirements.txt +1 -0
akn/AllDownloaderBot/__init__.py
CHANGED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import yaml
|
2 |
+
from pathlib import Path
|
3 |
+
|
4 |
+
class Translator:
|
5 |
+
def __init__(self):
|
6 |
+
self.languages = {}
|
7 |
+
self.load_languages()
|
8 |
+
|
9 |
+
def load_languages(self):
|
10 |
+
lang_dir = Path("langs")
|
11 |
+
for lang_file in lang_dir.glob("*.yml"):
|
12 |
+
with open(lang_file, 'r', encoding='utf-8') as f:
|
13 |
+
lang_code = lang_file.stem
|
14 |
+
self.languages[lang_code] = yaml.safe_load(f)
|
15 |
+
|
16 |
+
def get(self, key: str, lang: str = "en", **kwargs) -> str:
|
17 |
+
try:
|
18 |
+
parts = key.split('.')
|
19 |
+
value = self.languages[lang]
|
20 |
+
for part in parts:
|
21 |
+
value = value[part]
|
22 |
+
return value.format(**kwargs)
|
23 |
+
except KeyError:
|
24 |
+
return self.get(key, "en", **kwargs)
|
25 |
+
|
26 |
+
transdev = Translator()
|
akn/AllDownloaderBot/admins.py
CHANGED
@@ -286,6 +286,50 @@ async def arz_unmute(client: Client, message: Message):
|
|
286 |
)
|
287 |
await message.reply_text(msg)
|
288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
@Client.on_message(filters.incoming & filters.group, group=-1)
|
290 |
async def check_user_mute(client: Client, message: Message):
|
291 |
if message.from_user and message.from_user.is_bot:
|
|
|
286 |
)
|
287 |
await message.reply_text(msg)
|
288 |
|
289 |
+
@Client.on_message(
|
290 |
+
~filters.scheduled
|
291 |
+
& filters.command(["muteall"])
|
292 |
+
& ~filters.forwarded
|
293 |
+
)
|
294 |
+
async def arz_mute_all(client: Client, message: Message):
|
295 |
+
bot = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
296 |
+
if not bot.can_restrict_members:
|
297 |
+
return await message.edit_text("I don't have enough permissions")
|
298 |
+
if message.chat.type == ChatType.PRIVATE:
|
299 |
+
return await message.edit_text("This command is not available in private chats.")
|
300 |
+
if message.chat.type == ChatType.SUPERGROUP:
|
301 |
+
try:
|
302 |
+
await client.restrict_chat_member(
|
303 |
+
message.chat.id,
|
304 |
+
client.me.id,
|
305 |
+
permissions=ChatPermissions(),
|
306 |
+
)
|
307 |
+
await message.reply_text("All members muted successfully.")
|
308 |
+
except Exception as e:
|
309 |
+
await message.reply_text(f"Failed to mute all members: {e}")
|
310 |
+
|
311 |
+
@Client.on_message(
|
312 |
+
~filters.scheduled
|
313 |
+
& filters.command(["unmuteall"])
|
314 |
+
& ~filters.forwarded
|
315 |
+
)
|
316 |
+
async def arz_unmute_all(client: Client, message: Message):
|
317 |
+
bot = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
318 |
+
if not bot.can_restrict_members:
|
319 |
+
return await message.edit_text("I don't have enough permissions")
|
320 |
+
if message.chat.type == ChatType.PRIVATE:
|
321 |
+
return await message.edit_text("This command is not available in private chats.")
|
322 |
+
if message.chat.type == ChatType.SUPERGROUP:
|
323 |
+
try:
|
324 |
+
await client.restrict_chat_member(
|
325 |
+
message.chat.id,
|
326 |
+
client.me.id,
|
327 |
+
permissions=unmute_permissions,
|
328 |
+
)
|
329 |
+
await message.reply_text("All members unmuted successfully.")
|
330 |
+
except Exception as e:
|
331 |
+
await message.reply_text(f"Failed to unmute all members: {e}")
|
332 |
+
|
333 |
@Client.on_message(filters.incoming & filters.group, group=-1)
|
334 |
async def check_user_mute(client: Client, message: Message):
|
335 |
if message.from_user and message.from_user.is_bot:
|
akn/AllDownloaderBot/helpers/azrcallback.py
CHANGED
@@ -1,6 +1,17 @@
|
|
1 |
import time
|
2 |
from pyrogram import filters, Client
|
3 |
from pyrogram.types import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
unmute_permissions = ChatPermissions(
|
6 |
can_send_messages=True,
|
@@ -33,6 +44,7 @@ help_texts = {
|
|
33 |
"/mute - Mute a user\n"
|
34 |
"/unmute - Unmute user\n"
|
35 |
"/tmute - Temporary mute\n"
|
|
|
36 |
"/muteme - Mute yourself",
|
37 |
|
38 |
"promote": "**Promotion Commands:**\n"
|
|
|
1 |
import time
|
2 |
from pyrogram import filters, Client
|
3 |
from pyrogram.types import *
|
4 |
+
from akn.utils.database import db
|
5 |
+
|
6 |
+
@Client.on_callback_query(filters.regex("^arzlang_"))
|
7 |
+
async def arzset_language(_, callback):
|
8 |
+
lang_code = callback.data.split("_")[1]
|
9 |
+
await db.alldl_bot.update_one(
|
10 |
+
{"user_id": callback.from_user.id},
|
11 |
+
{"$set": {"language": lang_code}},
|
12 |
+
upsert=True
|
13 |
+
)
|
14 |
+
await callback.answer(f"Language set to {lang_code.upper()}!")
|
15 |
|
16 |
unmute_permissions = ChatPermissions(
|
17 |
can_send_messages=True,
|
|
|
44 |
"/mute - Mute a user\n"
|
45 |
"/unmute - Unmute user\n"
|
46 |
"/tmute - Temporary mute\n"
|
47 |
+
"/muteall - Mute all users\n"
|
48 |
"/muteme - Mute yourself",
|
49 |
|
50 |
"promote": "**Promotion Commands:**\n"
|
akn/AllDownloaderBot/langs/ en.yml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
buttons:
|
2 |
+
start: "🚀 Start"
|
3 |
+
help: "❓ Help"
|
4 |
+
settings: "⚙ Settings"
|
5 |
+
|
6 |
+
messages:
|
7 |
+
welcome: |
|
8 |
+
Hi {name} i am a modular group management bot with some fun extras.
|
9 |
+
|
10 |
+
Resfresh Ping: `{ping}`
|
11 |
+
|
12 |
+
i can do Azrea Bot of things, and help u manage your group effortlessly!
|
13 |
+
|
14 |
+
All Command can be accessed by using: `/`
|
15 |
+
**Click on help to learn more!**
|
16 |
+
|
17 |
+
help: |
|
18 |
+
Available commands:
|
19 |
+
- /start - Start bot
|
20 |
+
- /help - Show help
|
akn/AllDownloaderBot/langues.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pyrogram import *
|
2 |
+
from pyrogram.types import *
|
3 |
+
|
4 |
+
@Client.on_message(filters.command("setlang"))
|
5 |
+
async def arzlanguage_menu(client, message):
|
6 |
+
buttons = InlineKeyboardMarkup([
|
7 |
+
[InlineKeyboardButton("🇺🇸 English", callback_data="arzlang_en")],
|
8 |
+
[InlineKeyboardButton("🇪🇸 Español", callback_data="arzlang_es")],
|
9 |
+
[InlineKeyboardButton("🇫🇷 Français", callback_data="arzlang_fr")]
|
10 |
+
])
|
11 |
+
|
12 |
+
await message.reply("Select your language:", reply_markup=buttons)
|
akn/AllDownloaderBot/main.py
CHANGED
@@ -23,6 +23,7 @@ from yt_dlp import YoutubeDL
|
|
23 |
from akn.utils.database import db
|
24 |
from akn.utils.driver import YoutubeDriver
|
25 |
from akn.utils.formatter import secs_to_mins
|
|
|
26 |
|
27 |
import akenoai as js
|
28 |
|
@@ -210,17 +211,28 @@ async def startbot(c, m):
|
|
210 |
]
|
211 |
user_now = await db.get_alldlbot_by_no_button(c.me.id)
|
212 |
reply_markup = InlineKeyboardMarkup(buttons_start_in_group) if user_now else InlineKeyboardMarkup(buttons)
|
|
|
|
|
|
|
|
|
|
|
213 |
try:
|
214 |
await db.update_alldlbot_broadcast(c.me.id, m.from_user.id, "add")
|
215 |
is_pic, catbox_link = await db.get_pic_in_allbot(c.me.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
if is_pic and catbox_link:
|
217 |
return await m.reply_photo(
|
218 |
photo=catbox_link,
|
219 |
-
caption=
|
220 |
reply_markup=reply_markup
|
221 |
)
|
222 |
return await m.reply_text(
|
223 |
-
text=
|
224 |
disable_web_page_preview=True,
|
225 |
reply_markup=reply_markup
|
226 |
)
|
|
|
23 |
from akn.utils.database import db
|
24 |
from akn.utils.driver import YoutubeDriver
|
25 |
from akn.utils.formatter import secs_to_mins
|
26 |
+
from akn.AllDownloaderBot import transdev
|
27 |
|
28 |
import akenoai as js
|
29 |
|
|
|
211 |
]
|
212 |
user_now = await db.get_alldlbot_by_no_button(c.me.id)
|
213 |
reply_markup = InlineKeyboardMarkup(buttons_start_in_group) if user_now else InlineKeyboardMarkup(buttons)
|
214 |
+
get_lang_user = await db.alldl_bot.find_one({"user_id": m.from_user.id})
|
215 |
+
lang = None
|
216 |
+
if not get_lang_user:
|
217 |
+
lang = "en"
|
218 |
+
lang = get_lang_user.get("language", "en")
|
219 |
try:
|
220 |
await db.update_alldlbot_broadcast(c.me.id, m.from_user.id, "add")
|
221 |
is_pic, catbox_link = await db.get_pic_in_allbot(c.me.id)
|
222 |
+
text_str = transdev.get(
|
223 |
+
"messages.welcome",
|
224 |
+
lang=lang,
|
225 |
+
name=m.from_user.first_name,
|
226 |
+
ping=f"{latency:.2f}ms",
|
227 |
+
)
|
228 |
if is_pic and catbox_link:
|
229 |
return await m.reply_photo(
|
230 |
photo=catbox_link,
|
231 |
+
caption=text_str,
|
232 |
reply_markup=reply_markup
|
233 |
)
|
234 |
return await m.reply_text(
|
235 |
+
text=text_str,
|
236 |
disable_web_page_preview=True,
|
237 |
reply_markup=reply_markup
|
238 |
)
|
requirements.txt
CHANGED
@@ -88,6 +88,7 @@ git+https://github.com/KurimuzonAkuma/pyrogram.git@refs/tags/v2.1.30#egg=pyrogra
|
|
88 |
git+https://github.com/johnwmillr/LyricsGenius
|
89 |
git+https://github.com/urllib3/urllib3
|
90 |
yt-dlp==2025.03.31
|
|
|
91 |
Markdown
|
92 |
PyJWT
|
93 |
python-box
|
|
|
88 |
git+https://github.com/johnwmillr/LyricsGenius
|
89 |
git+https://github.com/urllib3/urllib3
|
90 |
yt-dlp==2025.03.31
|
91 |
+
PyYAML
|
92 |
Markdown
|
93 |
PyJWT
|
94 |
python-box
|