diff --git a/delta/mod.ts b/delta/mod.ts index 88ae65f..793a25e 100644 --- a/delta/mod.ts +++ b/delta/mod.ts @@ -1,9 +1,7 @@ import { Bot } from "../deps.ts"; -import trigger from "./trigger.ts"; import useful from "./useful.ts"; export default async (bot: Bot) => { await bot .use(useful) - .use(trigger) }; diff --git a/src/functions/about.rs b/src/functions/about.rs index b69f96d..67df6e4 100644 --- a/src/functions/about.rs +++ b/src/functions/about.rs @@ -11,11 +11,6 @@ static TEXT: &str = r#" Bizning botimiz aktiv tarzda shakllantirib boriladi. Buning ustida esa bir necha avtor va dasturchilar turadi, ushbu havolalar orqali bizning sinovchilarimizdan biriga aylaning va biz bilan botimiz, hamda guruhimiz ishlatish qulayligini oshiring. "#; -pub fn keyboard() -> InlineKeyboardMarkup { - let mut keyboard = Keyboard::new(); - keyboard.url("Ochiq Havolalar", "https://github.com/rust-lang-uz/rustina") -} - pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { if !msg.chat.is_private() { return { @@ -31,3 +26,8 @@ pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { Ok(()) } + +pub fn keyboard() -> InlineKeyboardMarkup { + let mut keyboard = Keyboard::new(); + keyboard.url("Ochiq Havolalar", "https://github.com/rust-lang-uz/rustina") +} diff --git a/src/functions/groups.rs b/src/functions/groups.rs index 104e004..fb41b13 100644 --- a/src/functions/groups.rs +++ b/src/functions/groups.rs @@ -13,7 +13,7 @@ static TEXT: &str = "Telegramdagi Rust Hamjamiyatlari yoki Guruhlari:\nAg pub async fn command(bot: &Bot, msg: &Message, groups: &Groups) -> ResponseResult<()> { bot.send_message(msg.chat.id, TEXT) .parse_mode(ParseMode::Html) - .reply_markup(keyboard_list(&groups, 1)) + .reply_markup(keyboard_list(groups, 1)) .await?; Ok(()) @@ -29,7 +29,7 @@ pub async fn callback_list( if let Some(Message { id, chat, .. }) = q.message.clone() { bot.edit_message_text(chat.id, id, TEXT) .parse_mode(ParseMode::Html) - .reply_markup(keyboard_list(&groups, args[0].parse().unwrap_or(1))) + .reply_markup(keyboard_list(groups, args[0].parse().unwrap_or(1))) .await?; } else if let Some(id) = q.inline_message_id.clone() { bot.edit_message_text_inline(id, "Oopsie, something went wrong...") @@ -80,7 +80,7 @@ pub fn keyboard_list(groups: &Groups, page: i32) -> InlineKeyboardMarkup { &format!( "detail_{}_{}", page, - group.telegram.clone().replace("@", "") + group.telegram.clone().replace('@', "") ), ); keyboard.row(); diff --git a/src/functions/help.rs b/src/functions/help.rs index c60ab42..b438238 100644 --- a/src/functions/help.rs +++ b/src/functions/help.rs @@ -3,15 +3,14 @@ use crate::Command; use teloxide::{payloads::SendMessageSetters, prelude::*, types::ParseMode}; static TEXT: &[(&str, &str)] = &[ - ("doc", "reply qilingan odamga dok borligi haqida eslatish"), + ("docs", "reply qilingan odamga dok borligi haqida eslatish"), ("useful", "rust haqida foydali yoki kerakli ma'lumotlar"), - ("last", "eng oxirgi reliz haqida qisqacha ma'lumot"), + ("latest", "eng oxirgi reliz haqida qisqacha ma'lumot"), ("version", "biron anniq reliz haqida to'liq ma'lumot"), ( "off", "reply qilingan odamga offtop borligi haqida eslatish", ), - ("nometa", "to'g'ri savol berish haqida eslatma"), ("group", "rust ga oid guruh va hamjamiyatlar"), ("help", "ushbu xabarni qayta ko'rsatish"), ("about", "ushbu botimizning rivojlantirish qismi"), diff --git a/src/functions/latest.rs b/src/functions/latest.rs index e69b8d5..7a491df 100644 --- a/src/functions/latest.rs +++ b/src/functions/latest.rs @@ -19,12 +19,12 @@ pub async fn command(bot: &Bot, github: GitHub, msg: &Message) -> ResponseResult pub fn view(release: &Release) -> String { format!( - "Hozirgi eng oxirgi versiya bu \ + "Hozirgi eng oxirgi versiya bu \ {} va ushbu reliz {} da e'lon qilingan \ {} tomonidan.\ \n\n\ ", - format!("https://releases.rs/docs/{}", release.tag_name), + release.tag_name, release.tag_name, release.published_at.unwrap().date_naive(), release.author.html_url, diff --git a/src/functions/mod.rs b/src/functions/mod.rs index abb09c2..cdb765e 100644 --- a/src/functions/mod.rs +++ b/src/functions/mod.rs @@ -1,3 +1,5 @@ +#![allow(clippy::single_match)] + pub mod about; pub mod groups; pub mod help; diff --git a/src/functions/rules.rs b/src/functions/rules.rs index b80923b..cb528af 100644 --- a/src/functions/rules.rs +++ b/src/functions/rules.rs @@ -19,11 +19,6 @@ Iltimos qoidalarga oz bo'lsada vaqt ajratishni unutmang, bu muhim! Ushbu guruhda Ushbu qoidalarni doimiy tarzda buzish, butunlay ban yoki bir necha ogohlantirishlirga olib keladi! "#; -pub fn keyboard() -> InlineKeyboardMarkup { - let mut keyboard = Keyboard::new(); - keyboard.url("Guruhga qaytish", "https://t.me/rustlanguz") -} - pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { if !msg.chat.is_private() { return { @@ -39,3 +34,8 @@ pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { Ok(()) } + +pub fn keyboard() -> InlineKeyboardMarkup { + let mut keyboard = Keyboard::new(); + keyboard.url("Guruhga qaytish", "https://t.me/rustlanguz") +} diff --git a/src/functions/start.rs b/src/functions/start.rs index d4c3974..d63e5da 100644 --- a/src/functions/start.rs +++ b/src/functions/start.rs @@ -11,12 +11,6 @@ static TEXT: &str = r#" Sizni ko'rib turganimdan bag'oyatda xursandman. Men O'zbek Rust jamiyati tomonidan yaratilgan bot hisoblanib, O'zbek Rust jamiyati foydalanuvchilari uchun foydali resurslarni yetkazish, saqlash va ularni saralash uchun xizmat qilaman. "#; -pub fn keyboard() -> InlineKeyboardMarkup { - let mut keyboard = Keyboard::new(); - keyboard.url("Jamiyat", "https://t.me/rustlanguz"); - keyboard.url("Web Sahifa", "https://rust-lang.uz") -} - pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { bot.send_message(msg.chat.id, TEXT) .parse_mode(ParseMode::Html) @@ -25,3 +19,9 @@ pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { Ok(()) } + +pub fn keyboard() -> InlineKeyboardMarkup { + let mut keyboard = Keyboard::new(); + keyboard.url("Jamiyat", "https://t.me/rustlanguz"); + keyboard.url("Web Sahifa", "https://rust-lang.uz") +} diff --git a/src/utils/github.rs b/src/utils/github.rs index 3f984f5..53dbd9a 100644 --- a/src/utils/github.rs +++ b/src/utils/github.rs @@ -6,6 +6,12 @@ pub struct GitHub { client: Octocrab, } +impl Default for GitHub { + fn default() -> Self { + Self::new() + } +} + impl GitHub { pub fn new() -> Self { Self { diff --git a/src/utils/group_manager.rs b/src/utils/group_manager.rs index b3c240c..7f71628 100644 --- a/src/utils/group_manager.rs +++ b/src/utils/group_manager.rs @@ -15,6 +15,12 @@ pub struct Groups { groups: Vec, } +impl Default for Groups { + fn default() -> Self { + Self::new() + } +} + impl Groups { pub fn new() -> Self { let json: Vec = serde_json::from_str(GROUPS).unwrap();