Initial commit

This commit is contained in:
eleksir
2025-05-08 18:12:52 +03:00
commit b21e3c84c0
1553 changed files with 649819 additions and 0 deletions

24
DESIGN.txt Normal file
View File

@@ -0,0 +1,24 @@
# How it works.
------------------------------------------------------------------------------------------------------------------------
Autoban uses 2 methods of matching spammers.
1. by querying CAS on member entry or change status from left-to-member.
2. by checking events, collected after 10 seconds since member enters chat.
------------------------------------------------------------------------------------------------------------------------
1.a Events, from new_chat_members being checked versus CAS and if check is positive user being banned.
1.b Events chat_members_updated with fields new_chat_member.status = member and old_chat_member.status = left being
checked versus CAS and if check is positive user being banned.
2.a Uids from message events, from new_chat_members fields stored into NewMembers collection alongside with timestamps
for each user id.
2.b Uids from chat_members_updated with fields new_chat_member.status = member and old_chat_member.status = left are
stored into AppearedUsers collection alongside with timestamps for each user id
2.c Every 10 seconds goroutine runAndBan rakes all events stored in NewMembers and AppearedUsers and compare them.
First it tosses off pairs of events with matching user ids. Then it searches in AppearedUsers events older than 10
seconds since current time and bans them (also puts them into SquashedMembers collection to avoid banning of banned
users). Then it iterates over NewMembers and cleans all events older than 15 seconds.