From 03ac4ed7aa7158bc3621df4697c1e9c86bc741cc Mon Sep 17 00:00:00 2001 From: Sokhibjon Orzikulov Date: Fri, 17 Nov 2023 03:34:26 +0500 Subject: [PATCH] remove inline to completed --- delta/inline.ts | 101 ------------------------------------------------ delta/mod.ts | 2 - 2 files changed, 103 deletions(-) delete mode 100644 delta/inline.ts diff --git a/delta/inline.ts b/delta/inline.ts deleted file mode 100644 index b350d04..0000000 --- a/delta/inline.ts +++ /dev/null @@ -1,101 +0,0 @@ -// deno-lint-ignore-file no-explicit-any -import { api, Composer, Context, InlineKeyboard } from "../deps.ts"; -import encoder from "../utils/encoder.ts"; - -const composer = new Composer(); - -composer.inlineQuery(/(.*)/ig, async (ctx: Context): Promise => { - if (ctx.inlineQuery?.query) { - const request = await api.search(ctx.inlineQuery?.query, 50); - - if (request.meta.total === 0) { - return await ctx.answerInlineQuery([{ - type: "article", - id: "404", - title: "Xatolik yuz berdi!", - description: `Ushbu ${ctx.inlineQuery?.query} ga oid natija topilmadi!`, - reply_markup: new InlineKeyboard().switchInlineCurrent( - "Qayta urinib ko'ramizmi?", - "rand", - ), - input_message_content: { - message_text: - `"${ctx.inlineQuery?.query}" ga oid natija mavjud emas!` + - `\n` + - `Iltimos, boshqattan ushbu qidirmoqchi bo'lgan paketingiz yozib qidirib ko'ring!`, - parse_mode: "HTML", - disable_web_page_preview: true, - }, - }]); - } - - return await ctx.answerInlineQuery( - request.crates.map((item) => ({ - type: "article", - id: crypto.randomUUID(), - title: item.name, - url: `https://crates.io/crates/${item.id}`, - description: item.description, - reply_markup: (() => { - const keyboard = new InlineKeyboard(); - keyboard.url(`Crate`, `https://crates.io/crates/${item.name}`); - if (item.homepage) keyboard.url(`Asosiy`, item.homepage).row(); - if (item.documentation) { - keyboard.url(`Dokumentatsiya`, item.documentation).row(); - } - if (item.repository) keyboard.url(`Repozitoriya`, item.repository); - return keyboard; - })(), - input_message_content: { - message_text: `🦀 Rust Telegram Cratelari 🦀\n\n` + - `📦 Nomi: ${item.name}` + - `\n` + - `🚨 Oxirgi versiya: ${item.newest_version} \n` + - `🎚 Yuklab olingan: yaqin orada: ${item.recent_downloads} | hammasi: ${item.downloads} \n` + - `⌚️ Yaratilgan: ${ - new Date(item.created_at).toLocaleString("uz") - } \n` + - `📡 Yangilangan: ${ - new Date(item.updated_at).toLocaleString("uz") - } \n` + - `📰 Ma'lumot: ${ - (encoder(item.description)).substring(0, 100) - }${item.description.length > 100 ? "..." : ""} \n\n` + - `🔌 Cargo.toml fayliga qo'shib qo'ying: \n` + - `[dependencies]\n${item.name} = "${item.max_stable_version}"`, - parse_mode: "HTML", - disable_web_page_preview: true, - }, - })), - { cache_time: 1 }, // { cache_time: 24 * 3600 }, - ); - } - - if (!ctx.inlineQuery?.query) { - return await ctx.answerInlineQuery([{ - type: "article", - id: "101", - title: "Qidirishni boshlang!", - description: "Qidirmoqchi bo'lgan paketingiz nomini yozing!", - reply_markup: new InlineKeyboard().switchInlineCurrent( - "Qayta urinib ko'ramizmi?", - "rand", - ), - input_message_content: { - message_text: `Salom foydalanuvchi!` + - `\n` + - `Siz inline rejim ishga tushurdingiz. Ushbu qulaylik yordamida siz crates.io ` + - `Rust dasturlash tili paketlar registridan web sahifani ishlatmasdan turib ` + - `telegram o'zida kerakli paketlarni qidirishingiz mumkin! Ushbu qulaylik ` + - `yozish uchun o'zimizning API SDK ishlatildi` + - `Qidirishni boshlash uchun: ` + - `\n` + - `@rustaceanbot <nomi>`, - parse_mode: "HTML", - disable_web_page_preview: true, - }, - }]); - } -}); - -export default composer; diff --git a/delta/mod.ts b/delta/mod.ts index c9c1b78..a15b3b3 100644 --- a/delta/mod.ts +++ b/delta/mod.ts @@ -1,4 +1,3 @@ -import inline from "./inline.ts"; import which from "./which.ts"; import { Bot } from "../deps.ts"; import channel from "./channel.ts"; @@ -10,7 +9,6 @@ import version from "./version.ts"; export default async (bot: Bot) => { await bot - .use(inline) .use(which) .use(groups) .use(useful)