Skip to content

Commit

Permalink
Added Language Feature
Browse files Browse the repository at this point in the history
Added Language feature. Now you can select all your individual languages according to your preference.
  • Loading branch information
Joelkb committed May 12, 2023
1 parent 6a9c393 commit d27bf42
Showing 1 changed file with 172 additions and 2 deletions.
174 changes: 172 additions & 2 deletions plugins/pm_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ async def next_page(bot, query):
],
)
btn.insert(0, [
InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Fɪʟᴇs Tᴏ PM !", callback_data=f"send_fall#files#{offset}")
InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Fɪʟᴇs Tᴏ PM !", callback_data=f"send_fall#files#{offset}"),
InlineKeyboardButton("! Lᴀɴɢᴜᴀɢᴇs !", callback_data=f"select_lang#{req}")
])
btn.insert(0, [
InlineKeyboardButton("⚡ Cʜᴇᴄᴋ Bᴏᴛ PM ⚡", url=f"https://t.me/{temp.U_NAME}")
Expand All @@ -253,6 +254,174 @@ async def next_page(bot, query):
pass
await query.answer()

@Client.on_callback_query(filters.regex(r"^lang"))
async def language_check(bot, query):
_, userid, language = query.data.split("#")
if int(userid) not in [query.from_user.id, 0]:
return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True)
if language == "unknown":
return await query.answer("Sᴇʟᴇᴄᴛ ᴀɴʏ ʟᴀɴɢᴜᴀɢᴇ ғʀᴏᴍ ᴛʜᴇ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴs !", show_alert=True)
movie = temp.KEYWORD.get(query.from_user.id)
if not movie:
return await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name), show_alert=True)
if language != "home":
movie = f"{movie} {language}"
files, offset, total_results = await get_search_results(query.message.chat.id, movie, offset=0, filter=True)
if files:
settings = await get_settings(query.message.chat.id)
temp.SEND_ALL_TEMP[query.from_user.id] = files
if 'is_shortlink' in settings.keys():
ENABLE_SHORTLINK = settings['is_shortlink']
else:
await save_group_settings(query.message.chat.id, 'is_shortlink', False)
ENABLE_SHORTLINK = False
pre = 'filep' if settings['file_secure'] else 'file'
if ENABLE_SHORTLINK and settings['button']:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {file.file_name}", url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}")
),
]
for file in files
]
elif ENABLE_SHORTLINK and not settings['button']:
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}",
url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}")
),
InlineKeyboardButton(
text=f"{get_size(file.file_size)}",
url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}")
),
]
for file in files
]
elif settings['button'] and not ENABLE_SHORTLINK:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'{pre}#{file.file_id}'
),
]
for file in files
]
else:
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}",
callback_data=f'{pre}#{file.file_id}',
),
InlineKeyboardButton(
text=f"{get_size(file.file_size)}",
callback_data=f'{pre}#{file.file_id}',
),
]
for file in files
]

try:
if settings['auto_delete']:
btn.insert(0,
[
InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'),
InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'),
InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo')
]
)

else:
btn.insert(0,
[
InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'),
InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo')
]
)

except KeyError:
await save_group_settings(query.message.chat.id, 'auto_delete', True)
btn.insert(0,
[
InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'),
InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'),
InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo')
]
)

btn.insert(0, [
InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Fɪʟᴇs Tᴏ PM !", callback_data=f"send_fall#{pre}#{0}"),
InlineKeyboardButton("! Lᴀɴɢᴜᴀɢᴇs !", callback_data=f"select_lang#{userid}")
])

btn.insert(0, [
InlineKeyboardButton("⚡ Cʜᴇᴄᴋ Bᴏᴛ PM ⚡", url=f"https://t.me/{temp.U_NAME}")
])

if offset != "":
key = f"{query.message.chat.id}-{query.message.id}"
BUTTONS[key] = movie
req = userid
try:
if settings['max_btn']:
btn.append(
[InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")]
)

else:
btn.append(
[InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/int(MAX_B_TN))}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")]
)
except KeyError:
await save_group_settings(query.message.chat.id, 'max_btn', True)
btn.append(
[InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")]
)
else:
btn.append(
[InlineKeyboardButton(text="𝐍𝐎 𝐌𝐎𝐑𝐄 𝐏𝐀𝐆𝐄𝐒 𝐀𝐕𝐀𝐈𝐋𝐀𝐁𝐋𝐄",callback_data="pages")]
)
try:
await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(btn)
)
except MessageNotModified:
pass
await query.answer()
else:
return await query.answer(f"Sᴏʀʀʏ, Nᴏ ғɪʟᴇs ғᴏᴜɴᴅ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {movie}.", show_alert=True)

@Client.on_callback_query(filters.regex(r"^select_lang"))
async def select_language(bot, query):
_, userid = query.data.split("#")
if int(userid) not in [query.from_user.id, 0]:
return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True)
btn = [[
InlineKeyboardButton("Sᴇʟᴇᴄᴛ Yᴏᴜʀ Dᴇꜱɪʀᴇᴅ Lᴀɴɢᴜᴀɢᴇ ↓", callback_data=f"lang#{userid}#unknown")
],[
InlineKeyboardButton("Eɴɢʟɪꜱʜ", callback_data=f"lang#{userid}#eng"),
InlineKeyboardButton("Tᴀᴍɪʟ", callback_data=f"lang#{userid}#tam"),
InlineKeyboardButton("Hɪɴᴅɪ", callback_data=f"lang#{userid}#hin")
],[
InlineKeyboardButton("Kᴀɴɴᴀᴅᴀ", callback_data=f"lang#{userid}#kan"),
InlineKeyboardButton("Tᴇʟᴜɢᴜ", callback_data=f"lang#{userid}#tel")
],[
InlineKeyboardButton("Mᴀʟᴀʏᴀʟᴀᴍ", callback_data=f"lang#{userid}#mal")
],[
InlineKeyboardButton("Mᴜʟᴛɪ Aᴜᴅɪᴏ", callback_data=f"lang#{userid}#multi"),
InlineKeyboardButton("Dᴜᴀʟ Aᴜᴅɪᴏ", callback_data=f"lang#{userid}#dual")
],[
InlineKeyboardButton("Gᴏ Bᴀᴄᴋ", callback_data=f"lang#{userid}#home")
]]
try:
await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(btn)
)
except MessageNotModified:
pass
await query.answer()

@Client.on_callback_query(filters.regex(r"^spol"))
async def advantage_spoll_choker(bot, query):
Expand Down Expand Up @@ -1439,7 +1608,8 @@ async def auto_filter(client, msg, spoll=False):
)

btn.insert(0, [
InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Fɪʟᴇs Tᴏ PM !", callback_data=f"send_fall#{pre}#{0}")
InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Fɪʟᴇs Tᴏ PM !", callback_data=f"send_fall#{pre}#{0}"),
InlineKeyboardButton("! Lᴀɴɢᴜᴀɢᴇs !", callback_data=f"select_lang#{message.from_user.id}")
])

btn.insert(0, [
Expand Down

0 comments on commit d27bf42

Please sign in to comment.