mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-05 03:34:51 +00:00
dd
This commit is contained in:
parent
8b26d42d9a
commit
e36c8f7948
1 changed files with 13 additions and 9 deletions
|
|
@ -3,9 +3,12 @@ import asyncio
|
||||||
from pykeyboard import InlineKeyboard
|
from pykeyboard import InlineKeyboard
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from misskaty.helper.http import http
|
from misskaty.helper.http import http
|
||||||
|
from misskaty.helper.tools import get_random_string
|
||||||
from misskaty import app
|
from misskaty import app
|
||||||
from misskaty.vars import COMMAND_HANDLER
|
from misskaty.vars import COMMAND_HANDLER
|
||||||
|
|
||||||
|
LK_DICT = {}
|
||||||
|
|
||||||
def split_arr(arr, size):
|
def split_arr(arr, size):
|
||||||
arrs = []
|
arrs = []
|
||||||
while len(arr) > size:
|
while len(arr) > size:
|
||||||
|
|
@ -16,9 +19,7 @@ def split_arr(arr, size):
|
||||||
return arrs
|
return arrs
|
||||||
|
|
||||||
async def getDatalk21(chat_id, message_id, kueri, CurrentPage):
|
async def getDatalk21(chat_id, message_id, kueri, CurrentPage):
|
||||||
lk21json = (await http.get(
|
lk21json = (await http.get(f'https://yasirapi.eu.org/lk21?q={kueri}')).json()
|
||||||
f'https://yasirapi.eu.org/lk21?q={kueri}')).json()
|
|
||||||
res = split_arr(lk21json["result"], 6)
|
|
||||||
if not lk21json.get("result"):
|
if not lk21json.get("result"):
|
||||||
return await app.send_message(
|
return await app.send_message(
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
|
|
@ -28,16 +29,17 @@ async def getDatalk21(chat_id, message_id, kueri, CurrentPage):
|
||||||
"Results: Sorry could not find any matching results!"
|
"Results: Sorry could not find any matching results!"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
LK_DICT[message_id] = [split_arr(lk21json["result"], 6), kueri]
|
||||||
try:
|
try:
|
||||||
index = int(CurrentPage - 1)
|
index = int(CurrentPage - 1)
|
||||||
PageLen = len(res)
|
PageLen = len(LK_DICT[message_id][0])
|
||||||
|
|
||||||
msgs = ""
|
msgs = ""
|
||||||
for c, i in enumerate(res[index], start=1):
|
for c, i in enumerate(LK_DICT[message_id][0][index], start=1):
|
||||||
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n"
|
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n"
|
||||||
|
|
||||||
lkResult = (
|
lkResult = (
|
||||||
f"**Tes of {kueri}**\n"
|
f"**Hasil pencarian dg kata kunci {kueri}**\n"
|
||||||
f"{msgs}\n\n"
|
f"{msgs}\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -78,7 +80,7 @@ async def lk21tes(client, message):
|
||||||
lkres, PageLen = await getDatalk21(chat_id, message_id, kueri, CurrentPage)
|
lkres, PageLen = await getDatalk21(chat_id, message_id, kueri, CurrentPage)
|
||||||
|
|
||||||
keyboard = InlineKeyboard()
|
keyboard = InlineKeyboard()
|
||||||
keyboard.paginate(PageLen, CurrentPage, 'pagination_lk21#{number}' + f'#{kueri}')
|
keyboard.paginate(PageLen, CurrentPage, 'pagination_lk21#{number}' + f'{message.from_user.id}')
|
||||||
await message.reply(
|
await message.reply(
|
||||||
text=f"{lkres}",
|
text=f"{lkres}",
|
||||||
reply_markup=keyboard
|
reply_markup=keyboard
|
||||||
|
|
@ -86,10 +88,12 @@ async def lk21tes(client, message):
|
||||||
|
|
||||||
@app.on_callback_query(filters.create(lambda _, __, query: 'pagination_lk21#' in query.data))
|
@app.on_callback_query(filters.create(lambda _, __, query: 'pagination_lk21#' in query.data))
|
||||||
async def lk21page_callback(client, callback_query):
|
async def lk21page_callback(client, callback_query):
|
||||||
|
if callback_query.from_user.id != callback_query.data.split('#')[3]:
|
||||||
|
return await callback_query.answer("Not yours..", True)
|
||||||
message_id = callback_query.message.id
|
message_id = callback_query.message.id
|
||||||
chat_id = callback_query.message.chat.id
|
chat_id = callback_query.message.chat.id
|
||||||
CurrentPage = int(callback_query.data.split('#')[1])
|
CurrentPage = int(callback_query.data.split('#')[1])
|
||||||
kueri = callback_query.data.split('#')[2]
|
kueri = LK_DICT[message_id][1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lkres, PageLen = await getDatalk21(chat_id, message_id, kueri, CurrentPage)
|
lkres, PageLen = await getDatalk21(chat_id, message_id, kueri, CurrentPage)
|
||||||
|
|
@ -97,7 +101,7 @@ async def lk21page_callback(client, callback_query):
|
||||||
return
|
return
|
||||||
|
|
||||||
keyboard = InlineKeyboard()
|
keyboard = InlineKeyboard()
|
||||||
keyboard.paginate(PageLen, CurrentPage, 'pagination_lk21#{number}' + f'#{kueri}')
|
keyboard.paginate(PageLen, CurrentPage, 'pagination_lk21#{number}' + f'#{callback_query.from_user.id}')
|
||||||
await app.edit_message_text(
|
await app.edit_message_text(
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue