diff --git a/PoGo.DiscordBot/Common/StringUtils.cs b/PoGo.DiscordBot/Common/StringUtils.cs index 0248cea..5180ea4 100644 --- a/PoGo.DiscordBot/Common/StringUtils.cs +++ b/PoGo.DiscordBot/Common/StringUtils.cs @@ -22,4 +22,4 @@ public static string ToLowerWithoutDiacritics(string text) return stringBuilder.ToString().Normalize(NormalizationForm.FormC); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Configuration/Options/ConfigurationOptions.cs b/PoGo.DiscordBot/Configuration/Options/ConfigurationOptions.cs index dec4439..5d135db 100644 --- a/PoGo.DiscordBot/Configuration/Options/ConfigurationOptions.cs +++ b/PoGo.DiscordBot/Configuration/Options/ConfigurationOptions.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Globalization; namespace PoGo.DiscordBot.Configuration.Options { @@ -14,6 +15,7 @@ public class GuildOptions { public string Name { get; set; } public ulong Id { get; set; } + public CultureInfo Language { get; set; } public bool IgnoreMention { get; set; } public string[] FreeRoles { get; set; } public ChannelOptions[] Channels { get; set; } @@ -43,4 +45,4 @@ public class GymInfoOptions public string Latitude { get; set; } public string Longitude { get; set; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Configuration/PokemonTeam.cs b/PoGo.DiscordBot/Configuration/PokemonTeam.cs index f7e12b4..622f9ef 100644 --- a/PoGo.DiscordBot/Configuration/PokemonTeam.cs +++ b/PoGo.DiscordBot/Configuration/PokemonTeam.cs @@ -6,4 +6,4 @@ public enum PokemonTeam Instinct, Valor } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Configuration/TeamRoleColors.cs b/PoGo.DiscordBot/Configuration/TeamRoleColors.cs index 0be326a..9ecfd29 100644 --- a/PoGo.DiscordBot/Configuration/TeamRoleColors.cs +++ b/PoGo.DiscordBot/Configuration/TeamRoleColors.cs @@ -20,4 +20,4 @@ public static Color GetColor(PokemonTeam team) } } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Dto/GymInfoDto.cs b/PoGo.DiscordBot/Dto/GymInfoDto.cs index 97879ee..7e8869e 100644 --- a/PoGo.DiscordBot/Dto/GymInfoDto.cs +++ b/PoGo.DiscordBot/Dto/GymInfoDto.cs @@ -6,4 +6,4 @@ public class GymInfoDto public string Latitude { get; set; } public string Longitude { get; set; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Dto/PlayerDto.cs b/PoGo.DiscordBot/Dto/PlayerDto.cs index 0280705..ddc59b8 100644 --- a/PoGo.DiscordBot/Dto/PlayerDto.cs +++ b/PoGo.DiscordBot/Dto/PlayerDto.cs @@ -11,4 +11,4 @@ public class PlayerDto public override string ToString() => User.Nickname ?? User.Username; } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Dto/RaidBossDto.cs b/PoGo.DiscordBot/Dto/RaidBossDto.cs index 7c93b55..8713e38 100644 --- a/PoGo.DiscordBot/Dto/RaidBossDto.cs +++ b/PoGo.DiscordBot/Dto/RaidBossDto.cs @@ -11,4 +11,4 @@ public class RaidBossDto public string[] ChargeAttacks { get; set; } public string[] Counters { get; set; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Dto/RaidChannelBindingDto.cs b/PoGo.DiscordBot/Dto/RaidChannelBindingDto.cs index 5079466..bc572fd 100644 --- a/PoGo.DiscordBot/Dto/RaidChannelBindingDto.cs +++ b/PoGo.DiscordBot/Dto/RaidChannelBindingDto.cs @@ -8,4 +8,4 @@ public class RaidChannelBindingDto public IMentionable Mention { get; set; } public bool AllowScheduledRaids { get; set; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Dto/RaidInfoDto.cs b/PoGo.DiscordBot/Dto/RaidInfoDto.cs index 3a7691d..c46bb75 100644 --- a/PoGo.DiscordBot/Dto/RaidInfoDto.cs +++ b/PoGo.DiscordBot/Dto/RaidInfoDto.cs @@ -1,5 +1,6 @@ using Discord; using PoGo.DiscordBot.Configuration; +using PoGo.DiscordBot.Properties; using System; using System.Collections.Generic; using System.Linq; @@ -58,36 +59,36 @@ Color GetColor() EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder .WithColor(GetColor()) - .AddInlineField("Boss", BossName) - .AddInlineField("Kde", Location) - .AddInlineField(RaidType == RaidType.Normal ? "Čas" : "Datum", DateTimeAsString) + .AddInlineField(Resources.Boss, BossName) + .AddInlineField(Resources.Where, Location) + .AddInlineField(RaidType == RaidType.Normal ? Resources.Time : Resources.Date, DateTimeAsString) ; - if (Players.Any()) + if (Players.Count > 0) { string playerFieldValue = Players.Count >= 10 ? PlayersToGroupString(Players.Values) : PlayersToString(Players.Values); - embedBuilder.AddField($"Hráči ({Players.Count})", playerFieldValue); + embedBuilder.AddField(Resources.Players + $"({Players.Count})", playerFieldValue); } - if (ExtraPlayers.Any()) + if (ExtraPlayers.Count > 0) { string extraPlayersFieldValue = string.Join(" + ", ExtraPlayers.Select(t => t.Count)); - embedBuilder.AddField($"Další hráči (bez Discordu, 2. mobil atd.) ({ExtraPlayers.Sum(t => t.Count)})", extraPlayersFieldValue); + embedBuilder.AddField(Resources.OtherPlayers + $"({ExtraPlayers.Sum(t => t.Count)})", extraPlayersFieldValue); } return embedBuilder.Build(); } - public string ToSimpleString() => $"{BossName} {Location} {DateTimeAsString}"; + public string ToSimpleString() => $"{BossName} {Location} {DateTimeAsString}"; string PlayersToString(IEnumerable players) => string.Join(", ", players); string PlayersToGroupString(IEnumerable allPlayers) { - string TeamToString(PokemonTeam? team) => team != null ? team.ToString() : "Bez teamu"; + string TeamToString(PokemonTeam? team) => team != null ? team.ToString() : Resources.WithoutTeam; List formatterGroupedPlayers = new List(); @@ -95,14 +96,14 @@ string PlayersToGroupString(IEnumerable allPlayers) foreach (PokemonTeam? team in teams) { var players = allPlayers.Where(t => t.Team == team).ToList(); - if (players.Any()) + if (players.Count > 0) formatterGroupedPlayers.Add($"{TeamToString(team)} ({players.Count}) - {PlayersToString(players)}"); } return string.Join(Environment.NewLine, formatterGroupedPlayers); } - public static DateTime? ParseTime(string time) => ParseTime(time, DateTime.Now.Date); + public static DateTime? ParseTime(string time) => ParseTime(time, DateTime.Now.Date); public static DateTime? ParseTime(string time, DateTime date) { @@ -140,7 +141,7 @@ public static RaidInfoDto Parse(IUserMessage message) RaidInfoDto result = null; - if (embed.Fields[2].Name == "Čas") + if (embed.Fields[2].Name.Equals(Resources.Time, StringComparison.OrdinalIgnoreCase)) { var time = ParseTime(embed.Fields[2].Value, message.CreatedAt.Date); if (!time.HasValue) @@ -155,7 +156,7 @@ public static RaidInfoDto Parse(IUserMessage message) DateTime = time.Value, }; } - else if (embed.Fields[2].Name == "Datum") + else if (embed.Fields[2].Name.Equals(Resources.Date, StringComparison.OrdinalIgnoreCase)) { var dateTime = ParseDateTime(embed.Fields[2].Value); if (!dateTime.HasValue) @@ -174,4 +175,4 @@ public static RaidInfoDto Parse(IUserMessage message) return result; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Dto/TeamRolesDto.cs b/PoGo.DiscordBot/Dto/TeamRolesDto.cs index 98b9138..6cadfea 100644 --- a/PoGo.DiscordBot/Dto/TeamRolesDto.cs +++ b/PoGo.DiscordBot/Dto/TeamRolesDto.cs @@ -9,4 +9,4 @@ public class TeamRolesDto public IReadOnlyDictionary RoleTeams { get; set; } // public IReadOnlyDictionary TeamRoles { get; set; } // } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Emojis.cs b/PoGo.DiscordBot/Emojis.cs index 2595c2c..570c5af 100644 --- a/PoGo.DiscordBot/Emojis.cs +++ b/PoGo.DiscordBot/Emojis.cs @@ -9,7 +9,6 @@ internal class UnicodeEmojis public const string ThumbsDown = "👎"; public const string Check = "✅"; public const string Cross = "❌"; - const char Border = '⃣'; public static readonly string[] KeycapDigits; @@ -35,4 +34,4 @@ static Emojis() KeycapDigits = UnicodeEmojis.KeycapDigits.Select(t => new Emoji(t)).ToArray(); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Localizing.txt b/PoGo.DiscordBot/Localizing.txt new file mode 100644 index 0000000..df0bacb --- /dev/null +++ b/PoGo.DiscordBot/Localizing.txt @@ -0,0 +1,8 @@ +If you wish to support the PoGo Discord bot in +your native language, create a pull request. +The easiest way to add a new .resx file is to +use the Zeta Resource Editor at +https://archive.codeplex.com/?p=ZetaResourceEditor and make a pull request. + + +Thank you for wanting to contribute additional languages. \ No newline at end of file diff --git a/PoGo.DiscordBot/LogSeverityExtensions.cs b/PoGo.DiscordBot/LogSeverityExtensions.cs index 6edcf18..0c54eba 100644 --- a/PoGo.DiscordBot/LogSeverityExtensions.cs +++ b/PoGo.DiscordBot/LogSeverityExtensions.cs @@ -26,4 +26,4 @@ public static LogLevel ToLogLevel(this LogSeverity logSeverity) } } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/BlameModule.cs b/PoGo.DiscordBot/Modules/BlameModule.cs index 7c50f3d..5f44692 100644 --- a/PoGo.DiscordBot/Modules/BlameModule.cs +++ b/PoGo.DiscordBot/Modules/BlameModule.cs @@ -41,4 +41,4 @@ public async Task ListPlayersWithoutTeam() await ReplyAsync($"`{message}`"); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/CleanModule.cs b/PoGo.DiscordBot/Modules/CleanModule.cs index 2a51813..c281c4e 100644 --- a/PoGo.DiscordBot/Modules/CleanModule.cs +++ b/PoGo.DiscordBot/Modules/CleanModule.cs @@ -1,5 +1,6 @@ using Discord; using Discord.Commands; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -9,25 +10,25 @@ namespace PoGo.DiscordBot.Modules public class CleanModule : ModuleBase { [Command("hardclean", RunMode = RunMode.Async)] - [Summary("Smaže všechny zprávy (omezeno počtem).")] - public async Task FullClean([Summary("Počet zpráv.")]int count = 10) + [Summary("DeleteAllMessagesSummary")] + public async Task FullClean([Summary("MessageNumber")]int count = 10) { - var batchMessages = AsyncEnumerable.ToEnumerable(Context.Channel.GetMessagesAsync(count)); + var batchMessages = AsyncEnumerable.ToEnumerable(Context.Channel.GetMessagesAsync(count)); foreach (var messages in batchMessages) await Context.Channel.DeleteMessagesAsync(messages); } [Command("clean", RunMode = RunMode.Async)] - [Summary("Smaže tvoje zprávy (omezeno počtem).")] - public async Task DeleteLastMessagesFromCurrentUser([Summary("Počet zpráv.")]int count = 5) + [Summary("DeleteYourMessageSummary")] + public async Task DeleteLastMessagesFromCurrentUser([Summary("MessageNumber")]int count = 5) { await DeleteMessagesAsync(Context.User.Id, count); } [Command("clean", RunMode = RunMode.Async)] - [Summary("Smaže zprávy označeného uživatele (omezeno počtem).")] - public async Task DeleteLastMessages([Summary("Uživatel.")]IUser user, - [Summary("Počet zpráv.")]int count = 5) + [Summary("DeleteLastMessageSummary")] + public async Task DeleteLastMessages([Summary("User")]IUser user, + [Summary("MessageNumber")]int count = 5) { ulong userId = user != null ? user.Id : Context.User.Id; @@ -36,7 +37,7 @@ public async Task DeleteLastMessages([Summary("Uživatel.")]IUser user, async Task DeleteMessagesAsync(ulong userId, int count) { - foreach (var messages in AsyncEnumerable.ToEnumerable(Context.Channel.GetMessagesAsync())) + foreach (var messages in Context.Channel.GetMessagesAsync().ToEnumerable()) { var messagesToDelete = messages.Where(t => t.Author.Id == userId).Take(count); if (messagesToDelete != null) @@ -44,4 +45,4 @@ async Task DeleteMessagesAsync(ulong userId, int count) } } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/DiagnosticModule.cs b/PoGo.DiscordBot/Modules/DiagnosticModule.cs index 75ec253..fe71b45 100644 --- a/PoGo.DiscordBot/Modules/DiagnosticModule.cs +++ b/PoGo.DiscordBot/Modules/DiagnosticModule.cs @@ -36,4 +36,4 @@ public async Task ProcessInfo() await ReplyAsync(string.Empty, embed: embedBuilder.Build()); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/HelpModule.cs b/PoGo.DiscordBot/Modules/HelpModule.cs index ba344c7..c3f8f72 100644 --- a/PoGo.DiscordBot/Modules/HelpModule.cs +++ b/PoGo.DiscordBot/Modules/HelpModule.cs @@ -3,8 +3,10 @@ using Discord.Commands; using Microsoft.Extensions.Options; using PoGo.DiscordBot.Configuration.Options; +using PoGo.DiscordBot.Properties; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -16,6 +18,8 @@ public class HelpModule : InteractiveBase readonly CommandService commandService; readonly IServiceProvider serviceProvider; readonly char prefix; + //TODO Load the current culture info from guild + readonly CultureInfo cultureInfo = CultureInfo.GetCultureInfo("cs-CS"); public HelpModule(CommandService commandService, IServiceProvider serviceProvider, IOptions config) { @@ -25,7 +29,7 @@ public HelpModule(CommandService commandService, IServiceProvider serviceProvide } [Command("help")] - [Summary("Vypíše seznam příkazů.")] + [Summary("ListCommandsSummary")] public async Task Help() { var groupCommands = new Dictionary>(); @@ -41,9 +45,9 @@ public async Task Help() var result = await cmd.CheckPreconditionsAsync(Context, serviceProvider); if (result.IsSuccess) { - string s = $"{prefix}{cmd.Aliases.First()}"; + string s = $"{prefix}{cmd.Aliases[0]}"; if (!string.IsNullOrEmpty(cmd.Summary)) - s += $" ({ cmd.Summary})"; + s += $" ({ Resources.ResourceManager.GetString(cmd.Summary,cultureInfo)})"; commands.Add(s); } @@ -64,7 +68,7 @@ string CommandsToString(IEnumerable commands) => foreach (var c in groupCommands.OrderBy(t => t.Key)) { - if (c.Key == string.Empty) continue; + if (c.Key?.Length == 0) continue; // future hint for division // c.Value.Count / MaxCommandsPerPage > 1 ... then divide it into N pages @@ -79,11 +83,12 @@ string CommandsToString(IEnumerable commands) => currentPageCommands.AddRange(c.Value); } - if (currentPageCommands.Any()) + if (currentPageCommands.Count > 0) commandPages.Add(currentPageCommands); var pages = commandPages.Select(CommandsToString).ToList(); if (pages.Count > 1) + { await PagedReplyAsync(new PaginatedMessage { Color = Color.Blue, @@ -93,11 +98,12 @@ await PagedReplyAsync(new PaginatedMessage DisplayInformationIcon = false, Timeout = TimeSpan.FromMinutes(1), }, - Title = "Dostupné příkazy", + Title = Resources.AllCommands, Pages = pages, }); - else if (pages.Any()) - await ReplyAsync($"```{pages.First()}```"); + } + else if (pages.Count > 0) + await ReplyAsync($"```{pages[0]}```"); } private enum CommandInfoSignature @@ -107,14 +113,16 @@ private enum CommandInfoSignature } [Command("help")] - [Summary("Vypíše nápovědu pro konkrétní příkaz.")] + [Summary("HelpSummary")] public async Task Help([Remainder] string command) { var result = commandService.Search(Context, command); if (!result.IsSuccess) { - await ReplyAsync($"Žádný příkaz **{command}** jsem nemohl najít."); + string reply = string.Format(Resources.CommandNotFound, command); + + await ReplyAsync(reply); return; } @@ -130,13 +138,13 @@ string ParameterInfoToDetailedString(ParameterInfo info) sb.Append(info.Name); if (!string.IsNullOrEmpty(info.Summary)) - sb.Append($" - {info.Summary}"); + sb.Append($" - {Resources.ResourceManager.GetString(info.Summary,cultureInfo)}"); if (info.Type.IsEnum) - sb.Append($" Možné jsou jenom tyhle hodnoty ({string.Join(" | ", Enum.GetNames(info.Type))})!"); + sb.Append(Resources.PossibleValues + $" ({string.Join(" | ", Enum.GetNames(info.Type))})!"); if (info.IsOptional) - sb.Append($" (Volitelný, výchozí hodnota je {info.DefaultValue})"); + sb.Append(Resources.Optional + $" ({info.DefaultValue})"); return sb.ToString(); } @@ -145,11 +153,11 @@ string CommandInfoSignature(CommandInfo ci, CommandInfoSignature signature) { StringBuilder sb = new StringBuilder() .Append(prefix) - .Append(ci.Aliases.First()); + .Append(ci.Aliases[0]); string FormatParameter(ParameterInfo pi) => $"<{pi.Name}>"; - if (ci.Parameters.Any()) + if (ci.Parameters.Count > 0) { var parameters = ci.Parameters.AsEnumerable(); @@ -166,29 +174,29 @@ string CommandInfoSignature(CommandInfo ci, CommandInfoSignature signature) { var cmd = match.Command; StringBuilder sb = new StringBuilder() - .AppendLine($"Popis: {cmd.Summary}") + .Append(Resources.Description).Append(':').AppendLine(cmd.Summary) .AppendLine() - .AppendLine($"Základní použití: **{CommandInfoSignature(cmd, HelpModule.CommandInfoSignature.Basic)}**"); + .Append(Resources.BasicUse).Append(":**").Append(CommandInfoSignature(cmd, HelpModule.CommandInfoSignature.Basic)).AppendLine("**"); if (cmd.Parameters.Any(t => t.IsOptional)) - sb.AppendLine($"Plné použití: {CommandInfoSignature(cmd, HelpModule.CommandInfoSignature.Full)}"); + sb.AppendLine(Resources.FullUse + $": {CommandInfoSignature(cmd, HelpModule.CommandInfoSignature.Full)}"); sb.AppendLine(); - if (cmd.Parameters.Any()) + if (cmd.Parameters.Count > 0) { string parameters = string.Join(", ", cmd.Parameters.Select(ParameterInfoToString)); string detailedParameters = string.Join(Environment.NewLine, cmd.Parameters.Select(ParameterInfoToDetailedString)); sb - .AppendLine($"Parametry: {parameters}") - .AppendLine("Popis parametrů:") + .Append(Resources.Parameters).Append(": ").AppendLine(parameters) + .AppendLine(Resources.ParameterDescription) .AppendLine(detailedParameters); } - builder.AddField($"Příkaz{(cmd.Aliases.Count > 1 ? "y" : "")}: {string.Join(", ", cmd.Aliases)}", sb); + builder.AddField(Resources.Command + $"{(cmd.Aliases.Count > 1 ? "y" : "")}: {string.Join(", ", cmd.Aliases)}", sb); } await ReplyAsync(string.Empty, false, builder.Build()); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/InfoModule.cs b/PoGo.DiscordBot/Modules/InfoModule.cs index 77e40b5..07c9b35 100644 --- a/PoGo.DiscordBot/Modules/InfoModule.cs +++ b/PoGo.DiscordBot/Modules/InfoModule.cs @@ -2,6 +2,7 @@ using Discord.Commands; using Microsoft.Extensions.Options; using PoGo.DiscordBot.Configuration.Options; +using PoGo.DiscordBot.Properties; using System; using System.Threading.Tasks; @@ -50,7 +51,7 @@ public async Task Contribute() [Command("donate", RunMode = RunMode.Async)] public async Task Donate() { - await ReplyAsync("V případě, že byste chtěli podpořit vývoj, tak se ozvěte Pako#3904"); + await ReplyAsync(Resources.SupportDevelopment); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/InviteModule.cs b/PoGo.DiscordBot/Modules/InviteModule.cs index 522a82a..78d5a46 100644 --- a/PoGo.DiscordBot/Modules/InviteModule.cs +++ b/PoGo.DiscordBot/Modules/InviteModule.cs @@ -1,5 +1,9 @@ using Discord.Commands; +using Discord.Rest; +using Discord.WebSocket; using Microsoft.Extensions.Logging; +using PoGo.DiscordBot.Properties; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -17,7 +21,7 @@ public InviteModule(ILogger logger) [Command("invite")] [Alias("inv")] - [Summary("Vrátí odkaz s pozvánkou sem na Discord.")] + [Summary("InviteSummary")] public async Task Invite() { var invites = await Context.Guild.GetInvitesAsync(); @@ -32,7 +36,7 @@ public async Task Invite() if (defaultChannel == null) { - await ReplyAsync("Sorry, žádný tu nemám :("); + await ReplyAsync("Sorry," + Resources.NoDefaultChannel + ":("); return; } @@ -43,4 +47,4 @@ public async Task Invite() await ReplyAsync(invite.Url); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/LanguageModule.cs b/PoGo.DiscordBot/Modules/LanguageModule.cs new file mode 100644 index 0000000..6971f7e --- /dev/null +++ b/PoGo.DiscordBot/Modules/LanguageModule.cs @@ -0,0 +1,20 @@ +using Discord.Commands; +using Microsoft.Extensions.Logging; +using PoGo.DiscordBot.Services; + +namespace PoGo.DiscordBot.Modules +{ + //TODO Add a command to support changing the language in the config + public class LanguageModule : ModuleBase + { + readonly ILogger logger; + readonly ConfigurationService configService; + + public LanguageModule(ILogger logger + , ConfigurationService configService) + { + this.logger = logger; + this.configService = configService; + } + } +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/LogsModule.cs b/PoGo.DiscordBot/Modules/LogsModule.cs index bffe388..a4f7aaa 100644 --- a/PoGo.DiscordBot/Modules/LogsModule.cs +++ b/PoGo.DiscordBot/Modules/LogsModule.cs @@ -1,6 +1,7 @@ using Discord; using Discord.Commands; using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -47,7 +48,7 @@ public async Task GetLog(string filename) { string path = Path.Combine(LogDirectory, filename); if (!File.Exists(path)) - { + { await ReplyAsync("Log does not exists."); return; } @@ -55,4 +56,4 @@ public async Task GetLog(string filename) await Context.Channel.SendFileAsync(path); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/PlayerModule.cs b/PoGo.DiscordBot/Modules/PlayerModule.cs index 375585e..e09de57 100644 --- a/PoGo.DiscordBot/Modules/PlayerModule.cs +++ b/PoGo.DiscordBot/Modules/PlayerModule.cs @@ -2,6 +2,7 @@ using Discord.WebSocket; using PoGo.DiscordBot.Configuration; using PoGo.DiscordBot.Modules.Preconditions; +using PoGo.DiscordBot.Properties; using PoGo.DiscordBot.Services; using System.Threading.Tasks; @@ -20,27 +21,26 @@ public PlayerModule(UserService userService, TeamService teamService) } [Command("team")] - [Summary("Zkontroluje zda má uživatel nastavený team. Jestliže ne, tak mu přijde zpráva s informacemi jak ho nastavit.")] + [Summary("CheckTeamSummary")] public async Task CheckTeam( - [Summary("Kontrolovaný uživatel.")]SocketGuildUser user) + [Summary("ControlledUser")]SocketGuildUser user) { await userService.CheckTeam(user); } [Command("team", RunMode = RunMode.Async)] - [Summary("Nastaví team.")] + [Summary("SetTeamSummary")] public async Task SetTeam( - [Summary("Zvolený team (roli).")]PokemonTeam team) + [Summary("SelectedTeam")]PokemonTeam team) { var contextUser = Context.User; - var user = contextUser as SocketGuildUser; - if (user == null) + if (!(contextUser is SocketGuildUser user)) return; var userTeam = userService.GetTeam(user); if (userTeam != null) { - await ReplyAsync("Už jsi v teamu."); + await ReplyAsync(Resources.InTeam); return; } @@ -51,16 +51,16 @@ public async Task SetTeam( [Command("level", RunMode = RunMode.Async)] [Alias("lvl")] [TeamPrecondition] - [Summary("Nastaví level.")] + [Summary("SetLevelSummary")] public async Task SetLevel( - [Summary("Aktuální level (1-40)")]int level) + [Summary("CurrentLevel")]int level) { if (!(Context.User is SocketGuildUser user)) return; if (!(level >= 1 && level <= 40)) { - await ReplyAsync("Asi hraješ jinou hru ... povolený level je 1-40."); + await ReplyAsync(Resources.PlayAnotherGame); return; } @@ -82,13 +82,13 @@ await user.ModifyAsync(t => } [Command("set")] - [Summary("Nastaví team a level.")] + [Summary("SetBasicInfoSummary")] public async Task SetBasicInfo( - [Summary("Zvolený team (roli).")]PokemonTeam team, - [Summary("Aktuální level (1-40).")]int level) + [Summary("SelectedTeam")]PokemonTeam team, + [Summary("CurrentLevel")]int level) { await SetTeam(team); await SetLevel(level); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/Preconditions/RaidChannelPreconditionAttribute.cs b/PoGo.DiscordBot/Modules/Preconditions/RaidChannelPreconditionAttribute.cs index e06c365..3f5d18d 100644 --- a/PoGo.DiscordBot/Modules/Preconditions/RaidChannelPreconditionAttribute.cs +++ b/PoGo.DiscordBot/Modules/Preconditions/RaidChannelPreconditionAttribute.cs @@ -18,4 +18,4 @@ public override Task CheckPermissions(ICommandContext contex return Task.FromResult(PreconditionResult.FromError("This channel is not configured as input")); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/Preconditions/TeamPreconditionAttribute.cs b/PoGo.DiscordBot/Modules/Preconditions/TeamPreconditionAttribute.cs index 934610f..c5fe41d 100644 --- a/PoGo.DiscordBot/Modules/Preconditions/TeamPreconditionAttribute.cs +++ b/PoGo.DiscordBot/Modules/Preconditions/TeamPreconditionAttribute.cs @@ -1,9 +1,9 @@ using Discord.Commands; using Discord.WebSocket; +using Microsoft.Extensions.DependencyInjection; using PoGo.DiscordBot.Services; using System; using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; namespace PoGo.DiscordBot.Modules.Preconditions { @@ -34,4 +34,4 @@ protected TeamPreconditionResult(CommandError? error, string errorReason) public static TeamPreconditionResult Success => new TeamPreconditionResult(null, null); public static TeamPreconditionResult Fail => new TeamPreconditionResult(CommandError.UnmetPrecondition, "Je nutné si zvolit team."); } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/RaidModule.cs b/PoGo.DiscordBot/Modules/RaidModule.cs index 80cc809..728556a 100644 --- a/PoGo.DiscordBot/Modules/RaidModule.cs +++ b/PoGo.DiscordBot/Modules/RaidModule.cs @@ -5,8 +5,10 @@ using Microsoft.Extensions.Logging; using PoGo.DiscordBot.Dto; using PoGo.DiscordBot.Modules.Preconditions; +using PoGo.DiscordBot.Properties; using PoGo.DiscordBot.Services; using System; +using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -43,23 +45,23 @@ public RaidModule(TeamService teamService, RaidService raidService, ILogger [Command("schedule", RunMode = RunMode.Async)] [Alias("s")] - [Summary("Vytvoří plánovanou raid anketu do speciálního kanálu.")] + [Summary("StartScheduledRaidSummary")] [RaidChannelPrecondition] public async Task StartScheduledRaid( - [Summary("Název bosse.")]string bossName, - [Summary("Místo.")]string location, - [Remainder][Summary("Datum (" + RaidInfoDto.DateTimeFormat + ").")]string dateTime) + [Summary("BossName")]string bossName, + [Summary("Place")]string location, + [Remainder][Summary("Date (" + RaidInfoDto.DateTimeFormat + ").")]string dateTime) { var raidChannelBinding = raidChannelService.TryGetRaidChannelBinding(Context.Guild.Id, Context.Channel.Id); if (raidChannelBinding == null || !raidChannelBinding.AllowScheduledRaids) { - await ReplyAsync($"Z tohoto kanálu není možné vytvořit plánovanou raid anketu."); + await ReplyAsync(Resources.RaidNotPossible); return; } var parsedDateTime = RaidInfoDto.ParseDateTime(dateTime); if (!parsedDateTime.HasValue) { - await ReplyAsync($"Datum není ve validním formátu ({RaidInfoDto.DateTimeFormat} 24H)."); + await ReplyAsync((Resources.DateNotValid) + $"({RaidInfoDto.DateTimeFormat} 24H)."); return; } if (parsedDateTime < DateTime.Now) { - await ReplyAsync($"Vážně chceš vytvořit plánovaný raid v minulosti?"); + await ReplyAsync(Resources.PastRaid); return; } @@ -147,7 +149,7 @@ RaidInfoDto GetRaid(int skip) [Command("time", RunMode = RunMode.Async)] [Alias("t")] - [Summary("Přenastaví čas raidu.")] + [Summary("AdjustRaidTimeSummary")] [RaidChannelPrecondition] public async Task AdjustRaidTime( [Summary("Nový čas raidu (" + RaidInfoDto.TimeFormat + ").")]string time, @@ -158,20 +160,20 @@ public async Task AdjustRaidTime( if (raid == null) { - await ReplyAsync("Raid nenalezen."); + await ReplyAsync(Resources.RaidNotFound); return; } var parsedTime = RaidInfoDto.ParseTime(time); if (!parsedTime.HasValue) { - await ReplyAsync($"Čas není ve validním formátu ({RaidInfoDto.TimeFormat} 24H)."); + await ReplyAsync(Resources.BadTimeFormat + $" ({RaidInfoDto.TimeFormat} 24H)."); return; } if (parsedTime < DateTime.Now) { - await ReplyAsync($"Vážně změnit čas do minulosti?"); + await ReplyAsync(Resources.PastRaid); return; } @@ -194,7 +196,7 @@ await user.SendMessageAsync( [Command("boss", RunMode = RunMode.Async)] [Alias("b")] - [Summary("Přenastaví bosse raidu.")] + [Summary("AdjustRaidBossSummary")] [RaidChannelPrecondition] public async Task AdjustRaidBoss( [Summary("Přenastaví bosse raidu.")]string boss, @@ -204,7 +206,7 @@ public async Task AdjustRaidBoss( if (raid == null) { - await ReplyAsync("Raid nenalezen."); + await ReplyAsync(Resources.RaidNotFound); return; } @@ -225,7 +227,7 @@ public async Task AdjustRaidBoss( [Command("mention", RunMode = RunMode.Async)] [Alias("m")] - [Summary("Označí lidi, kteří jsou zapsáni na raid.")] + [Summary("MentionRaidPlayersSummary")] [RaidChannelPrecondition] public async Task MentionRaidPlayers( [Summary("Počet anket odspodu.")] int skip = 0, @@ -235,13 +237,13 @@ public async Task MentionRaidPlayers( if (raid == null) { - await ReplyAsync("Raid nenalezen."); + await ReplyAsync(Resources.RaidNotFound); return; } var users = raid.Players.Values.ToHashSet(); - if (users.Any()) + if (users.Count > 0) { string playerMentions = string.Join(' ', users.Select(t => t.User.Mention)); string message = string.Empty; @@ -254,7 +256,7 @@ public async Task MentionRaidPlayers( [Command("delete", RunMode = RunMode.Async)] [Alias("d")] - [Summary("Smaže raid.")] + [Summary("DeleteRaidSummary")] [RaidChannelPrecondition] public async Task DeleteRaid( [Summary("Počet anket odspodu.")] int skip = 0) @@ -263,13 +265,13 @@ public async Task DeleteRaid( if (raid == null) { - await ReplyAsync("Raid nenalezen."); + await ReplyAsync(Resources.RaidNotFound); return; } var questionMessage = await ReplyAsync($"Vážně chceš smazat tenhle raid: '{raid.ToSimpleString()}'? [y]"); var responseMessage = await NextMessageAsync(); - if (responseMessage == null || responseMessage.Content.ToLower() != "y") + if (responseMessage == null || !string.Equals(responseMessage.Content, "y", StringComparison.OrdinalIgnoreCase)) return; foreach (var player in raid.Players.Values) @@ -284,7 +286,7 @@ public async Task DeleteRaid( [Command("info", RunMode = RunMode.Async)] [Alias("i")] - [Summary("Vypíše základní info o bossovi.")] + [Summary("RaidBossInfoSummary")] public async Task RaidBossInfo( [Summary("Název bosse.")] string bossName) { @@ -314,20 +316,20 @@ public async Task RaidBossInfo( [Command("location", RunMode = RunMode.Async)] [Alias("l", "loc")] - [Summary("Vrátí lokaci gymu.")] + [Summary("RaidLocationSummary")] public async Task RaidLocation( [Remainder][Summary("Část názvu gymu")]string name) { if (string.IsNullOrEmpty(name) || name.Length < 3) { - await ReplyAsync("Moc krátký název."); + await ReplyAsync(Resources.VeryShortName); return; } var searchResult = gymLocationService.Search(Context.Guild.Id, name); if (searchResult == null) { - await ReplyAsync("Server nepodporuje tenhle příkaz."); + await ReplyAsync(Resources.CommandNotSupported); return; } @@ -339,18 +341,18 @@ public async Task RaidLocation( } [Command("list", RunMode = RunMode.Async)] - [Summary("Vrátí seznam aktivních raidů včetně indexů.")] + [Summary("RaidListSummary")] public async Task RaidList() { var channelId = raidChannelService.TryGetRaidChannelBinding(Context.Guild.Id, Context.Channel.Id).Channel.Id; var raids = raidStorageService.GetActiveRaidsWithIndexes(Context.Guild.Id, channelId); if (!raids.Any()) { - await ReplyAsync("Nejsou aktivní žádné raidy."); + await ReplyAsync(Resources.NoActiveRaids); return; } string message = string.Join(Environment.NewLine, raids.Select(t => $"{t.Index} - {t.Raid.ToSimpleString()}").Reverse()); await ReplyAsync($"```{message}```"); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/RoleModule.cs b/PoGo.DiscordBot/Modules/RoleModule.cs index 9529b39..a2ff854 100644 --- a/PoGo.DiscordBot/Modules/RoleModule.cs +++ b/PoGo.DiscordBot/Modules/RoleModule.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using PoGo.DiscordBot.Configuration.Options; +using PoGo.DiscordBot.Properties; using PoGo.DiscordBot.Services; using System.Collections.Generic; using System.Linq; @@ -29,7 +30,7 @@ public RoleModule(ILogger logger, IOptions opt [Command("add")] [Alias("a")] - [Summary("Přidá uživateli roli.")] + [Summary("AddRoleSummary")] public async Task AddRole([Summary("Název role")]string roleName) { if (!(Context.User is SocketGuildUser user)) @@ -41,7 +42,7 @@ public async Task AddRole([Summary("Název role")]string roleName) var role = roleService.GetRoleByName(Context.Guild, roleName); if (role == null) { - await ReplyAsync("Neznámá role."); + await ReplyAsync(Resources.UnknownRole); return; } @@ -51,7 +52,7 @@ public async Task AddRole([Summary("Název role")]string roleName) [Command("remove")] [Alias("r")] - [Summary("Smaže uživateli roli.")] + [Summary("RemoveRoleSummary")] public async Task RemoveRole([Summary("Název role")]string roleName) { if (!(Context.User is SocketGuildUser user)) @@ -63,7 +64,7 @@ public async Task RemoveRole([Summary("Název role")]string roleName) var role = roleService.GetRoleByName(Context.Guild, roleName); if (role == null) { - await ReplyAsync("Neznámá role."); + await ReplyAsync(Resources.UnknownRole); return; } @@ -71,4 +72,4 @@ public async Task RemoveRole([Summary("Název role")]string roleName) await ReplyAsync($"Byla ti odebrána role '{roleName}'"); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/StatisticsModule.cs b/PoGo.DiscordBot/Modules/StatisticsModule.cs index 43eab82..46fa7cb 100644 --- a/PoGo.DiscordBot/Modules/StatisticsModule.cs +++ b/PoGo.DiscordBot/Modules/StatisticsModule.cs @@ -79,4 +79,4 @@ public async Task LevelStatistics() await ReplyAsync(string.Empty, embed: embedBuilder.Build()); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Modules/TestModule.cs b/PoGo.DiscordBot/Modules/TestModule.cs index c56b15a..26777f8 100644 --- a/PoGo.DiscordBot/Modules/TestModule.cs +++ b/PoGo.DiscordBot/Modules/TestModule.cs @@ -22,4 +22,4 @@ public async Task Test(string a, string b) await Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/PoGo.DiscordBot.csproj b/PoGo.DiscordBot/PoGo.DiscordBot.csproj index b23998d..4084bad 100644 --- a/PoGo.DiscordBot/PoGo.DiscordBot.csproj +++ b/PoGo.DiscordBot/PoGo.DiscordBot.csproj @@ -14,15 +14,38 @@ + - + + + + True + True + Resources.resx + + + + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + appsettings.json @@ -37,5 +60,5 @@ configuration.json - + diff --git a/PoGo.DiscordBot/PoGoBot.cs b/PoGo.DiscordBot/PoGoBot.cs index 561a33c..0102fdf 100644 --- a/PoGo.DiscordBot/PoGoBot.cs +++ b/PoGo.DiscordBot/PoGoBot.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.Options; using PoGo.DiscordBot.Configuration.Options; using PoGo.DiscordBot.Modules.Preconditions; +using PoGo.DiscordBot.Properties; using PoGo.DiscordBot.Services; using System; using System.Diagnostics; @@ -34,7 +35,14 @@ public PoGoBot() { string environment = Environment.GetEnvironmentVariable("PoGoEnvironment"); if (string.IsNullOrEmpty(environment)) - throw new Exception($"Unknown environment '{environment}'"); + { +#if DEBUG + environment = "Development"; +#else + environment = "Production"; +#endif + } + //throw new Exception($"Unknown environment '{environment}'"); Console.WriteLine($"Environment: {environment}"); Configuration = new ConfigurationBuilder() @@ -224,7 +232,7 @@ async Task HandleCommand(SocketMessage messageParam) if (!(message.HasCharPrefix(configuration.Prefix, ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos))) return; // Create a Command Context var context = new SocketCommandContext(client, message); - // Execute the command. (result does not indicate a return value, + // Execute the command. (result does not indicate a return value, // rather an object stating if the command executed succesfully) var result = await commands.ExecuteAsync(context, argPos, ServiceProvider); if (!result.IsSuccess) @@ -234,12 +242,12 @@ async Task HandleCommand(SocketMessage messageParam) const string TooFewArgs = "The input text has too few parameters."; const string TooManyArgs = "The input text has too many parameters."; if (result.ErrorReason == TooFewArgs) - await context.Channel.SendMessageAsync("Chybí některý z parametrů."); + await context.Channel.SendMessageAsync(Resources.TooFewArgs); else if (result.ErrorReason == TooManyArgs) - await context.Channel.SendMessageAsync("Hodně parametrů - nechybí ti tam uvozovky?"); + await context.Channel.SendMessageAsync(Resources.TooManyArgs); } else if (result.Error == CommandError.ParseFailed) - await context.Channel.SendMessageAsync("Špatné parametry."); + await context.Channel.SendMessageAsync(Resources.BadParameters); else if (result is TeamPreconditionResult teamResult) await context.Channel.SendMessageAsync(teamResult.ErrorReason); @@ -264,4 +272,4 @@ string LogMessageFormatter(LogMessage message, Exception exception) return $"{message.Source}: {message.Message}"; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Program.cs b/PoGo.DiscordBot/Program.cs index 73963e3..66b516c 100644 --- a/PoGo.DiscordBot/Program.cs +++ b/PoGo.DiscordBot/Program.cs @@ -14,4 +14,4 @@ static async Task Main(string[] args) } } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Properties/PublishProfiles/FolderProfile.pubxml b/PoGo.DiscordBot/Properties/PublishProfiles/FolderProfile.pubxml index 548b9af..ae788bf 100644 --- a/PoGo.DiscordBot/Properties/PublishProfiles/FolderProfile.pubxml +++ b/PoGo.DiscordBot/Properties/PublishProfiles/FolderProfile.pubxml @@ -1,7 +1,7 @@  diff --git a/PoGo.DiscordBot/Properties/Resources.Designer.cs b/PoGo.DiscordBot/Properties/Resources.Designer.cs new file mode 100644 index 0000000..e7eaa95 --- /dev/null +++ b/PoGo.DiscordBot/Properties/Resources.Designer.cs @@ -0,0 +1,621 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PoGo.DiscordBot.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PoGo.DiscordBot.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Adds a role to the user. + /// + public static string AddRoleSummary { + get { + return ResourceManager.GetString("AddRoleSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Rebuilds boss raid. + /// + public static string AdjustRaidBossSummary { + get { + return ResourceManager.GetString("AdjustRaidBossSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to It will reset the raid time. + /// + public static string AdjustRaidTimeSummary { + get { + return ResourceManager.GetString("AdjustRaidTimeSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to All Commands. + /// + public static string AllCommands { + get { + return ResourceManager.GetString("AllCommands", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Available commands. + /// + public static string AvailableCommands { + get { + return ResourceManager.GetString("AvailableCommands", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bad parameters. + /// + public static string BadParameters { + get { + return ResourceManager.GetString("BadParameters", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Time is not in valid format. + /// + public static string BadTimeFormat { + get { + return ResourceManager.GetString("BadTimeFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Basic Use. + /// + public static string BasicUse { + get { + return ResourceManager.GetString("BasicUse", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Boss. + /// + public static string Boss { + get { + return ResourceManager.GetString("Boss", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Name of the boss.. + /// + public static string BossName { + get { + return ResourceManager.GetString("BossName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Checks whether the user has a team set up. If not, he will receive a message with information on how to set it. + /// + public static string CheckTeamSummary { + get { + return ResourceManager.GetString("CheckTeamSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Command. + /// + public static string Command { + get { + return ResourceManager.GetString("Command", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No command found {0}, I couldn't find it. + /// + public static string CommandNotFound { + get { + return ResourceManager.GetString("CommandNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Server does not support this command. + /// + public static string CommandNotSupported { + get { + return ResourceManager.GetString("CommandNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Controlled user. + /// + public static string ControlledUser { + get { + return ResourceManager.GetString("ControlledUser", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Current Level (1-40). + /// + public static string CurrentLevel { + get { + return ResourceManager.GetString("CurrentLevel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to date. + /// + public static string Date { + get { + return ResourceManager.GetString("Date", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Date is not in valid format . + /// + public static string DateNotValid { + get { + return ResourceManager.GetString("DateNotValid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deletes all messages (limited). + /// + public static string DeleteAllMessagesSummary { + get { + return ResourceManager.GetString("DeleteAllMessagesSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deletes tagged user messages (limited). + /// + public static string DeleteLastMessageSummary { + get { + return ResourceManager.GetString("DeleteLastMessageSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete Raid. + /// + public static string DeleteRaidSummary { + get { + return ResourceManager.GetString("DeleteRaidSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deletes your messages (limited). + /// + public static string DeleteYourMessagesSummary { + get { + return ResourceManager.GetString("DeleteYourMessagesSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Description. + /// + public static string Description { + get { + return ResourceManager.GetString("Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Full Use. + /// + public static string FullUse { + get { + return ResourceManager.GetString("FullUse", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists help for a specific command. + /// + public static string HelpSummary { + get { + return ResourceManager.GetString("HelpSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You're in the team. + /// + public static string InTeam { + get { + return ResourceManager.GetString("InTeam", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Returns a link to the Discord invitation here. + /// + public static string InviteSummary { + get { + return ResourceManager.GetString("InviteSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists Commands.. + /// + public static string ListCommandsSummary { + get { + return ResourceManager.GetString("ListCommandsSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mark people who are enrolled on raid. + /// + public static string MentionRaidPlayersSummary { + get { + return ResourceManager.GetString("MentionRaidPlayersSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Number Of Messages. + /// + public static string MessageNumber { + get { + return ResourceManager.GetString("MessageNumber", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No raids active. + /// + public static string NoActiveRaids { + get { + return ResourceManager.GetString("NoActiveRaids", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to none here. + /// + public static string NoDefaultChannel { + get { + return ResourceManager.GetString("NoDefaultChannel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Optional, default is. + /// + public static string Optional { + get { + return ResourceManager.GetString("Optional", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Other players (without Discord, 2nd mobile, etc.). + /// + public static string OtherPlayers { + get { + return ResourceManager.GetString("OtherPlayers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parameter Description. + /// + public static string ParameterDescription { + get { + return ResourceManager.GetString("ParameterDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parameters. + /// + public static string Parameters { + get { + return ResourceManager.GetString("Parameters", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Do you really want to create a raid in the past?. + /// + public static string PastRaid { + get { + return ResourceManager.GetString("PastRaid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Place. + /// + public static string Place { + get { + return ResourceManager.GetString("Place", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You probably play another game ... the allowed level is 1-40. + /// + public static string PlayAnotherGame { + get { + return ResourceManager.GetString("PlayAnotherGame", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Players. + /// + public static string Players { + get { + return ResourceManager.GetString("Players", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Only these values ​​are possible. + /// + public static string PossibleValues { + get { + return ResourceManager.GetString("PossibleValues", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists basic boss info. + /// + public static string RaidBossInfoSummary { + get { + return ResourceManager.GetString("RaidBossInfoSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Returns a list of active raids, including indexes. + /// + public static string RaidListSummary { + get { + return ResourceManager.GetString("RaidListSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Returns the location of the gym. + /// + public static string RaidLocationSummary { + get { + return ResourceManager.GetString("RaidLocationSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Raid not found.. + /// + public static string RaidNotFound { + get { + return ResourceManager.GetString("RaidNotFound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to It is not possible to create a scheduled raid poll from this channel. + /// + public static string RaidNotPossible { + get { + return ResourceManager.GetString("RaidNotPossible", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete a role for the user. + /// + public static string RemoveRollSummary { + get { + return ResourceManager.GetString("RemoveRollSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Selected team (role). + /// + public static string SelectedTeam { + get { + return ResourceManager.GetString("SelectedTeam", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets team and level. + /// + public static string SetBasicInfoSummary { + get { + return ResourceManager.GetString("SetBasicInfoSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets the level. + /// + public static string SetLevelSummary { + get { + return ResourceManager.GetString("SetLevelSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets the team. + /// + public static string SetTeamSummary { + get { + return ResourceManager.GetString("SetTeamSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Creates a raid poll in a special channel.. + /// + public static string StartRaidSummary { + get { + return ResourceManager.GetString("StartRaidSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Creates a scheduled raid poll in a special channel. + /// + public static string StartScheduledRaidSummary { + get { + return ResourceManager.GetString("StartScheduledRaidSummary", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to If you would like to support the development, please contact Pako # 3904. + /// + public static string SupportDevelopment { + get { + return ResourceManager.GetString("SupportDevelopment", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to time. + /// + public static string Time { + get { + return ResourceManager.GetString("Time", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The input text has too few parameters. + /// + public static string TooFewArgs { + get { + return ResourceManager.GetString("TooFewArgs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The input text has too many parameters. + /// + public static string TooManyArgs { + get { + return ResourceManager.GetString("TooManyArgs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unknown Role. + /// + public static string UnknownRole { + get { + return ResourceManager.GetString("UnknownRole", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to User. + /// + public static string User { + get { + return ResourceManager.GetString("User", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Very Short Name. + /// + public static string VeryShortName { + get { + return ResourceManager.GetString("VeryShortName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Where. + /// + public static string Where { + get { + return ResourceManager.GetString("Where", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Without Team. + /// + public static string WithoutTeam { + get { + return ResourceManager.GetString("WithoutTeam", resourceCulture); + } + } + } +} diff --git a/PoGo.DiscordBot/Properties/Resources.cs.resx b/PoGo.DiscordBot/Properties/Resources.cs.resx new file mode 100644 index 0000000..dccf27c --- /dev/null +++ b/PoGo.DiscordBot/Properties/Resources.cs.resx @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Přidá uživateli roli + + + Přenastaví bosse raidu + + + Přenastaví čas raidu + + + Všechny příkazy + + + Dostupné příkazy + + + Špatné parametry + + + Čas není ve validním formátu + + + Základní použití + + + Boss + + + Název bosse + + + Zkontroluje zda má uživatel nastavený team. Jestliže ne, tak mu přijde zpráva s informacemi jak ho nastavit + + + Příkaz + + + Žádný příkaz **{0}** jsem nemohl najít + + + Server nepodporuje tenhle příkaz + + + Kontrolovaný uživatel + + + Aktuální level (1-40) + + + datum + + + Datum není ve validním formátu + + + Smaže všechny zprávy (omezeno počtem) + + + Maže zprávy označeného uživatele (omezeno počtem) + + + Smaže raid. + + + Smaže tvoje zprávy (omezeno počtem) + + + Popis + + + Plné použití + + + Vypíše nápovědu pro konkrétní příkaz + + + Už jsi v teamu + + + Vrátí odkaz s pozvánkou sem na Discord + + + Vypíše seznam příkazů. + + + Označí lidi, kteří jsou zapsáni na raid + + + Počet zpráv + + + Nejsou aktivní žádné raidy + + + žádný tu nemám + + + Volitelný, výchozí hodnota je + + + Další hráči (bez Discordu, 2. mobil atd + + + Popis parametrů + + + Parametry + + + Vážně chceš vytvořit raid v minulosti? + + + Místo + + + Asi hraje jinou hru ... povolený level je 1-40 + + + Hráči + + + Možné jsou jenom tyhle hodnoty + + + Vypíše základní info o bossovi + + + Vrátí seznam aktivních raidů včetně indexů + + + Vrátí lokaci gymu + + + Raid nenalezen. + + + Z tohoto kanálu není možné vytvořit naplánovanou raid anketu + + + Smaže uživateli roli. + + + Zvolený team (roli) + + + Nastaví team a level + + + Nastaví level + + + Nastaví tým. + + + Vytvoří raid anketu do speciálního kanálu. + + + Vytvoří plánovanou raid anketu do speciálního kanálu + + + V případě, že byste chtěli podpořit vývoj, tak se ozvěte Pako#3904 + + + Čas + + + Chybí některý z parametrů + + + Hodně parametrů - nechybí ti tam uvozovky? + + + Neznámá role + + + Uživatel + + + Moc krátký název + + + Kde + + + Bez teamu + + \ No newline at end of file diff --git a/PoGo.DiscordBot/Properties/Resources.en.resx b/PoGo.DiscordBot/Properties/Resources.en.resx new file mode 100644 index 0000000..03a5394 --- /dev/null +++ b/PoGo.DiscordBot/Properties/Resources.en.resx @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Adds a role to the user + + + Rebuilds boss raid + + + It will reset the raid time + + + All Commands + + + Available commands + + + Bad parameters + + + Time is not in valid format + + + Basic Use + + + Boss + + + Name of the boss. + + + Checks whether the user has a team set up. If not, he will receive a message with information on how to set it + + + Command + + + No command found {0}, I couldn't find it + + + Server does not support this command + + + Controlled user + + + Current Level (1-40) + + + date + + + Date is not in valid format + + + Deletes all messages (limited) + + + Deletes tagged user messages (limited) + + + Delete Raid + + + Deletes your messages (limited) + + + Description + + + Full Use + + + Lists help for a specific command + + + You're in the team + + + Returns a link to the Discord invitation here + + + Lists Commands + + + Mark people who are enrolled on raid + + + Number Of Messages + + + No Active Raids + + + None here + + + Optional, default is + + + Other players (without Discord, 2nd mobile, etc.) + + + Parameter Description + + + Parameters + + + Do you really want to create a raid in the past? + + + Place + + + You probably play another game ... the allowed level is 1-40 + + + Players + + + Only these values ​​are possible + + + Lists basic boss info + + + Returns a list of active raids, including indexes + + + Returns the location of the gym + + + Raid not found. + + + It is not possible to create a scheduled raid poll from this channel + + + Delete a role for the user + + + Selected team (role) + + + Sets team and level + + + Sets the level + + + Sets the team + + + Creates a raid poll in a special channel. + + + Creates a scheduled raid poll in a special channel + + + If you would like to support the development, please contact Pako # 3904 + + + time + + + The input text has too few parameters + + + The input text has too many parameters + + + Unknown Role + + + User + + + Very Short Name + + + Where + + + Without Team + + \ No newline at end of file diff --git a/PoGo.DiscordBot/Properties/Resources.resx b/PoGo.DiscordBot/Properties/Resources.resx new file mode 100644 index 0000000..ba25b39 --- /dev/null +++ b/PoGo.DiscordBot/Properties/Resources.resx @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Adds a role to the user + + + Rebuilds boss raid + + + It will reset the raid time + + + All Commands + + + Available commands + + + Bad parameters + + + Time is not in valid format + + + Basic Use + + + Boss + + + Name of the boss. + + + Checks whether the user has a team set up. If not, he will receive a message with information on how to set it + + + Command + + + No command found {0}, I couldn't find it + + + Server does not support this command + + + Controlled user + + + Current Level (1-40) + + + date + + + Date is not in valid format + + + Deletes all messages (limited) + + + Deletes tagged user messages (limited) + + + Delete Raid + + + Deletes your messages (limited) + + + Description + + + Full Use + + + Lists help for a specific command + + + You're in the team + + + Returns a link to the Discord invitation here + + + Lists Commands. + + + Mark people who are enrolled on raid + + + Number Of Messages + + + No raids active + + + none here + + + Optional, default is + + + Other players (without Discord, 2nd mobile, etc.) + + + Parameter Description + + + Parameters + + + Do you really want to create a raid in the past? + + + Place + + + You probably play another game ... the allowed level is 1-40 + + + Players + + + Only these values ​​are possible + + + Lists basic boss info + + + Returns a list of active raids, including indexes + + + Returns the location of the gym + + + Raid not found. + + + It is not possible to create a scheduled raid poll from this channel + + + Delete a role for the user + + + Selected team (role) + + + Sets team and level + + + Sets the level + + + Sets the team + + + Creates a raid poll in a special channel. + + + Creates a scheduled raid poll in a special channel + + + If you would like to support the development, please contact Pako # 3904 + + + time + + + The input text has too few parameters + + + The input text has too many parameters + + + Unknown Role + + + User + + + Very Short Name + + + Where + + + Without Team + + \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/ConfigurationService.cs b/PoGo.DiscordBot/Services/ConfigurationService.cs index 3c7806e..8565cf3 100644 --- a/PoGo.DiscordBot/Services/ConfigurationService.cs +++ b/PoGo.DiscordBot/Services/ConfigurationService.cs @@ -15,4 +15,4 @@ public ConfigurationService(IOptions configurationOptions) public GuildOptions GetGuildOptions(ulong guildId) => configurationOptions.Guilds.FirstOrDefault(t => t.Id == guildId); } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/GymLocationService.cs b/PoGo.DiscordBot/Services/GymLocationService.cs index 0f76902..c3a04d2 100644 --- a/PoGo.DiscordBot/Services/GymLocationService.cs +++ b/PoGo.DiscordBot/Services/GymLocationService.cs @@ -21,7 +21,7 @@ public GymLocationService(IOptions options) Latitude = g.Latitude, Longitude = g.Longitude })).ToArray()); - } + } public IEnumerable Search(ulong guildId, string name) { @@ -36,4 +36,4 @@ public IEnumerable Search(ulong guildId, string name) public string GetMapUrl(GymInfoDto gymInfo) => $"http://maps.google.com/maps?q={gymInfo.Latitude},{gymInfo.Longitude}"; } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/RaidBossInfoService.cs b/PoGo.DiscordBot/Services/RaidBossInfoService.cs index c8f7981..ece3ea2 100644 --- a/PoGo.DiscordBot/Services/RaidBossInfoService.cs +++ b/PoGo.DiscordBot/Services/RaidBossInfoService.cs @@ -25,8 +25,8 @@ public RaidBossInfoService(IOptions options) } public IEnumerable GetAllKnownBossNames() => raidBosses.Values - .Select(t => t.BossName) - .OrderBy(t => t); + .Select(t => t.BossName) + .OrderBy(t => t); public RaidBossDto GetBoss(string bossName) => raidBosses.TryGetValue(bossName.ToLower(), out var dto) ? dto : null; @@ -41,4 +41,4 @@ public string GetBossNameWithEmoji(string bossName, SocketGuild guild) return bossName; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/RaidChannelService.cs b/PoGo.DiscordBot/Services/RaidChannelService.cs index 9886258..8eddcbe 100644 --- a/PoGo.DiscordBot/Services/RaidChannelService.cs +++ b/PoGo.DiscordBot/Services/RaidChannelService.cs @@ -59,25 +59,35 @@ public void OnNewGuild(SocketGuild guild, GuildOptions[] guildOptions) public bool IsKnown(ulong guildId) => guilds.ContainsKey(guildId); + public bool IsKnown(ulong guildId, ulong textChannelId) => TryGetRaidChannelBinding(guildId, textChannelId) != null; + public IEnumerable GetRaidChannels(ulong guildId) => guilds[guildId].Select(t => t.To); /// /// Returns raid channel for the raid poll based on the channel where the command came from. /// + /// todo: describe guildId parameter on TryGetRaidChannelBinding + /// todo: describe fromTextChannelId parameter on TryGetRaidChannelBinding public RaidChannelBindingDto TryGetRaidChannelBinding(ulong guildId, ulong fromTextChannelId) { if (guilds.TryGetValue(guildId, out var raidChannelBindings)) + { foreach (var channel in raidChannelBindings) + { if (channel.From == null || channel.From.Id == fromTextChannelId) + { return new RaidChannelBindingDto { Channel = channel.To, Mention = channel.Mention, AllowScheduledRaids = channel.ScheduledRaids, }; + } + } + } return null; } @@ -124,4 +134,4 @@ void AddBindingIfValid(List channelBindings, SocketGuild gui channelBindings.Add(new RaidChannelBinding(channelFrom, channelTo, mention, channelOptions.ScheduledRaids)); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/RaidService.cs b/PoGo.DiscordBot/Services/RaidService.cs index 79ae353..79a7ccd 100644 --- a/PoGo.DiscordBot/Services/RaidService.cs +++ b/PoGo.DiscordBot/Services/RaidService.cs @@ -49,7 +49,7 @@ public async Task UpdateRaidMessages(SocketGuild guild, IMessageChannel channel, .ToList(); var latestMessages = batchMessages.SelectMany(t => t.Where(m => m.CreatedAt.UtcDateTime > dateTimeFrom)) .ToList(); - if (!latestMessages.Any()) + if (latestMessages.Count == 0) return; logger.LogInformation($"start updating raid messages for channel '{channel.Name}'"); @@ -207,4 +207,4 @@ public async Task UpdateRaidMessages() raidStorageService.TryRemove(guildId, channelId, messageId); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/RaidStorageService.cs b/PoGo.DiscordBot/Services/RaidStorageService.cs index 4b49b76..e65e2b0 100644 --- a/PoGo.DiscordBot/Services/RaidStorageService.cs +++ b/PoGo.DiscordBot/Services/RaidStorageService.cs @@ -103,4 +103,4 @@ public RaidMessageMapping() } } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/RoleService.cs b/PoGo.DiscordBot/Services/RoleService.cs index c4a1752..eb26c40 100644 --- a/PoGo.DiscordBot/Services/RoleService.cs +++ b/PoGo.DiscordBot/Services/RoleService.cs @@ -7,4 +7,4 @@ public class RoleService { public SocketRole GetRoleByName(SocketGuild guild, string name) => guild.Roles.FirstOrDefault(t => t.Name == name); } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/TeamService.cs b/PoGo.DiscordBot/Services/TeamService.cs index 87834a2..61fd955 100644 --- a/PoGo.DiscordBot/Services/TeamService.cs +++ b/PoGo.DiscordBot/Services/TeamService.cs @@ -64,4 +64,4 @@ async Task GetTeamRoles(IGuild guild) }; } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/Services/UserService.cs b/PoGo.DiscordBot/Services/UserService.cs index 4a5c235..6b63aa9 100644 --- a/PoGo.DiscordBot/Services/UserService.cs +++ b/PoGo.DiscordBot/Services/UserService.cs @@ -79,4 +79,4 @@ public Task OnUserJoined(SocketGuildUser user) return CheckTeam(user); } } -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/TextFile1.txt b/PoGo.DiscordBot/TextFile1.txt new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/PoGo.DiscordBot/TextFile1.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/PoGo.DiscordBot/configuration.Development.json b/PoGo.DiscordBot/configuration.Development.json index c885bc3..9d79664 100644 --- a/PoGo.DiscordBot/configuration.Development.json +++ b/PoGo.DiscordBot/configuration.Development.json @@ -1,3 +1,3 @@ { "Token": "" -} +} \ No newline at end of file diff --git a/PoGo.DiscordBot/configuration.Production.json b/PoGo.DiscordBot/configuration.Production.json index c885bc3..9d79664 100644 --- a/PoGo.DiscordBot/configuration.Production.json +++ b/PoGo.DiscordBot/configuration.Production.json @@ -1,3 +1,3 @@ { "Token": "" -} +} \ No newline at end of file