forked from sultansq/kiu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguages.py
87 lines (76 loc) · 2.47 KB
/
languages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from pykeyboard import InlineKeyboard
from pyrogram import filters
from pyrogram.types import InlineKeyboardButton, Message
from config import BANNED_USERS
from strings import get_command, get_string
from AnonX import app
from AnonX.utils.database import get_lang, set_lang
from AnonX.utils.decorators import (ActualAdminCB, language,
languageCB)
from strings.filters import command
# Languages Available
def lanuages_keyboard(_):
keyboard = InlineKeyboard(row_width=2)
keyboard.row(
InlineKeyboardButton(
text="🇦🇺 ᴇɴɢʟɪsʜ 🇦🇺",
callback_data=f"languages:en",
),
)
keyboard.row(
InlineKeyboardButton(
text=_["CLOSE_BUTTON"], callback_data=f"close"
),
)
return keyboard
LANGUAGE_COMMAND = get_command("LANGUAGE_COMMAND")
@app.on_message(
filters.command(LANGUAGE_COMMAND)
& filters.group
& ~filters.edited
& ~BANNED_USERS
)
@language
async def langs_command(client, message: Message, _):
keyboard = lanuages_keyboard(_)
await message.reply_text(
_["setting_1"].format(message.chat.title, message.chat.id),
reply_markup=keyboard,
)
@app.on_callback_query(filters.regex("LG") & ~BANNED_USERS)
@languageCB
async def lanuagecb(client, CallbackQuery, _):
try:
await CallbackQuery.answer()
except:
pass
keyboard = lanuages_keyboard(_)
return await CallbackQuery.edit_message_reply_markup(
reply_markup=keyboard
)
@app.on_callback_query(
filters.regex(r"languages:(.*?)") & ~BANNED_USERS
)
@ActualAdminCB
async def language_markup(client, CallbackQuery, _):
langauge = (CallbackQuery.data).split(":")[1]
old = await get_lang(CallbackQuery.message.chat.id)
if str(old) == str(langauge):
return await CallbackQuery.answer(
"بالفعل انت تستخدم هذه اللغة في هذه الدردشه.", show_alert=True
)
try:
_ = get_string(langauge)
await CallbackQuery.answer(
"تم تغيير اللغة بنجاح.", show_alert=True
)
except:
return await CallbackQuery.answer(
"فشل تغيير اللغة هذه اللغة تحت الصيانه.",
show_alert=True,
)
await set_lang(CallbackQuery.message.chat.id, langauge)
keyboard = lanuages_keyboard(_)
return await CallbackQuery.edit_message_reply_markup(
reply_markup=keyboard
)