-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
164 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<b>Salom bo'lajak Rustacean!</b> | ||
|
||
Ushbu tutorialga xush kelibsiz! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use teloxide::{payloads::SendMessageSetters, prelude::*, types::ParseMode}; | ||
|
||
pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { | ||
println!("Command triggered: {:?}", msg); | ||
bot.send_message(msg.chat.id, view(msg)) | ||
.parse_mode(ParseMode::Html) | ||
// .reply_markup(keyboard()) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn view(msg: &Message) -> String { | ||
let mut message: String = String::new(); | ||
|
||
message.push_str(&format!("<b>Chat ID:</b> {}", msg.chat.id)); | ||
|
||
if msg.thread_id.is_some() { | ||
message.push_str(&format!("\n<b>Thread ID:</b> {}", msg.thread_id.unwrap())) | ||
} | ||
|
||
println!("Message: {:?}", message); | ||
|
||
message | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use teloxide::{prelude::*, types::*}; | ||
|
||
static TEXT: &str = "<b>Salom bo'lajak Rustacean!</b>\n\n\ | ||
Sizlarni bu guruhda ko'rib turganimizdan mamnunmiz. Bu guruh Rust dasturlash tiliga qaratilgan hisoblanib, \ | ||
bu yerda ushbu til haqida gaplashish, savollar berish yoki o'z fikrlaringiz bilan bo'lishishingiz mumkin. \ | ||
Hamda, agar siz ushbu dasturlash tilida butunlay yangi bo'lsangiz, /roadmap yordamida kerakli boshlang'ich \ | ||
maslahatlar, va hamda /useful yordamoda foydali resurslar olishingiz mumkin. | ||
"; | ||
|
||
pub async fn trigger(bot: &Bot, msg: &Message) -> ResponseResult<()> { | ||
let message = bot | ||
.send_message(msg.chat.id, TEXT) | ||
.parse_mode(ParseMode::Html); | ||
|
||
if msg.thread_id.is_some() { | ||
message | ||
.message_thread_id(msg.thread_id.unwrap()) | ||
.send() | ||
.await?; | ||
} else { | ||
message.send().await?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::hooks; | ||
use crate::utils::keyboard::Keyboard; | ||
use teloxide::{ | ||
payloads::SendMessageSetters, | ||
prelude::*, | ||
types::{InlineKeyboardMarkup, ParseMode}, | ||
}; | ||
|
||
static ROADMAP: &str = include_str!("../../data/roadmap.md"); | ||
|
||
pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { | ||
if !msg.chat.is_private() { | ||
return { | ||
hooks::is_private(bot, msg).await.unwrap(); | ||
Ok(()) | ||
}; | ||
} | ||
|
||
bot.send_message(msg.chat.id, ROADMAP) | ||
.parse_mode(ParseMode::Html) | ||
.reply_markup(keyboard()) | ||
.await?; | ||
|
||
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use teloxide::{payloads::*, prelude::*, requests::JsonRequest, types::*}; | ||
|
||
trait RequestTopicFriendly { | ||
type Err: std::error::Error + Send; | ||
type SendMessageTF: Request<Payload = SendMessage, Err = Self::Err>; | ||
|
||
/// For Telegram documentation see [`SendMessage`]. | ||
fn send_message_tf<C, T>(&self, chat_id: C, text: T) -> Self::SendMessageTF | ||
where | ||
C: Into<Recipient>, | ||
T: Into<String>; | ||
} | ||
|
||
impl RequestTopicFriendly for Bot { | ||
type Err = teloxide::errors::RequestError; | ||
type SendMessageTF = JsonRequest<teloxide::payloads::SendMessage>; | ||
|
||
fn send_message_tf<C, T>(&self, chat_id: C, text: T) -> Self::SendMessageTF | ||
where | ||
C: Into<Recipient>, | ||
T: Into<String>, | ||
{ | ||
Self::SendMessageTF::new( | ||
self.clone(), | ||
teloxide::payloads::SendMessage::new(chat_id, text), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ pub mod github; | |
pub mod groups; | ||
pub mod inlines; | ||
pub mod keyboard; | ||
pub mod message; | ||
pub mod resources; |