Skip to content

Commit 27f0a40

Browse files
committed
hotfix: stop sending join requests to the users with persian chars in their names (spam)
1 parent 98cb061 commit 27f0a40

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/bot.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use crate::telegram::{self, ForwardMessage, PinChatMessage, WebhookReply};
44

55
use std::collections::HashMap;
66

7-
use rust_persian_tools::digits::DigitsEn2Fa;
7+
use rust_persian_tools::{
8+
persian_chars::HasPersian,
9+
arabic_chars::HasArabic,
10+
digits::DigitsEn2Fa,
11+
};
812
use telegram_types::bot::{
913
methods::{
1014
ApproveJoinRequest, ChatTarget, DeclineJoinRequest, DeleteMessage, ReplyMarkup,
@@ -240,6 +244,11 @@ impl Bot {
240244
if !self.config.bot.allowed_chats_id.contains(&r.chat.id) {
241245
return Response::empty();
242246
}
247+
// hotfix: ignore persian names for now
248+
// as targeted spam users mostly have a name containing persian chars
249+
if r.from.first_name.has_persian(true) || r.from.first_name.has_arabic() {
250+
return Response::empty();
251+
}
243252
return self.chat_join_request(&r.from, r.chat.id).await;
244253
}
245254
Some(UpdateContent::CallbackQuery(q)) => {

0 commit comments

Comments
 (0)