🚧 Anti-spam system based on entities

This commit is contained in:
2020-03-03 14:11:51 +04:00
parent 1441c345b2
commit 8f8898e901
9 changed files with 148 additions and 3 deletions
+2 -2
View File
@@ -161,11 +161,11 @@ namespace Kruzya.TelegramBot.Core
private void HookAppDomain()
{
var appDomain = AppDomain.CurrentDomain;
appDomain.AssemblyResolve += delegate(object? sender, ResolveEventArgs args)
{
var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string assemblyPath = Path.Combine(basePath, new AssemblyName(args.Name).Name + ".dll");
var assemblyPath = Path.Combine(basePath, new AssemblyName(args.Name).Name + ".dll");
if (!File.Exists(assemblyPath))
{
return null;
+4
View File
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using Kruzya.TelegramBot.Core.Cache;
using Microsoft.Extensions.DependencyInjection;
namespace Kruzya.TelegramBot.Core.Extensions
@@ -7,5 +8,8 @@ namespace Kruzya.TelegramBot.Core.Extensions
{
public static IServiceCollection AddQueue<T>(this IServiceCollection collection)
=> collection.AddSingleton<ConcurrentQueue<T>>();
public static IServiceCollection AddMemoryCache<TKey, TValue>(this IServiceCollection collection)
=> collection.AddSingleton<MemoryCache<TKey, TValue>>();
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Kruzya.TelegramBot.Core.Extensions
public static string ToHtml(this User user)
{
var text = new StringBuilder();
text.Append("<a href=\"tg://user?id={member.Id}\">");
text.Append($"<a href=\"tg://user?id={user.Id}\">");
if (!string.IsNullOrWhiteSpace(user.Username))
text.Append(user.Username);
else