mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Code cleanup
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
namespace Kruzya.TelegramBot.Core.Cache
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Cache
|
|
||||||
{
|
{
|
||||||
public interface ICacheStorage<TKey, TValue>
|
public interface ICacheStorage<TKey, TValue>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using SQLitePCL;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Cache
|
namespace Kruzya.TelegramBot.Core.Cache
|
||||||
{
|
{
|
||||||
@@ -32,7 +30,7 @@ namespace Kruzya.TelegramBot.Core.Cache
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Dictionary<TKey, CacheEntry<TValue>> dict = new Dictionary<TKey, CacheEntry<TValue>>();
|
private readonly Dictionary<TKey, CacheEntry<TValue>> _dict = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The TTL for all entries if not set.
|
/// The TTL for all entries if not set.
|
||||||
@@ -51,20 +49,20 @@ namespace Kruzya.TelegramBot.Core.Cache
|
|||||||
public bool TryGetValue(TKey key, out TValue value)
|
public bool TryGetValue(TKey key, out TValue value)
|
||||||
{
|
{
|
||||||
value = default;
|
value = default;
|
||||||
if (!dict.ContainsKey(key))
|
if (!_dict.ContainsKey(key))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheEntry<TValue> temp;
|
CacheEntry<TValue> temp;
|
||||||
if (!dict.TryGetValue(key, out temp))
|
if (!_dict.TryGetValue(key, out temp))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp.IsExpired())
|
if (temp.IsExpired())
|
||||||
{
|
{
|
||||||
dict.Remove(key);
|
_dict.Remove(key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,12 +88,12 @@ namespace Kruzya.TelegramBot.Core.Cache
|
|||||||
|
|
||||||
public void SetValue(TKey key, TValue value, int timeToLive)
|
public void SetValue(TKey key, TValue value, int timeToLive)
|
||||||
{
|
{
|
||||||
if (dict.ContainsKey(key))
|
if (_dict.ContainsKey(key))
|
||||||
{
|
{
|
||||||
dict.Remove(key);
|
_dict.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
dict.Add(key, new CacheEntry<TValue>()
|
_dict.Add(key, new CacheEntry<TValue>()
|
||||||
{
|
{
|
||||||
Created = DateTime.Now,
|
Created = DateTime.Now,
|
||||||
ExpiresAt = timeToLive,
|
ExpiresAt = timeToLive,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Data
|
namespace Kruzya.TelegramBot.Core.Data
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Xml.Serialization;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Data
|
namespace Kruzya.TelegramBot.Core.Data
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Telegram.Bot.Types;
|
||||||
using Telegram.Bot.Types;
|
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Extensions;
|
namespace Kruzya.TelegramBot.Core.Extensions;
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using System.Threading.Tasks;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Extensions
|
namespace Kruzya.TelegramBot.Core.Extensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework;
|
|
||||||
using BotFramework.Abstractions;
|
using BotFramework.Abstractions;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Telegram.Bot;
|
|
||||||
using Telegram.Bot.Exceptions;
|
|
||||||
using Telegram.Bot.Types;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.Core.Service
|
namespace Kruzya.TelegramBot.Core.Service
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public partial class BanStickerSet
|
|||||||
|
|
||||||
public async Task<bool> PreCommand(ParamParser.StickerSet.Param? stickerSetParam = null)
|
public async Task<bool> PreCommand(ParamParser.StickerSet.Param? stickerSetParam = null)
|
||||||
{
|
{
|
||||||
if (stickerSetParam != null && !stickerSetParam.IsValid)
|
if (stickerSetParam is { IsValid: false })
|
||||||
{
|
{
|
||||||
await Reply("Неверный набор стикеров.");
|
await Reply("Неверный набор стикеров.");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework;
|
using BotFramework;
|
||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#nullable enable
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
using Kruzya.TelegramBot.Core.Data;
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ using System.Threading.Tasks;
|
|||||||
using BotFramework;
|
using BotFramework;
|
||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using BotFramework.Setup;
|
|
||||||
using Kruzya.TelegramBot.CombotAntiSpam.Combot;
|
using Kruzya.TelegramBot.CombotAntiSpam.Combot;
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
using Kruzya.TelegramBot.Core.Extensions;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
@@ -15,8 +13,7 @@ namespace Kruzya.TelegramBot.CombotAntiSpam;
|
|||||||
|
|
||||||
public class UserJoinHandler : BotEventHandler
|
public class UserJoinHandler : BotEventHandler
|
||||||
{
|
{
|
||||||
protected ICombotClient _combotClient;
|
private readonly ICombotClient _combotClient;
|
||||||
protected ILogger _logger;
|
|
||||||
|
|
||||||
public UserJoinHandler(ICombotClient combotClient)
|
public UserJoinHandler(ICombotClient combotClient)
|
||||||
{
|
{
|
||||||
@@ -27,17 +24,9 @@ public class UserJoinHandler : BotEventHandler
|
|||||||
[Message(MessageFlag.HasNewChatMembers)]
|
[Message(MessageFlag.HasNewChatMembers)]
|
||||||
public async Task OnUserJoined()
|
public async Task OnUserJoined()
|
||||||
{
|
{
|
||||||
// var canKickMembers = (await Bot.GetChatMemberAsync(Chat, (await Bot.GetMeAsync()).Id)).CanRestrictMembers == true;
|
var canKickMembers = await Bot.IsUserAdminAsync(Chat, await Bot.GetMeAsync());
|
||||||
var meUserId = (await Bot.GetMeAsync()).Id;
|
|
||||||
var meChatMember = await Bot.GetChatMemberAsync(Chat, meUserId);
|
|
||||||
|
|
||||||
var canKickMembers = false;
|
foreach (var member in RawUpdate.Message!.NewChatMembers!)
|
||||||
if (meChatMember is ChatMemberAdministrator adminMember)
|
|
||||||
{
|
|
||||||
canKickMembers = adminMember.CanRestrictMembers;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var member in RawUpdate.Message.NewChatMembers)
|
|
||||||
{
|
{
|
||||||
if (!(await _combotClient.IsSpammerAsync(member)))
|
if (!(await _combotClient.IsSpammerAsync(member)))
|
||||||
{
|
{
|
||||||
@@ -45,7 +34,7 @@ public class UserJoinHandler : BotEventHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
var messageText = new StringBuilder();
|
var messageText = new StringBuilder();
|
||||||
messageText.Append($"⚠️ <b>Combot Anti-Spam</b>\n\n");
|
messageText.Append("⚠️ <b>Combot Anti-Spam</b>\n\n");
|
||||||
messageText.Append($"User {member.ToHtml(true)} is spammer.\n");
|
messageText.Append($"User {member.ToHtml(true)} is spammer.\n");
|
||||||
messageText.Append(
|
messageText.Append(
|
||||||
$"More details you can find on <a href=\"https://cas.chat/query?u={member.Id}\">CAS site</a>.");
|
$"More details you can find on <a href=\"https://cas.chat/query?u={member.Id}\">CAS site</a>.");
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ public class ContentStore : Module
|
|||||||
{
|
{
|
||||||
services.AddOption<AllowNsfw>();
|
services.AddOption<AllowNsfw>();
|
||||||
|
|
||||||
var kittiesConfig = Configuration.GetSection("KittiesService");
|
|
||||||
services.AddHttpClient<IKittiesApi, KittiesApi>(c =>
|
services.AddHttpClient<IKittiesApi, KittiesApi>(c =>
|
||||||
{
|
{
|
||||||
|
var kittiesConfig = Configuration.GetSection("KittiesService");
|
||||||
|
|
||||||
c.BaseAddress = kittiesConfig.GetValue<Uri>("Uri");
|
c.BaseAddress = kittiesConfig.GetValue<Uri>("Uri");
|
||||||
c.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
|
c.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
|
||||||
"Bearer",
|
"Bearer",
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Kruzya.TelegramBot.Core.Data;
|
using West.TelegramBot.ContentStore.API;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using West.TelegramBot.ContentStore.API;
|
|
||||||
using West.TelegramBot.ContentStore.Model;
|
using West.TelegramBot.ContentStore.Model;
|
||||||
using West.TelegramBot.ContentStore.Option;
|
using West.TelegramBot.ContentStore.Option;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using West.TelegramBot.ContentStore.API;
|
||||||
using West.TelegramBot.ContentStore.API;
|
|
||||||
using West.TelegramBot.ContentStore.Model;
|
using West.TelegramBot.ContentStore.Model;
|
||||||
using West.TelegramBot.ContentStore.Option;
|
using West.TelegramBot.ContentStore.Option;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Kruzya.TelegramBot.Core.Data;
|
using Newtonsoft.Json;
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using West.TelegramBot.ContentStore.Model;
|
using West.TelegramBot.ContentStore.Model;
|
||||||
using West.TelegramBot.ContentStore.Option;
|
using West.TelegramBot.ContentStore.Option;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ global using GuessCache = Kruzya.TelegramBot.Core.Cache.MemoryCache<Telegram.Bot
|
|||||||
|
|
||||||
|
|
||||||
using Kruzya.TelegramBot.Core;
|
using Kruzya.TelegramBot.Core;
|
||||||
using Kruzya.TelegramBot.Core.Options;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using System;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework;
|
using BotFramework;
|
||||||
using Castle.Core.Internal;
|
|
||||||
using Kruzya.TelegramBot.Core;
|
using Kruzya.TelegramBot.Core;
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
using Kruzya.TelegramBot.Core.Data;
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
using Kruzya.TelegramBot.Core.Extensions;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class Guess : CommonHandler
|
|||||||
{
|
{
|
||||||
ChatId = Chat.Id,
|
ChatId = Chat.Id,
|
||||||
DeleteAt = DateTime.UtcNow.AddSeconds(20),
|
DeleteAt = DateTime.UtcNow.AddSeconds(20),
|
||||||
MessageId = Message.MessageId
|
MessageId = Message!.MessageId
|
||||||
});
|
});
|
||||||
|
|
||||||
var cooldownOption = await _db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "guessCooldown");
|
var cooldownOption = await _db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "guessCooldown");
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Telegram.Bot.Types;
|
namespace West.Entertainment.Handler;
|
||||||
|
|
||||||
namespace West.Entertainment.Handler;
|
|
||||||
|
|
||||||
public class GuessData
|
public class GuessData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Kruzya.TelegramBot.Core;
|
using Kruzya.TelegramBot.Core;
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
using Kruzya.TelegramBot.Core.Data;
|
||||||
@@ -14,7 +13,6 @@ using Kruzya.TelegramBot.Core.AutoDelete;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Microsoft.AspNetCore.Components.Forms;
|
|
||||||
using Kruzya.TelegramBot.Core.Handler;
|
using Kruzya.TelegramBot.Core.Handler;
|
||||||
|
|
||||||
namespace West.Entertainment.Handler;
|
namespace West.Entertainment.Handler;
|
||||||
@@ -46,7 +44,7 @@ public class Roll : CommonHandler
|
|||||||
{
|
{
|
||||||
ChatId = Chat.Id,
|
ChatId = Chat.Id,
|
||||||
DeleteAt = DateTime.UtcNow.AddSeconds(20),
|
DeleteAt = DateTime.UtcNow.AddSeconds(20),
|
||||||
MessageId = Message.MessageId
|
MessageId = Message!.MessageId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (cd > DateTime.Now)
|
if (cd > DateTime.Now)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/// This file is a part of RSS Bot for Telegram.
|
// This file is a part of RSS Bot for Telegram.
|
||||||
/// License: MIT
|
// License: MIT
|
||||||
/// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
||||||
///
|
//
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
/// This file is a part of RSS Bot for Telegram.
|
// This file is a part of RSS Bot for Telegram.
|
||||||
/// License: MIT
|
// License: MIT
|
||||||
/// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
||||||
///
|
//
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Web;
|
|
||||||
using Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule;
|
using Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule;
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/// This file is a part of RSS Bot for Telegram.
|
// This file is a part of RSS Bot for Telegram.
|
||||||
/// License: MIT
|
// License: MIT
|
||||||
/// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
||||||
///
|
//
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/// This file is a part of RSS Bot for Telegram.
|
// This file is a part of RSS Bot for Telegram.
|
||||||
/// License: MIT
|
// License: MIT
|
||||||
/// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
// Author: CrazyHackGUT aka Kruzya (Sergey Gut) <kruzefag@gmail.com>
|
||||||
///
|
//
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using BotFramework.Setup;
|
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
using Kruzya.TelegramBot.Core.Extensions;
|
||||||
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using BotFramework;
|
||||||
using BotFramework;
|
|
||||||
using Kruzya.TelegramBot.Core;
|
using Kruzya.TelegramBot.Core;
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
using Kruzya.TelegramBot.Core.Extensions;
|
||||||
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
||||||
@@ -7,7 +6,6 @@ using Kruzya.TelegramBot.RichSiteSummary.Service;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Telegram.Bot.Types;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.RichSiteSummary
|
namespace Kruzya.TelegramBot.RichSiteSummary
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Net;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CodeHollow.FeedReader;
|
using CodeHollow.FeedReader;
|
||||||
@@ -20,8 +19,6 @@ using Telegram.Bot.Types.Enums;
|
|||||||
using Feed = Kruzya.TelegramBot.RichSiteSummary.Data.Feed;
|
using Feed = Kruzya.TelegramBot.RichSiteSummary.Data.Feed;
|
||||||
|
|
||||||
using CodeHollow.FeedReader.Feeds;
|
using CodeHollow.FeedReader.Feeds;
|
||||||
using CodeHollow.FeedReader.Feeds.Itunes;
|
|
||||||
using CodeHollow.FeedReader.Feeds.MediaRSS;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,13 +2,11 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework;
|
|
||||||
using BotFramework.Abstractions;
|
using BotFramework.Abstractions;
|
||||||
using Kruzya.TelegramBot.Core.Service;
|
using Kruzya.TelegramBot.Core.Service;
|
||||||
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Telegram.Bot;
|
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule
|
namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework;
|
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ using System.Threading.Tasks;
|
|||||||
using BotFramework;
|
using BotFramework;
|
||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using BotFramework.Setup;
|
|
||||||
using Kruzya.TelegramBot.Core.Cache;
|
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
using Kruzya.TelegramBot.Core.Data;
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
using Kruzya.TelegramBot.Core.Extensions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -49,12 +47,12 @@ namespace Kruzya.TelegramBot.UrlLimitations
|
|||||||
0 || await message.HasUnknownMention(Bot))
|
0 || await message.HasUnknownMention(Bot))
|
||||||
{
|
{
|
||||||
var targetChat = new ChatId(Chat.Id);
|
var targetChat = new ChatId(Chat.Id);
|
||||||
Task.WaitAll(new Task[] {
|
Task.WaitAll(
|
||||||
Bot.BanChatMemberAsync(new ChatId(Chat.Id), From.Id, DateTime.Now.AddDays(1)),
|
Bot.BanChatMemberAsync(new ChatId(Chat.Id), From.Id, DateTime.Now.AddDays(1)),
|
||||||
Bot.DeleteMessageAsync(targetChat, message.MessageId),
|
Bot.DeleteMessageAsync(targetChat, message.MessageId),
|
||||||
Bot.SendTextMessageAsync(targetChat,
|
Bot.SendTextMessageAsync(targetChat,
|
||||||
$"Member {From.ToHtml(true)} has been banned.\n<b>Reason</b>: <pre>Spam suspicion</pre>", parseMode: ParseMode.Html)
|
$"Member {From.ToHtml(true)} has been banned.\n<b>Reason</b>: <pre>Spam suspicion</pre>", parseMode: ParseMode.Html)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
using Kruzya.TelegramBot.Core;
|
||||||
using Kruzya.TelegramBot.Core;
|
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.UrlLimitations
|
namespace Kruzya.TelegramBot.UrlLimitations
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,11 +3,8 @@ using System.Threading.Tasks;
|
|||||||
using BotFramework;
|
using BotFramework;
|
||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using BotFramework.Setup;
|
|
||||||
using Kruzya.TelegramBot.Core.Cache;
|
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
using Kruzya.TelegramBot.Core.Data;
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
using Kruzya.TelegramBot.Core.Extensions;
|
||||||
using Telegram.Bot.Types.Enums;
|
|
||||||
|
|
||||||
namespace Kruzya.TelegramBot.UrlLimitations
|
namespace Kruzya.TelegramBot.UrlLimitations
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using BotFramework;
|
|||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using BotFramework.Utils;
|
using BotFramework.Utils;
|
||||||
using Castle.Core.Internal;
|
|
||||||
using Kruzya.TelegramBot.Core.Cache;
|
using Kruzya.TelegramBot.Core.Cache;
|
||||||
using Kruzya.TelegramBot.Core.Data;
|
using Kruzya.TelegramBot.Core.Data;
|
||||||
using Kruzya.TelegramBot.Core.Extensions;
|
using Kruzya.TelegramBot.Core.Extensions;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Kruzya.TelegramBot.Core;
|
||||||
using Kruzya.TelegramBot.Core;
|
|
||||||
|
|
||||||
namespace UserGroupTag
|
namespace UserGroupTag
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user