Added midlewares.
This commit is contained in:
@ -20,17 +20,11 @@ pub struct Greeter;
|
||||
|
||||
#[async_trait]
|
||||
impl Handler for Greeter {
|
||||
async fn react(&self, client: &Client, update: &Update) -> anyhow::Result<()> {
|
||||
async fn react(&self, _: &Client, update: &Update) -> anyhow::Result<()> {
|
||||
let Update::NewMessage(message) = update else {return Ok(())};
|
||||
|
||||
// Check if chat has less than 100 participants.
|
||||
let participants = client.iter_participants(message.chat()).total().await?;
|
||||
if participants >= 100 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Choose random greeting from the list of greetings.
|
||||
let reply_text = GREETINGS.iter().choose(&mut rand::thread_rng()).copied();
|
||||
let reply_text = GREETINGS.iter().choose(&mut rand::rngs::OsRng).copied();
|
||||
|
||||
if let Some(text) = reply_text {
|
||||
message.reply(text).await?;
|
||||
|
Reference in New Issue
Block a user