From 645e6b498a81ed53b8c037a9bbfcbcca77fe1292 Mon Sep 17 00:00:00 2001 From: asonix Date: Wed, 2 Nov 2022 18:04:57 -0500 Subject: [PATCH] Use String instead of IriString for domain in telegram bot --- src/telegram.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/telegram.rs b/src/telegram.rs index 9c0c2c0..a57742c 100644 --- a/src/telegram.rs +++ b/src/telegram.rs @@ -1,5 +1,4 @@ use crate::db::Db; -use activitystreams::iri_string::types::IriString; use std::sync::Arc; use teloxide::{prelude::*, utils::command::BotCommands}; @@ -13,16 +12,16 @@ enum Command { Help, #[command(description = "Block a domain from the relay.")] - Block { domain: IriString }, + Block { domain: String }, #[command(description = "Unblock a domain from the relay.")] - Unblock { domain: IriString }, + Unblock { domain: String }, #[command(description = "Allow a domain to connect to the relay (for RESTRICTED_MODE)")] - Allow { domain: IriString }, + Allow { domain: String }, #[command(description = "Disallow a domain to connect to the relay (for RESTRICTED_MODE)")] - Disallow { domain: IriString }, + Disallow { domain: String }, } pub(crate) fn start(admin_handle: String, db: Db, token: &str) { @@ -61,25 +60,25 @@ async fn answer(bot: Bot, msg: Message, cmd: Command, db: Db) -> ResponseResult< .await?; } Command::Block { domain } => { - if db.add_blocks(vec![domain.to_string()]).await.is_ok() { + if db.add_blocks(vec![domain.clone()]).await.is_ok() { bot.send_message(msg.chat.id, format!("{} has been blocked", domain)) .await?; } } Command::Unblock { domain } => { - if db.remove_blocks(vec![domain.to_string()]).await.is_ok() { + if db.remove_blocks(vec![domain.clone()]).await.is_ok() { bot.send_message(msg.chat.id, format!("{} has been unblocked", domain)) .await?; } } Command::Allow { domain } => { - if db.add_allows(vec![domain.to_string()]).await.is_ok() { + if db.add_allows(vec![domain.clone()]).await.is_ok() { bot.send_message(msg.chat.id, format!("{} has been allowed", domain)) .await?; } } Command::Disallow { domain } => { - if db.remove_allows(vec![domain.to_string()]).await.is_ok() { + if db.remove_allows(vec![domain.clone()]).await.is_ok() { bot.send_message(msg.chat.id, format!("{} has been disallwoed", domain)) .await?; }