Notification when user is flooding, fixes

This commit is contained in:
2022-02-16 20:05:14 +03:00
parent 8c3d7c3cc1
commit 49664064f6
3 changed files with 10 additions and 13 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ public class MemoryAntiFloodService : IAntiFlood
var dictKey = DictKey(chat, user); var dictKey = DictKey(chat, user);
if (_bannedUsers.TryGetValue(dictKey, out var expirationTime)) if (_bannedUsers.TryGetValue(dictKey, out var expirationTime))
{ {
if (DateTime.UtcNow <= expirationTime) if (DateTime.UtcNow > expirationTime)
{ {
expirationTime = DateTime.MinValue; expirationTime = DateTime.MinValue;
_bannedUsers.Remove(dictKey); _bannedUsers.Remove(dictKey);
+2 -12
View File
@@ -30,19 +30,9 @@ FROM mcr.microsoft.com/dotnet/aspnet:6.0.1-alpine3.14
WORKDIR /user WORKDIR /user
COPY --from=build /app /app COPY --from=build /app /app
ENV MUSL_LOCPATH /usr/share/i18n/locales/musl \ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
Logging__Console__FormatterName=Simple Logging__Console__FormatterName=Simple
RUN apk add --no-cache cmake make musl-dev gcc gettext-dev libintl icu-libs \ RUN apk add --no-cache icu-libs
&& wget https://gitlab.com/rilian-la-te/musl-locales/-/archive/master/musl-locales-master.zip \
&& unzip musl-locales-master.zip \
&& cd musl-locales-master \
&& cmake -DLOCALE_PROFILE=OFF -D CMAKE_INSTALL_PREFIX:PATH=/usr . && make && make install \
&& cd .. && rm -r musl-locales-master
ENV LANG ru_RU.UTF-8
ENV LANGUAGE ru_RU.UTF-8
ENV LC_ALL ru_RU.UTF-8
ENTRYPOINT ["dotnet", "/app/TelegramBot.dll"] ENTRYPOINT ["dotnet", "/app/TelegramBot.dll"]
+7
View File
@@ -82,6 +82,13 @@ public class Reputation : CommonHandler
} }
_antiFlood.RecordAction(Chat, From); _antiFlood.RecordAction(Chat, From);
if (_antiFlood.IsUserFlooding(Chat, From))
{
await Reply(new HtmlString()
.UserMention(From).Pre(": пользователь отправлен в игнор.")
.ToString());
return;
}
} }
var senderRepCount = await GetUserReputation(From); var senderRepCount = await GetUserReputation(From);