mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-01-21 00:56:09 +03:00
Usings and namespace cleanup
This commit is contained in:
parent
d2e8ed4d69
commit
2cc286ad9c
@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Perfusion;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using NLog;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
class AwardCommand : IChatCommand
|
||||
{
|
||||
public IReadOnlyCollection<string> Names => new[] { "award", "revoke" };
|
||||
@ -159,4 +154,3 @@ namespace JetKarmaBot.Commands
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Perfusion;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using NLog;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
class LocaleCommand : IChatCommand
|
||||
{
|
||||
public IReadOnlyCollection<string> Names => new[] { "changelocale", "locale" };
|
||||
@ -77,4 +73,3 @@ namespace JetKarmaBot.Commands
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
public class CommandString
|
||||
{
|
||||
public CommandString(string command, params string[] parameters)
|
||||
@ -48,4 +46,3 @@ namespace JetKarmaBot.Commands
|
||||
throw new ArgumentException($"\"{s}\" is not a command");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Perfusion;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
public class CurrenciesCommand : IChatCommand
|
||||
{
|
||||
[Inject] Localization Locale { get; set; }
|
||||
@ -30,4 +26,3 @@ namespace JetKarmaBot.Commands
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Perfusion;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
using System.Threading.Tasks;
|
||||
using JetKarmaBot.Models;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
public class HelpCommand : IChatCommand
|
||||
{
|
||||
[Inject] Localization Locale { get; set; }
|
||||
@ -41,4 +36,3 @@ namespace JetKarmaBot.Commands
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
public interface IChatCommand
|
||||
{
|
||||
IReadOnlyCollection<string> Names { get; }
|
||||
@ -29,4 +27,3 @@ namespace JetKarmaBot.Commands
|
||||
String,
|
||||
Integer,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Perfusion;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
class LeaderboardCommand : IChatCommand
|
||||
{
|
||||
public IReadOnlyCollection<string> Names => new[] { "leaderboard" };
|
||||
@ -67,4 +63,3 @@ namespace JetKarmaBot.Commands
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Perfusion;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Commands
|
||||
{
|
||||
namespace JetKarmaBot.Commands;
|
||||
|
||||
class StatusCommand : IChatCommand
|
||||
{
|
||||
public IReadOnlyCollection<string> Names => ["status"];
|
||||
@ -53,4 +49,3 @@ namespace JetKarmaBot.Commands
|
||||
|
||||
public IReadOnlyCollection<ChatCommandArgument> Arguments => [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,10 +2,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using JsonNet.PrivateSettersContractResolvers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JetKarmaBot
|
||||
{
|
||||
namespace JetKarmaBot;
|
||||
|
||||
public class Config : ConfigBase
|
||||
{
|
||||
public Config(string path) : base(path) { }
|
||||
@ -74,5 +73,4 @@ namespace JetKarmaBot
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
namespace JetKarmaBot;
|
||||
|
||||
namespace JetKarmaBot
|
||||
{
|
||||
public static class IReadOnlyDictionaryExtensions
|
||||
{
|
||||
public static TValue GetOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dict, TKey key)
|
||||
{
|
||||
TValue res = default(TValue);
|
||||
TValue res = default;
|
||||
if (key != null)
|
||||
dict.TryGetValue(key, out res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace JsonNet.PrivateSettersContractResolvers
|
||||
{
|
||||
namespace JsonNet.PrivateSettersContractResolvers;
|
||||
|
||||
public class PrivateSetterContractResolver : DefaultContractResolver
|
||||
{
|
||||
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
|
||||
@ -42,4 +42,3 @@ namespace JsonNet.PrivateSettersContractResolvers
|
||||
return property?.GetSetMethod(true) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
6
JetKarmaBot/GlobalUsings.cs
Normal file
6
JetKarmaBot/GlobalUsings.cs
Normal file
@ -0,0 +1,6 @@
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Linq;
|
||||
global using System.Threading;
|
||||
global using System.Threading.Tasks;
|
||||
global using Perfusion;
|
||||
@ -3,18 +3,14 @@ using JetKarmaBot.Models;
|
||||
using JetKarmaBot.Services;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using NLog;
|
||||
using Perfusion;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Polling;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace JetKarmaBot
|
||||
{
|
||||
namespace JetKarmaBot;
|
||||
|
||||
public class JetKarmaBot : IDisposable
|
||||
{
|
||||
[Inject] Config Config { get; set; }
|
||||
@ -139,4 +135,3 @@ namespace JetKarmaBot
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Models
|
||||
{
|
||||
public partial class Award
|
||||
{
|
||||
public int AwardId { get; set; }
|
||||
@ -22,4 +20,3 @@ namespace JetKarmaBot.Models
|
||||
[ForeignKey("ToId")]
|
||||
public virtual User To { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Models
|
||||
{
|
||||
public partial class AwardType
|
||||
{
|
||||
public AwardType()
|
||||
@ -18,4 +15,3 @@ namespace JetKarmaBot.Models
|
||||
|
||||
public virtual ICollection<Award> Awards { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Models
|
||||
{
|
||||
public partial class Chat
|
||||
{
|
||||
public Chat()
|
||||
@ -16,4 +13,3 @@ namespace JetKarmaBot.Models
|
||||
|
||||
public virtual ICollection<Award> Awards { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Perfusion;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Models
|
||||
{
|
||||
[Transient]
|
||||
public partial class KarmaContext : DbContext
|
||||
{
|
||||
@ -180,4 +177,3 @@ namespace JetKarmaBot.Models
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Models
|
||||
{
|
||||
public partial class User
|
||||
{
|
||||
public User()
|
||||
@ -20,4 +18,3 @@ namespace JetKarmaBot.Models
|
||||
[InverseProperty("To")]
|
||||
public virtual ICollection<Award> AwardsTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Threading;
|
||||
using JetKarmaBot.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using Perfusion;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot;
|
||||
|
||||
namespace JetKarmaBot
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
private static Logger log = LogManager.GetCurrentClassLogger();
|
||||
@ -76,4 +71,3 @@ namespace JetKarmaBot
|
||||
return (int)ExitCode.Ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
using JetKarmaBot.Commands;
|
||||
using NLog;
|
||||
using Perfusion;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Telegram.Bot;
|
||||
using JetKarmaBot.Commands;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling
|
||||
{
|
||||
public class ChatCommandRouter : IRequestHandler
|
||||
{
|
||||
public class Feature
|
||||
@ -108,4 +103,3 @@ namespace JetKarmaBot.Services.Handling
|
||||
|
||||
Dictionary<string, IChatCommand> commands = new Dictionary<string, IChatCommand>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Perfusion;
|
||||
namespace JetKarmaBot.Services.Handling;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling
|
||||
{
|
||||
public class DatabaseHandler : IRequestHandler
|
||||
{
|
||||
[Inject] private KarmaContextFactory Db;
|
||||
@ -20,4 +15,3 @@ namespace JetKarmaBot.Services.Handling
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Perfusion;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling
|
||||
{
|
||||
namespace JetKarmaBot.Services.Handling;
|
||||
|
||||
public interface IRequestHandler
|
||||
{
|
||||
Task Handle(RequestContext ctx, Func<RequestContext, Task> next);
|
||||
@ -39,4 +35,3 @@ namespace JetKarmaBot.Services.Handling
|
||||
handlerStack.Add(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using JetKarmaBot.Commands;
|
||||
using JetKarmaBot.Models;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Args;
|
||||
using Telegram.Bot.Types;
|
||||
using JetKarmaBot.Commands;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling
|
||||
{
|
||||
public class RequestContext : IServiceProvider
|
||||
{
|
||||
public ITelegramBotClient Client { get; }
|
||||
@ -36,4 +30,3 @@ namespace JetKarmaBot.Services.Handling
|
||||
replyParameters: new ReplyParameters { MessageId = EventArgs.Message.MessageId }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using JetKarmaBot.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling
|
||||
{
|
||||
public class SaveData : IRequestHandler
|
||||
{
|
||||
public async Task Handle(RequestContext ctx, Func<RequestContext, Task> next)
|
||||
@ -33,4 +31,3 @@ namespace JetKarmaBot.Services.Handling
|
||||
(await db.Users.FindAsync(u.Id)).Username = un;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,8 @@
|
||||
using Perfusion;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using JetKarmaBot.Models;
|
||||
using System.Threading;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using JetKarmaBot.Models;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling;
|
||||
|
||||
namespace JetKarmaBot.Services.Handling
|
||||
{
|
||||
[Singleton]
|
||||
public class TimeoutManager : IRequestHandler
|
||||
{
|
||||
@ -130,4 +124,3 @@ namespace JetKarmaBot.Services.Handling
|
||||
+ (t.GenericTypeArguments.Length > 0 ? "<" + string.Join(",", t.GenericTypeArguments.Select(getTypeName)) + ">" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,10 @@
|
||||
using JetKarmaBot.Models;
|
||||
using Perfusion;
|
||||
|
||||
namespace JetKarmaBot.Services
|
||||
{
|
||||
namespace JetKarmaBot.Services;
|
||||
|
||||
public class KarmaContextFactory
|
||||
{
|
||||
[Inject] IContainer C { get; set; }
|
||||
|
||||
public KarmaContext GetContext() => C.GetInstance<KarmaContext>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using Perfusion;
|
||||
|
||||
namespace JetKarmaBot
|
||||
{
|
||||
namespace JetKarmaBot;
|
||||
|
||||
public class Localization : IReadOnlyDictionary<string, Locale>
|
||||
{
|
||||
private Dictionary<string, Locale> locales = new Dictionary<string, Locale>();
|
||||
@ -168,4 +164,3 @@ namespace JetKarmaBot
|
||||
SerializationInfo info,
|
||||
StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Perfusion;
|
||||
|
||||
namespace JetKarmaBot
|
||||
{
|
||||
namespace JetKarmaBot;
|
||||
|
||||
public class LogInfo : ObjectInfo
|
||||
{
|
||||
public override ObjectInfo Clone() => new LogInfo();
|
||||
@ -19,4 +16,3 @@ namespace JetKarmaBot
|
||||
+ (t.GenericTypeArguments.Length > 0 ? "<" + string.Join(",", t.GenericTypeArguments.Select(getTypeName)) + ">" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog;
|
||||
using Perfusion;
|
||||
|
||||
namespace JetKarmaBot
|
||||
{
|
||||
namespace JetKarmaBot;
|
||||
|
||||
public class NLoggerFactory : ILoggerFactory
|
||||
{
|
||||
[Inject]
|
||||
@ -100,4 +98,3 @@ namespace JetKarmaBot
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user