Use file-scoped namespaces

This commit is contained in:
Andriy
2023-07-29 15:14:52 +03:00
parent a24332370d
commit 8ab067a027
58 changed files with 2222 additions and 2280 deletions
+2 -3
View File
@@ -1,9 +1,8 @@
namespace Kruzya.TelegramBot.Core.Cache namespace Kruzya.TelegramBot.Core.Cache;
{
public interface ICacheStorage<TKey, TValue> public interface ICacheStorage<TKey, TValue>
{ {
public bool TryGetValue(TKey key, out TValue value); public bool TryGetValue(TKey key, out TValue value);
public void SetValue(TKey key, TValue value, int timeToLive); public void SetValue(TKey key, TValue value, int timeToLive);
public TValue GetOr(TKey key, TValue value); public TValue GetOr(TKey key, TValue value);
} }
}
+2 -3
View File
@@ -2,8 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
namespace Kruzya.TelegramBot.Core.Cache namespace Kruzya.TelegramBot.Core.Cache;
{
public class MemoryCache<TKey, TValue> : ICacheStorage<TKey, TValue> public class MemoryCache<TKey, TValue> : ICacheStorage<TKey, TValue>
{ {
/// <summary> /// <summary>
@@ -101,4 +101,3 @@ namespace Kruzya.TelegramBot.Core.Cache
}); });
} }
} }
}
+2 -3
View File
@@ -7,8 +7,8 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
namespace Kruzya.TelegramBot.Core namespace Kruzya.TelegramBot.Core;
{
public sealed class Core public sealed class Core
{ {
/// <summary> /// <summary>
@@ -204,4 +204,3 @@ namespace Kruzya.TelegramBot.Core
}; };
} }
} }
}
+2 -3
View File
@@ -1,8 +1,8 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Kruzya.TelegramBot.Core.Data namespace Kruzya.TelegramBot.Core.Data;
{
public class BotUser public class BotUser
{ {
/// <summary> /// <summary>
@@ -21,4 +21,3 @@ namespace Kruzya.TelegramBot.Core.Data
/// </summary> /// </summary>
public long UserId { get; set; } public long UserId { get; set; }
} }
}
+2 -3
View File
@@ -4,8 +4,8 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Kruzya.TelegramBot.Core.Data namespace Kruzya.TelegramBot.Core.Data;
{
public class BotUserValue public class BotUserValue
{ {
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -38,4 +38,3 @@ namespace Kruzya.TelegramBot.Core.Data
ValueType = value.GetType().FullName; ValueType = value.GetType().FullName;
} }
} }
}
+2 -3
View File
@@ -1,8 +1,8 @@
using Kruzya.TelegramBot.Core.EF; using Kruzya.TelegramBot.Core.EF;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace Kruzya.TelegramBot.Core.Data namespace Kruzya.TelegramBot.Core.Data;
{
public class CoreContext : AutoSaveDbContext public class CoreContext : AutoSaveDbContext
{ {
/// <summary> /// <summary>
@@ -22,4 +22,3 @@ namespace Kruzya.TelegramBot.Core.Data
Database.Migrate(); Database.Migrate();
} }
} }
}
+2 -3
View File
@@ -2,8 +2,8 @@
using BotFramework; using BotFramework;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace Kruzya.TelegramBot.Core namespace Kruzya.TelegramBot.Core;
{
/// <summary> /// <summary>
/// Resolves the GUIDs from database to entities. /// Resolves the GUIDs from database to entities.
/// </summary> /// </summary>
@@ -38,4 +38,3 @@ namespace Kruzya.TelegramBot.Core
return false; return false;
} }
} }
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core.Extensions namespace Kruzya.TelegramBot.Core.Extensions;
{
public static class BotExtension public static class BotExtension
{ {
public static async Task<bool> CanPunishMember(this ITelegramBotClient bot, Chat chat, User user, User victim = null) public static async Task<bool> CanPunishMember(this ITelegramBotClient bot, Chat chat, User user, User victim = null)
@@ -43,4 +43,3 @@ namespace Kruzya.TelegramBot.Core.Extensions
or ChatMemberAdministrator {CanRestrictMembers: true}; or ChatMemberAdministrator {CanRestrictMembers: true};
} }
} }
}
+2 -3
View File
@@ -3,8 +3,8 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Kruzya.TelegramBot.Core.Extensions namespace Kruzya.TelegramBot.Core.Extensions;
{
public static class HttpClientExtension public static class HttpClientExtension
{ {
public static async Task<T> GetJsonAsync<T>(this HttpClient client, Uri requestUri) public static async Task<T> GetJsonAsync<T>(this HttpClient client, Uri requestUri)
@@ -19,4 +19,3 @@ namespace Kruzya.TelegramBot.Core.Extensions
return JsonConvert.DeserializeObject<T>(response); return JsonConvert.DeserializeObject<T>(response);
} }
} }
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Kruzya.TelegramBot.Core.Extensions namespace Kruzya.TelegramBot.Core.Extensions;
{
internal static class ModuleArrayExtension internal static class ModuleArrayExtension
{ {
public static void ConfigureServices(this Module[] modules, IServiceCollection services) public static void ConfigureServices(this Module[] modules, IServiceCollection services)
@@ -16,4 +16,3 @@ namespace Kruzya.TelegramBot.Core.Extensions
foreach (var module in modules) module.Configure(app, env); foreach (var module in modules) module.Configure(app, env);
} }
} }
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace Kruzya.TelegramBot.Core.Extensions namespace Kruzya.TelegramBot.Core.Extensions;
{
public static partial class RepositoryExtension public static partial class RepositoryExtension
{ {
public static TEntity Create<TEntity>(this DbSet<TEntity> repository) where TEntity : class, new() public static TEntity Create<TEntity>(this DbSet<TEntity> repository) where TEntity : class, new()
@@ -12,4 +12,3 @@ namespace Kruzya.TelegramBot.Core.Extensions
return entity; return entity;
} }
} }
}
+2 -3
View File
@@ -1,7 +1,7 @@
using System.Web; using System.Web;
namespace Kruzya.TelegramBot.Core.Extensions namespace Kruzya.TelegramBot.Core.Extensions;
{
public static class StringExtension public static class StringExtension
{ {
public static string HtmlEncode(this string content) public static string HtmlEncode(this string content)
@@ -14,4 +14,3 @@ namespace Kruzya.TelegramBot.Core.Extensions
return HttpUtility.HtmlDecode(content); return HttpUtility.HtmlDecode(content);
} }
} }
}
+2 -3
View File
@@ -1,8 +1,8 @@
using System.Text; using System.Text;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core.Extensions namespace Kruzya.TelegramBot.Core.Extensions;
{
public static class UserExtension public static class UserExtension
{ {
public static string ToHtml(this User user, bool byUsername = false) public static string ToHtml(this User user, bool byUsername = false)
@@ -28,4 +28,3 @@ namespace Kruzya.TelegramBot.Core.Extensions
return $"{name} (ID: {user.Id}, Username: {user.Username ?? "N/A"})"; return $"{name} (ID: {user.Id}, Username: {user.Username ?? "N/A"})";
} }
} }
}
+2 -3
View File
@@ -9,8 +9,8 @@ using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.Core.Handler namespace Kruzya.TelegramBot.Core.Handler;
{
public abstract class CommonHandler : BotEventHandler public abstract class CommonHandler : BotEventHandler
{ {
protected readonly CoreContext Db; protected readonly CoreContext Db;
@@ -59,4 +59,3 @@ namespace Kruzya.TelegramBot.Core.Handler
await Bot.AnswerCallbackQueryAsync(id, message); await Bot.AnswerCallbackQueryAsync(id, message);
} }
} }
}
+2 -3
View File
@@ -6,8 +6,8 @@ using Kruzya.TelegramBot.Core.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core.Handler namespace Kruzya.TelegramBot.Core.Handler;
{
public class GeneralHandler : BotEventHandler public class GeneralHandler : BotEventHandler
{ {
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
@@ -73,4 +73,3 @@ namespace Kruzya.TelegramBot.Core.Handler
}); });
} }
} }
}
+2 -3
View File
@@ -3,8 +3,8 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Kruzya.TelegramBot.Core namespace Kruzya.TelegramBot.Core;
{
public abstract class Module public abstract class Module
{ {
protected readonly Core Core; protected readonly Core Core;
@@ -33,4 +33,3 @@ namespace Kruzya.TelegramBot.Core
return (T) Core.EnsureLoaded(typeof(T)); return (T) Core.EnsureLoaded(typeof(T));
} }
} }
}
+2 -3
View File
@@ -2,8 +2,8 @@ using System.Globalization;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
namespace Kruzya.TelegramBot.Core namespace Kruzya.TelegramBot.Core;
{
public class Program public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
@@ -17,4 +17,3 @@ namespace Kruzya.TelegramBot.Core
.UseSystemd() .UseSystemd()
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
} }
}
+2 -3
View File
@@ -5,8 +5,8 @@ using BotFramework.Abstractions;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace Kruzya.TelegramBot.Core.Service namespace Kruzya.TelegramBot.Core.Service;
{
public abstract class AbstractTimedHostedService : IHostedService, IDisposable public abstract class AbstractTimedHostedService : IHostedService, IDisposable
{ {
private Timer _timer; private Timer _timer;
@@ -71,4 +71,3 @@ namespace Kruzya.TelegramBot.Core.Service
await Task.Delay(500); await Task.Delay(500);
} }
} }
}
+2 -3
View File
@@ -3,8 +3,8 @@ using System.Threading.Tasks;
using Kruzya.TelegramBot.Core.Data; using Kruzya.TelegramBot.Core.Data;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core.Service namespace Kruzya.TelegramBot.Core.Service;
{
public interface IReputation public interface IReputation
{ {
public Task<double> GetUserReputationAsync(Chat chat, User user); public Task<double> GetUserReputationAsync(Chat chat, User user);
@@ -13,4 +13,3 @@ namespace Kruzya.TelegramBot.Core.Service
public Task<double> IncrementReputationAsync(Chat chat, User user, double diff); public Task<double> IncrementReputationAsync(Chat chat, User user, double diff);
public Task<IEnumerable<IReputationEntity>> GetChatRatingAsync(Chat chat, int limit = 10, int offset = 0); public Task<IEnumerable<IReputationEntity>> GetChatRatingAsync(Chat chat, int limit = 10, int offset = 0);
} }
}
+2 -3
View File
@@ -11,8 +11,8 @@ using Microsoft.Extensions.Logging;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core.Service namespace Kruzya.TelegramBot.Core.Service;
{
public class UserService public class UserService
{ {
private readonly List<long> _superUsers; private readonly List<long> _superUsers;
@@ -88,4 +88,3 @@ namespace Kruzya.TelegramBot.Core.Service
return _statusMap.ContainsKey(userId) ? _statusMap[userId] : null; return _statusMap.ContainsKey(userId) ? _statusMap[userId] : null;
} }
} }
}
+2 -3
View File
@@ -14,8 +14,8 @@ using System.Collections.Concurrent;
using Kruzya.TelegramBot.Core.Options; using Kruzya.TelegramBot.Core.Options;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core namespace Kruzya.TelegramBot.Core;
{
public class Startup public class Startup
{ {
private Core _core; private Core _core;
@@ -67,4 +67,3 @@ namespace Kruzya.TelegramBot.Core
_core.Modules.Configure(app, env); _core.Modules.Configure(app, env);
} }
} }
}
+2 -3
View File
@@ -6,8 +6,8 @@ using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using West.TelegramBot.ChatQuotes.Json; using West.TelegramBot.ChatQuotes.Json;
namespace West.TelegramBot.ChatQuotes namespace West.TelegramBot.ChatQuotes;
{
public class ChatQuotes : Module public class ChatQuotes : Module
{ {
public static readonly JsonSerializerSettings SerializerSettings = new() public static readonly JsonSerializerSettings SerializerSettings = new()
@@ -29,4 +29,3 @@ namespace West.TelegramBot.ChatQuotes
services.AddSingleton<QuoteGeneratorService>(); services.AddSingleton<QuoteGeneratorService>();
} }
} }
}
@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
namespace West.TelegramBot.ChatQuotes.Json namespace West.TelegramBot.ChatQuotes.Json;
{
class NullToEmptyObjectResolver : DefaultContractResolver class NullToEmptyObjectResolver : DefaultContractResolver
{ {
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization) protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
@@ -15,4 +15,3 @@ namespace West.TelegramBot.ChatQuotes.Json
}).ToList(); }).ToList();
} }
} }
}
+2 -3
View File
@@ -4,8 +4,8 @@ using Microsoft.Extensions.DependencyInjection;
using West.TelegramBot.CodeWatcher.Options; using West.TelegramBot.CodeWatcher.Options;
using West.TelegramBot.CodeWatcher.Service; using West.TelegramBot.CodeWatcher.Service;
namespace West.TelegramBot.CodeWatcher namespace West.TelegramBot.CodeWatcher;
{
public class CodeWatcher : Module public class CodeWatcher : Module
{ {
public CodeWatcher(Core core) : base(core) {} public CodeWatcher(Core core) : base(core) {}
@@ -20,4 +20,3 @@ namespace West.TelegramBot.CodeWatcher
}); });
} }
} }
}
@@ -6,7 +6,6 @@ using BotFramework.Enums;
using Kruzya.TelegramBot.CombotAntiSpam.Combot; using Kruzya.TelegramBot.CombotAntiSpam.Combot;
using Kruzya.TelegramBot.Core.Extensions; using Kruzya.TelegramBot.Core.Extensions;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.CombotAntiSpam; namespace Kruzya.TelegramBot.CombotAntiSpam;
@@ -1,10 +1,9 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
{
public interface IXurPlaceProvider public interface IXurPlaceProvider
{ {
public Task<string> GetPlaceAsync(); public Task<string> GetPlaceAsync();
public string GetPlace(); public string GetPlace();
} }
}
@@ -2,8 +2,8 @@ using System.Threading.Tasks;
using Fizzler.Systems.HtmlAgilityPack; using Fizzler.Systems.HtmlAgilityPack;
using HtmlAgilityPack; using HtmlAgilityPack;
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
{
public class XurWiki : IXurPlaceProvider public class XurWiki : IXurPlaceProvider
{ {
public async Task<string> GetPlaceAsync() public async Task<string> GetPlaceAsync()
@@ -25,4 +25,3 @@ namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider
return GetPlaceAsync().GetAwaiter().GetResult(); return GetPlaceAsync().GetAwaiter().GetResult();
} }
} }
}
@@ -5,8 +5,8 @@ using Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur namespace Kruzya.TelegramBot.Destiny2.WhereIsXur;
{
public class RequestHandler : BotEventHandler public class RequestHandler : BotEventHandler
{ {
protected readonly IXurPlaceProvider _placeProvider; protected readonly IXurPlaceProvider _placeProvider;
@@ -34,4 +34,3 @@ namespace Kruzya.TelegramBot.Destiny2.WhereIsXur
await Bot.SendTextMessageAsync(Chat, $"<b>Xûr</b> place is <code>{place}</code>", parseMode: ParseMode.Html); await Bot.SendTextMessageAsync(Chat, $"<b>Xûr</b> place is <code>{place}</code>", parseMode: ParseMode.Html);
} }
} }
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider; using Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur namespace Kruzya.TelegramBot.Destiny2.WhereIsXur;
{
public class WhereIsXur : Module public class WhereIsXur : Module
{ {
public WhereIsXur(Core.Core core) : base(core) public WhereIsXur(Core.Core core) : base(core)
@@ -15,4 +15,3 @@ namespace Kruzya.TelegramBot.Destiny2.WhereIsXur
services.AddSingleton<IXurPlaceProvider, XurWiki>(); services.AddSingleton<IXurPlaceProvider, XurWiki>();
} }
} }
}
+2 -3
View File
@@ -6,8 +6,8 @@ using Kruzya.TelegramBot.Core;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace West.Entertainment namespace West.Entertainment;
{
public class Entertainment : Module public class Entertainment : Module
{ {
public Entertainment(Core core) : base(core) { } public Entertainment(Core core) : base(core) { }
@@ -17,4 +17,3 @@ namespace West.Entertainment
services.AddSingleton<IGuessCache, GuessCache>(); services.AddSingleton<IGuessCache, GuessCache>();
} }
} }
}
+2 -3
View File
@@ -13,8 +13,8 @@ using Microsoft.Extensions.Logging;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace West.Entertainment.Handler namespace West.Entertainment.Handler;
{
public class Common : BotEventHandler public class Common : BotEventHandler
{ {
private readonly UserService _userService; private readonly UserService _userService;
@@ -61,4 +61,3 @@ namespace West.Entertainment.Handler
await Bot.SendTextMessageAsync(Chat.Id, msg.ToString(), parseMode: ParseMode.Html); await Bot.SendTextMessageAsync(Chat.Id, msg.ToString(), parseMode: ParseMode.Html);
} }
} }
}
@@ -11,8 +11,8 @@ using Microsoft.Extensions.Logging;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace West.Entertainment.Handler.Fun namespace West.Entertainment.Handler.Fun;
{
public abstract class AbstractAnimationReply : BotEventHandler public abstract class AbstractAnimationReply : BotEventHandler
{ {
private readonly CoreContext _db; private readonly CoreContext _db;
@@ -105,4 +105,3 @@ namespace West.Entertainment.Handler.Fun
protected virtual int? GetMessageIdToReply() => Message?.MessageId; protected virtual int? GetMessageIdToReply() => Message?.MessageId;
} }
}
+2 -3
View File
@@ -10,8 +10,8 @@ using Kruzya.TelegramBot.Core.Data;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Telegram.Bot; using Telegram.Bot;
namespace West.Entertainment.Handler.Fun namespace West.Entertainment.Handler.Fun;
{
public class Bayan : AbstractAnimationReply public class Bayan : AbstractAnimationReply
{ {
protected override TimeSpan Cooldown => TimeSpan.Zero; protected override TimeSpan Cooldown => TimeSpan.Zero;
@@ -48,4 +48,3 @@ namespace West.Entertainment.Handler.Fun
=> Message?.ReplyToMessage != null; => Message?.ReplyToMessage != null;
} }
}
@@ -6,8 +6,8 @@ using Kruzya.TelegramBot.Core;
using Kruzya.TelegramBot.Core.Data; using Kruzya.TelegramBot.Core.Data;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace West.Entertainment.Handler.Fun namespace West.Entertainment.Handler.Fun;
{
public class JavaScript : AbstractAnimationReply public class JavaScript : AbstractAnimationReply
{ {
public JavaScript(CoreContext db, ILogger<JavaScript> logger, ThreadSafeRandom rng) : base(db, logger, rng) { } public JavaScript(CoreContext db, ILogger<JavaScript> logger, ThreadSafeRandom rng) : base(db, logger, rng) { }
@@ -30,4 +30,3 @@ namespace West.Entertainment.Handler.Fun
await HandleAnimation(); await HandleAnimation();
} }
} }
}
+2 -3
View File
@@ -8,8 +8,8 @@ using Kruzya.TelegramBot.Core;
using Kruzya.TelegramBot.Core.Data; using Kruzya.TelegramBot.Core.Data;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace West.Entertainment.Handler.Fun namespace West.Entertainment.Handler.Fun;
{
public class Python : AbstractAnimationReply public class Python : AbstractAnimationReply
{ {
protected override Regex AnimationMatch => protected override Regex AnimationMatch =>
@@ -33,4 +33,3 @@ namespace West.Entertainment.Handler.Fun
public Python(CoreContext db, ILogger<Python> logger, ThreadSafeRandom rng) : base(db, logger, rng) { } public Python(CoreContext db, ILogger<Python> logger, ThreadSafeRandom rng) : base(db, logger, rng) { }
} }
}
+2 -3
View File
@@ -8,8 +8,8 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Kruzya.TelegramBot.RichSiteSummary.Data namespace Kruzya.TelegramBot.RichSiteSummary.Data;
{
/// <summary> /// <summary>
/// Represents a feed in database. /// Represents a feed in database.
/// </summary> /// </summary>
@@ -87,4 +87,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Data
public override string ToString() => Title; public override string ToString() => Title;
} }
}
+2 -3
View File
@@ -9,8 +9,8 @@ using System.Text;
using Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule; using Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.RichSiteSummary.Data namespace Kruzya.TelegramBot.RichSiteSummary.Data;
{
/// <summary> /// <summary>
/// Represents a post from feed in database. /// Represents a post from feed in database.
/// </summary> /// </summary>
@@ -104,4 +104,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Data
} }
} }
} }
}
@@ -7,8 +7,8 @@ using System;
using System.Web; using System.Web;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.RichSiteSummary.Data namespace Kruzya.TelegramBot.RichSiteSummary.Data;
{
/// <summary> /// <summary>
/// Implements the basic logic for rendering Database Entities in messages. /// Implements the basic logic for rendering Database Entities in messages.
/// </summary> /// </summary>
@@ -58,4 +58,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Data
#endregion #endregion
} }
}
@@ -1,8 +1,8 @@
using Kruzya.TelegramBot.Core.EF; using Kruzya.TelegramBot.Core.EF;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace Kruzya.TelegramBot.RichSiteSummary.Data namespace Kruzya.TelegramBot.RichSiteSummary.Data;
{
public class RichSiteSummaryContext : AutoSaveDbContext public class RichSiteSummaryContext : AutoSaveDbContext
{ {
/// <summary> /// <summary>
@@ -55,4 +55,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Data
.HasForeignKey(s => s.FeedId); .HasForeignKey(s => s.FeedId);
} }
} }
}
+2 -3
View File
@@ -6,8 +6,8 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Kruzya.TelegramBot.RichSiteSummary.Data namespace Kruzya.TelegramBot.RichSiteSummary.Data;
{
/// <summary> /// <summary>
/// Represents a subscription in database. /// Represents a subscription in database.
/// </summary> /// </summary>
@@ -53,4 +53,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Data
Feed = feed; Feed = feed;
} }
} }
}
@@ -1,8 +1,8 @@
using BotFramework; using BotFramework;
using Kruzya.TelegramBot.RichSiteSummary.Data; using Kruzya.TelegramBot.RichSiteSummary.Data;
namespace Kruzya.TelegramBot.RichSiteSummary.Handler namespace Kruzya.TelegramBot.RichSiteSummary.Handler;
{
public abstract class AbstractHandler : BotEventHandler public abstract class AbstractHandler : BotEventHandler
{ {
protected readonly RichSiteSummaryContext _dbContext; protected readonly RichSiteSummaryContext _dbContext;
@@ -12,4 +12,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
_dbContext = dbContext; _dbContext = dbContext;
} }
} }
}
+2 -3
View File
@@ -13,8 +13,8 @@ using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups; using Telegram.Bot.Types.ReplyMarkups;
namespace Kruzya.TelegramBot.RichSiteSummary.Handler namespace Kruzya.TelegramBot.RichSiteSummary.Handler;
{
public class FeedList : AbstractHandler public class FeedList : AbstractHandler
{ {
public FeedList(RichSiteSummaryContext dbContext) : base(dbContext) public FeedList(RichSiteSummaryContext dbContext) : base(dbContext)
@@ -308,4 +308,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
#endregion #endregion
} }
}
@@ -7,8 +7,8 @@ using Microsoft.EntityFrameworkCore;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.RichSiteSummary.Handler namespace Kruzya.TelegramBot.RichSiteSummary.Handler;
{
public class StatsHandler : AbstractHandler public class StatsHandler : AbstractHandler
{ {
public StatsHandler(RichSiteSummaryContext dbContext) : base(dbContext) public StatsHandler(RichSiteSummaryContext dbContext) : base(dbContext)
@@ -34,4 +34,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
await Bot.SendTextMessageAsync(Chat, textMessage.ToString(), parseMode: ParseMode.Html); await Bot.SendTextMessageAsync(Chat, textMessage.ToString(), parseMode: ParseMode.Html);
} }
} }
}
+2 -3
View File
@@ -7,8 +7,8 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Kruzya.TelegramBot.RichSiteSummary namespace Kruzya.TelegramBot.RichSiteSummary;
{
public class RichSiteSummary : Module public class RichSiteSummary : Module
{ {
public RichSiteSummary(Core.Core core) : base(core) public RichSiteSummary(Core.Core core) : base(core)
@@ -34,4 +34,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary
.AddHostedService<MessageSender>(); .AddHostedService<MessageSender>();
} }
} }
}
@@ -5,8 +5,8 @@ using Kruzya.TelegramBot.RichSiteSummary.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.RichSiteSummary namespace Kruzya.TelegramBot.RichSiteSummary;
{
internal static class RichSiteSummaryRepositoryExtension internal static class RichSiteSummaryRepositoryExtension
{ {
#region Subscriber #region Subscriber
@@ -69,4 +69,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary
#endregion #endregion
} }
}
@@ -9,8 +9,8 @@ using Telegram.Bot;
using Telegram.Bot.Exceptions; using Telegram.Bot.Exceptions;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.RichSiteSummary.Service namespace Kruzya.TelegramBot.RichSiteSummary.Service;
{
public class MessageSender : AbstractTimedHostedService public class MessageSender : AbstractTimedHostedService
{ {
protected override TimeSpan TimerPeriod => TimeSpan.FromSeconds(1); protected override TimeSpan TimerPeriod => TimeSpan.FromSeconds(1);
@@ -86,4 +86,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
Queue.Enqueue(message); Queue.Enqueue(message);
} }
} }
}
+2 -3
View File
@@ -20,8 +20,8 @@ using Feed = Kruzya.TelegramBot.RichSiteSummary.Data.Feed;
using CodeHollow.FeedReader.Feeds; using CodeHollow.FeedReader.Feeds;
namespace Kruzya.TelegramBot.RichSiteSummary.Service namespace Kruzya.TelegramBot.RichSiteSummary.Service;
{
/// <summary> /// <summary>
/// Performs a RSS feed parsing. /// Performs a RSS feed parsing.
/// Grabs the all feeds from database. /// Grabs the all feeds from database.
@@ -258,4 +258,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
#endregion #endregion
} }
}
@@ -9,8 +9,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.RichSiteSummary.Service namespace Kruzya.TelegramBot.RichSiteSummary.Service;
{
public class Unsubscriber : AbstractTimedHostedService public class Unsubscriber : AbstractTimedHostedService
{ {
protected readonly ConcurrentQueue<UserUnsubscribe> Queue; protected readonly ConcurrentQueue<UserUnsubscribe> Queue;
@@ -46,4 +46,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
await dbContext.SaveChangesAsync(); await dbContext.SaveChangesAsync();
} }
} }
}
@@ -1,5 +1,5 @@
namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule;
{
public struct UtmParameters public struct UtmParameters
{ {
public string Source; public string Source;
@@ -8,4 +8,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule
public string Term; public string Term;
public string Content; public string Content;
} }
}
@@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Web; using System.Web;
namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule;
{
public class UtmUtility public class UtmUtility
{ {
public static string ApplyParameters(string url, UtmParameters parameters) public static string ApplyParameters(string url, UtmParameters parameters)
@@ -48,4 +48,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary.UrchinTrackingModule
queryParameteters.Set(key, value); queryParameteters.Set(key, value);
} }
} }
}
+2 -3
View File
@@ -1,8 +1,8 @@
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.RichSiteSummary namespace Kruzya.TelegramBot.RichSiteSummary;
{
public struct UserMessage public struct UserMessage
{ {
public ChatId ChatId; public ChatId ChatId;
@@ -11,4 +11,3 @@ namespace Kruzya.TelegramBot.RichSiteSummary
public bool DisableWebPagePreview; public bool DisableWebPagePreview;
public string ImageUrl; public string ImageUrl;
} }
}
+2 -3
View File
@@ -1,9 +1,8 @@
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.RichSiteSummary namespace Kruzya.TelegramBot.RichSiteSummary;
{
public struct UserUnsubscribe public struct UserUnsubscribe
{ {
public ChatId ChatId; public ChatId ChatId;
} }
}
+2 -3
View File
@@ -5,8 +5,8 @@ using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.UrlLimitations namespace Kruzya.TelegramBot.UrlLimitations;
{
public static class MessageExtension public static class MessageExtension
{ {
public static async Task<bool> HasUnknownMention(this Message message, ITelegramBotClient bot) public static async Task<bool> HasUnknownMention(this Message message, ITelegramBotClient bot)
@@ -60,4 +60,3 @@ namespace Kruzya.TelegramBot.UrlLimitations
return false; return false;
} }
} }
}
+2 -3
View File
@@ -11,8 +11,8 @@ using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.UrlLimitations namespace Kruzya.TelegramBot.UrlLimitations;
{
public class MessageHandler : BotEventHandler public class MessageHandler : BotEventHandler
{ {
protected ILogger Logger; protected ILogger Logger;
@@ -56,4 +56,3 @@ namespace Kruzya.TelegramBot.UrlLimitations
} }
} }
} }
}
+2 -3
View File
@@ -1,11 +1,10 @@
using Kruzya.TelegramBot.Core; using Kruzya.TelegramBot.Core;
namespace Kruzya.TelegramBot.UrlLimitations namespace Kruzya.TelegramBot.UrlLimitations;
{
public class UrlLimitations : Module public class UrlLimitations : Module
{ {
public UrlLimitations(Core.Core core) : base(core) public UrlLimitations(Core.Core core) : base(core)
{ {
} }
} }
}
+2 -3
View File
@@ -6,8 +6,8 @@ using BotFramework.Enums;
using Kruzya.TelegramBot.Core.Data; using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Extensions; using Kruzya.TelegramBot.Core.Extensions;
namespace Kruzya.TelegramBot.UrlLimitations namespace Kruzya.TelegramBot.UrlLimitations;
{
public class UserJoinHandler : BotEventHandler public class UserJoinHandler : BotEventHandler
{ {
protected readonly CoreContext dbCtx; protected readonly CoreContext dbCtx;
@@ -26,4 +26,3 @@ namespace Kruzya.TelegramBot.UrlLimitations
0); 0);
} }
} }
}
+2 -3
View File
@@ -14,8 +14,8 @@ using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
namespace UserGroupTag namespace UserGroupTag;
{
public class Handler : BotEventHandler public class Handler : BotEventHandler
{ {
private readonly CoreContext _db; private readonly CoreContext _db;
@@ -104,4 +104,3 @@ namespace UserGroupTag
return user; return user;
} }
} }
}
+2 -3
View File
@@ -1,9 +1,8 @@
using Kruzya.TelegramBot.Core; using Kruzya.TelegramBot.Core;
namespace UserGroupTag namespace UserGroupTag;
{
public class UserGroupTag : Module public class UserGroupTag : Module
{ {
public UserGroupTag(Core core) : base(core) { } public UserGroupTag(Core core) : base(core) { }
} }
}