Skip to content

Commit

Permalink
new type update checkups
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Oct 14, 2024
1 parent be192e9 commit 242f260
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 110 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
nohup.out
/target
.idea
152 changes: 61 additions & 91 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bots/xinuxmgr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ url = "2.4.1"
uuid = { version = "1.5.0", features = ["v4"] }
serde_json = "1"
serde = { version = "1", features = ["derive"] }
orzklv = { version = "0.0.8", features = ["full"] }
orzklv = { version = "0.1.8", features = ["full"] }
libxinux = { version = "0.2.3", features = ["pkgs-async"] }
20 changes: 16 additions & 4 deletions bots/xinuxmgr/src/functions/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ macro_rules! return_err_answer {
InputMessageContent::Text(
InputMessageContentText::new($msg)
.parse_mode(ParseMode::Html)
.disable_web_page_preview(true),
.link_preview_options(LinkPreviewOptions {
is_disabled: true,
url: None,
prefer_small_media: false,
prefer_large_media: false,
show_above_text: false,
})
),
)
.reply_markup(err_keyboard())
Expand Down Expand Up @@ -67,11 +73,17 @@ pub async fn inline(
InputMessageContent::Text(
InputMessageContentText::new(view_generate(d))
.parse_mode(ParseMode::Html)
.disable_web_page_preview(true),
.link_preview_options(LinkPreviewOptions {
is_disabled: true,
url: None,
prefer_small_media: false,
prefer_large_media: false,
show_above_text: false,
})
),
)
.description(d.description.clone().unwrap())
.reply_markup(kb_generate(d)),
.description(d.description.clone().unwrap())
.reply_markup(kb_generate(d)),
)
})
.collect();
Expand Down
4 changes: 2 additions & 2 deletions bots/xinuxmgr/src/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub async fn callback(

pub async fn triggers(bot: Bot, msg: Message) -> Result<(), Box<dyn Error + Send + Sync>> {
if let Some(thread) = msg.thread_id {
if msg.chat.id.0 == -1001174263940 && thread == 178654 {
if msg.chat.id.0 == -1001174263940 && thread.0.0 == 178654 {
// Delete anything except image
if msg.photo().is_some() || msg.document().is_some() {
return Ok(());
Expand All @@ -72,7 +72,7 @@ pub async fn triggers(bot: Bot, msg: Message) -> Result<(), Box<dyn Error + Send
}
}

if let Some(user) = msg.from() {
if let Some(ref user) = msg.from {
if let Some(username) = user.username.clone() {
if username == "Channel_Bot" {
// Try to delete message and ignore error
Expand Down
24 changes: 12 additions & 12 deletions bots/xinuxmgr/src/functions/warn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> Resp
}

if msg.reply_to_message().is_none()
|| msg.reply_to_message().unwrap().id == MessageId(msg.thread_id.unwrap())
|| msg.reply_to_message().unwrap().id == MessageId(msg.thread_id.unwrap().0.0)
{
return {
bot.send_message_tf(msg.chat.id, TEXT_NON_REPLY, msg)
Expand All @@ -43,7 +43,7 @@ pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> Resp
}

// if replied person is bot itself, send a fail message
if let Some(user) = msg.reply_to_message().as_ref().unwrap().from() {
if let Some(user) = &msg.reply_to_message().as_ref().unwrap().from {
if user.username.is_some() && user.username.clone().unwrap() == me.username() {
return {
bot.send_message_tf(msg.chat.id, TEXT_FAIL, msg).await?;
Expand All @@ -55,7 +55,7 @@ pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> Resp
bot.delete_message(msg.chat.id, msg.reply_to_message().unwrap().id)
.await?;

let replied_person = match msg.reply_to_message().unwrap().from() {
let replied_person = match &msg.reply_to_message().unwrap().from {
None => {
bot.send_message_tf(
msg.chat.id,
Expand All @@ -73,15 +73,15 @@ pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> Resp
msg.chat.id,
format!(
"<b>Xo'sh, <a href=\"tg://user?id={}\">{}</a>.</b> Qaysi mavzu taraflama yozgan odam chetlashdi?",
msg.from().unwrap().id,
msg.from().unwrap().first_name
msg.from.clone().unwrap().id,
msg.from.clone().unwrap().first_name
),
msg,
) // view_detail(msg.reply_to_message().unwrap())
.parse_mode(ParseMode::Html)
.reply_markup(keyboard(
topics.list(),
msg.from().unwrap().id,
msg.from.clone().unwrap().id,
&replied_person.id,
&replied_person.first_name,
))
Expand Down Expand Up @@ -113,23 +113,23 @@ pub async fn callback(

match code {
None => {
bot.delete_message(message.chat.id, message.id).await?;
bot.delete_message(message.chat().id, message.id()).await?;
bot.send_message_tf(
message.chat.id,
message.chat().id,
"Unaqa topic borga o'xshamaydi do'stlar...",
&message,
&message.regular_message().unwrap(),
)
.await?;

Ok(())
}
Some(c) => {
bot.delete_message(message.chat.id, message.id).await?;
bot.delete_message(message.chat().id, message.id()).await?;

bot.send_message_tf(
message.chat.id,
message.chat().id,
view_detail(sender, title.to_string()),
&message,
&message.regular_message().unwrap(),
)
.reply_markup(callback_keyboard(title, c))
.parse_mode(ParseMode::Html)
Expand Down
Loading

0 comments on commit 242f260

Please sign in to comment.