Added .rl, fixed some messages, removed liveness probe.
This commit is contained in:
@ -37,10 +37,6 @@ spec:
|
|||||||
- name: http
|
- name: http
|
||||||
containerPort: {{ default 8000 .Values.env.BOT_SERVER_PORT }}
|
containerPort: {{ default 8000 .Values.env.BOT_SERVER_PORT }}
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /health
|
|
||||||
port: http
|
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health
|
path: /health
|
||||||
|
@ -2,7 +2,7 @@ use crate::{
|
|||||||
bot::handlers::Handler,
|
bot::handlers::Handler,
|
||||||
utils::{inter_join::RandomIntersperse, messages::get_message},
|
utils::{inter_join::RandomIntersperse, messages::get_message},
|
||||||
};
|
};
|
||||||
use grammers_client::{Client, Update};
|
use grammers_client::{Client, InputMessage, Update};
|
||||||
|
|
||||||
const BLYA_WORDS: &[&str] = &[", бля,", ", сука,", ", ёбаный рот,", ", охуеть конечно,"];
|
const BLYA_WORDS: &[&str] = &[", бля,", ", сука,", ", ёбаный рот,", ", охуеть конечно,"];
|
||||||
|
|
||||||
@ -32,7 +32,9 @@ impl Handler for Blyaficator {
|
|||||||
|
|
||||||
// If the text was blyaficated we send it as a reply.
|
// If the text was blyaficated we send it as a reply.
|
||||||
if let Some(blyficated) = maybe_blyaficated {
|
if let Some(blyficated) = maybe_blyaficated {
|
||||||
message.reply(blyficated).await?;
|
message
|
||||||
|
.reply(InputMessage::from(blyficated).silent(true))
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
pub mod blyaficator;
|
pub mod blyaficator;
|
||||||
pub mod greeter;
|
pub mod greeter;
|
||||||
|
pub mod rotator;
|
||||||
|
49
src/bot/handlers/fun/rotator.rs
Normal file
49
src/bot/handlers/fun/rotator.rs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use grammers_client::{types::Message, Client, InputMessage, Update};
|
||||||
|
|
||||||
|
use crate::{bot::handlers::Handler, utils::messages::get_message};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Rotator;
|
||||||
|
|
||||||
|
async fn rotator(replied_message: Message, text: String) {
|
||||||
|
let mut skip = 1;
|
||||||
|
let start = std::time::SystemTime::now();
|
||||||
|
let mut current = std::time::SystemTime::now();
|
||||||
|
while current
|
||||||
|
.duration_since(start)
|
||||||
|
.map(|dur| dur.as_secs())
|
||||||
|
.unwrap_or(100)
|
||||||
|
< 10
|
||||||
|
{
|
||||||
|
let rotated = text
|
||||||
|
.chars()
|
||||||
|
.cycle()
|
||||||
|
.skip(skip)
|
||||||
|
.take(text.len())
|
||||||
|
.collect::<String>();
|
||||||
|
skip += 1;
|
||||||
|
if skip == rotated.len() {
|
||||||
|
skip = 0;
|
||||||
|
}
|
||||||
|
replied_message.edit(rotated).await.ok();
|
||||||
|
current = std::time::SystemTime::now();
|
||||||
|
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||||
|
}
|
||||||
|
replied_message.delete().await.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl Handler for Rotator {
|
||||||
|
async fn react(&self, _: &Client, update: &Update) -> anyhow::Result<()> {
|
||||||
|
let Some(message) = get_message(update) else{
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
if let Some(text) = message.text().strip_prefix(".rl").map(str::trim) {
|
||||||
|
let replied_message = message.reply(InputMessage::from(text).silent(true)).await?;
|
||||||
|
tokio::spawn(rotator(replied_message, text.to_string()));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ use super::{
|
|||||||
get_chat_id::GetChatId,
|
get_chat_id::GetChatId,
|
||||||
help::Help,
|
help::Help,
|
||||||
},
|
},
|
||||||
fun::{blyaficator::Blyaficator, greeter::Greeter},
|
fun::{blyaficator::Blyaficator, greeter::Greeter, rotator::Rotator},
|
||||||
Handler,
|
Handler,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -104,12 +104,17 @@ async fn run(args: BotConfig, client: Client) -> anyhow::Result<()> {
|
|||||||
.add_filter(TextFilter(&[".cid"], TextMatchMethod::IMatches)),
|
.add_filter(TextFilter(&[".cid"], TextMatchMethod::IMatches)),
|
||||||
// Make бля fun again.
|
// Make бля fun again.
|
||||||
FilteredHandler::new(Blyaficator)
|
FilteredHandler::new(Blyaficator)
|
||||||
|
.add_filter(SilentFilter)
|
||||||
.add_filter(TextFilter(&[".bl"], TextMatchMethod::IStartsWith)),
|
.add_filter(TextFilter(&[".bl"], TextMatchMethod::IStartsWith)),
|
||||||
// Handler for converting currecies.
|
// Handler for converting currecies.
|
||||||
FilteredHandler::new(CurrencyConverter::new()?)
|
FilteredHandler::new(CurrencyConverter::new()?)
|
||||||
.add_filter(SilentFilter)
|
.add_filter(SilentFilter)
|
||||||
.add_filter(ExcludedChatsFilter(args.currency_excluded_chats))
|
.add_filter(ExcludedChatsFilter(args.currency_excluded_chats))
|
||||||
.add_filter(CurrencyTextFilter),
|
.add_filter(CurrencyTextFilter),
|
||||||
|
// Simlpe rotator.
|
||||||
|
FilteredHandler::new(Rotator)
|
||||||
|
.add_filter(SilentFilter)
|
||||||
|
.add_filter(TextFilter(&[".rl"], TextMatchMethod::IStartsWith)),
|
||||||
];
|
];
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
Reference in New Issue
Block a user