mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-22 09:31:07 +00:00
Use String instead of IriString for domain in telegram bot
This commit is contained in:
parent
bd172753fb
commit
645e6b498a
1 changed files with 8 additions and 9 deletions
|
@ -1,5 +1,4 @@
|
||||||
use crate::db::Db;
|
use crate::db::Db;
|
||||||
use activitystreams::iri_string::types::IriString;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use teloxide::{prelude::*, utils::command::BotCommands};
|
use teloxide::{prelude::*, utils::command::BotCommands};
|
||||||
|
|
||||||
|
@ -13,16 +12,16 @@ enum Command {
|
||||||
Help,
|
Help,
|
||||||
|
|
||||||
#[command(description = "Block a domain from the relay.")]
|
#[command(description = "Block a domain from the relay.")]
|
||||||
Block { domain: IriString },
|
Block { domain: String },
|
||||||
|
|
||||||
#[command(description = "Unblock a domain from the relay.")]
|
#[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)")]
|
#[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)")]
|
#[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) {
|
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?;
|
.await?;
|
||||||
}
|
}
|
||||||
Command::Block { domain } => {
|
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))
|
bot.send_message(msg.chat.id, format!("{} has been blocked", domain))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::Unblock { domain } => {
|
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))
|
bot.send_message(msg.chat.id, format!("{} has been unblocked", domain))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::Allow { domain } => {
|
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))
|
bot.send_message(msg.chat.id, format!("{} has been allowed", domain))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::Disallow { domain } => {
|
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))
|
bot.send_message(msg.chat.id, format!("{} has been disallwoed", domain))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue