From 2ea4c0c7c81ed24185b0858af17c85545333a9e2 Mon Sep 17 00:00:00 2001 From: goat Date: Sun, 24 Nov 2019 23:11:19 +0900 Subject: [PATCH] Cleaner chat log --- Dalamud/DiscordBot/DiscordBotManager.cs | 84 +------------------------ Dalamud/Game/Chat/XivChatType.cs | 22 +++---- 2 files changed, 14 insertions(+), 92 deletions(-) diff --git a/Dalamud/DiscordBot/DiscordBotManager.cs b/Dalamud/DiscordBot/DiscordBotManager.cs index b2d6d11db..8fcfcd643 100644 --- a/Dalamud/DiscordBot/DiscordBotManager.cs +++ b/Dalamud/DiscordBot/DiscordBotManager.cs @@ -38,86 +38,6 @@ namespace Dalamud.DiscordBot { this.socketClient = new DiscordSocketClient(); this.socketClient.Ready += SocketClientOnReady; - this.socketClient.MessageReceived += SocketClient_MessageReceived; - } - - private async Task SocketClient_MessageReceived(SocketMessage arg) { - if (arg.Embeds != null && arg.Embeds.Count == 1) { - this.recentMessages.Add(arg); - return; - } - - var msgContent = arg.Content; - - if (!msgContent.StartsWith("!f")) - return; - - if (arg.Author.Id != this.config.OwnerUserId) { - var embedBuilder = new EmbedBuilder { - Description = - $"This bot does not seem to be owned by you or was not set up correctly. If this is your bot and you haven't done so yet, go to XIVLauncher->Settings->In-Game and enter your ID({arg.Author.Id}) into the owner ID field.", - Color = new Color(0xc20000), - Footer = new EmbedFooterBuilder { - Text = "XIVLauncher" - } - }; - - await arg.Channel.SendMessageAsync(embed: embedBuilder.Build()); - return; - } - - msgContent = msgContent.Substring(2); - var parts = msgContent.Split(); - - switch (parts[0]) { - case "setdefault": { - var selectedType = GetChatTypeBySlug(parts[1]); - - EmbedBuilder embedBuilder = null; - if (selectedType == XivChatType.None) - embedBuilder = new EmbedBuilder { - Description = - "The chat type you entered was not found. Use !ftypes for a list of possible values.", - Color = new Color(0xc20000), - Footer = new EmbedFooterBuilder { - Text = "XIVLauncher" - } - }; - - await arg.Channel.SendMessageAsync(embed: embedBuilder.Build()); - } - break; - - case "types": { - var embedText = string.Empty; - - foreach (var chatType in Enum.GetValues(typeof(XivChatType)).Cast()) { - var details = chatType.GetDetails(); - - if (details?.Slug == null) - continue; - - embedText += $"{details.FancyName} - {details.Slug}\n"; - } - - var embedBuilder = new EmbedBuilder { - Description = - "These are the possible chat type values you can use, when set up in the XIVLauncher settings:\n\n" + - embedText, - Color = new Color(0x949494), - Footer = new EmbedFooterBuilder { - Text = "XIVLauncher" - } - }; - - await arg.Channel.SendMessageAsync(embed: embedBuilder.Build()); - } - break; - default: { - var selectedType = GetChatTypeBySlug(parts[0]); - } - break; - } } private XivChatType GetChatTypeBySlug(string slug) { @@ -237,6 +157,8 @@ namespace Dalamud.DiscordBot { if (!chatTypeConfigs.Any()) return; + var chatTypeDetail = type.GetDetails(); + var channels = chatTypeConfigs.Select(c => GetChannel(c.Channel).GetAwaiter().GetResult()); var senderSplit = sender.Split(new[] {this.worldIcon}, StringSplitOptions.None); @@ -340,7 +262,7 @@ namespace Dalamud.DiscordBot { } } - await channels.ElementAt(chatTypeIndex).SendMessageAsync($"{name}: {message}"); + await channels.ElementAt(chatTypeIndex).SendMessageAsync($"**[{chatTypeDetail.Slug}]{name}**: {message}"); } } } diff --git a/Dalamud/Game/Chat/XivChatType.cs b/Dalamud/Game/Chat/XivChatType.cs index 1ecb16985..4a457cf3f 100644 --- a/Dalamud/Game/Chat/XivChatType.cs +++ b/Dalamud/Game/Chat/XivChatType.cs @@ -9,13 +9,13 @@ namespace Dalamud.Game.Chat { None = 0, Debug = 1, - [XivChatTypeInfo("Urgent", null, 0xFF9400D3)] + [XivChatTypeInfo("Urgent", "urgent", 0xFF9400D3)] Urgent = 2, - [XivChatTypeInfo("Notice", null, 0xFF9400D3)] + [XivChatTypeInfo("Notice", "notice", 0xFF9400D3)] Notice = 3, - [XivChatTypeInfo("Say", "s", 0xFFFFFFFF)] + [XivChatTypeInfo("Say", "say", 0xFFFFFFFF)] Say = 10, [XivChatTypeInfo("Shout", "shout", 0xFFFF4500)] @@ -25,10 +25,10 @@ namespace Dalamud.Game.Chat { [XivChatTypeInfo("Tell", "tell", 0xFFFF69B4)] TellIncoming = 13, - [XivChatTypeInfo("Party", "p", 0xFF1E90FF)] + [XivChatTypeInfo("Party", "party", 0xFF1E90FF)] Party = 14, - [XivChatTypeInfo("Alliance", "a", 0xFFFF4500)] + [XivChatTypeInfo("Alliance", "alliance", 0xFFFF4500)] Alliance = 15, [XivChatTypeInfo("Linkshell 1", "ls1", 0xFF228B22)] @@ -61,24 +61,24 @@ namespace Dalamud.Game.Chat { [XivChatTypeInfo("Novice Network", "nn", 0xFF8B4513)] NoviceNetwork = 27, - [XivChatTypeInfo("Custom Emotes", "nn", 0xFF8B4513)] + [XivChatTypeInfo("Custom Emotes", "emote", 0xFF8B4513)] CustomEmote = 28, - [XivChatTypeInfo("Standard Emotes", null, 0xFF8B4513)] + [XivChatTypeInfo("Standard Emotes", "emote", 0xFF8B4513)] StandardEmote = 29, - [XivChatTypeInfo("Yell", "y", 0xFFFFFF00)] + [XivChatTypeInfo("Yell", "yell", 0xFFFFFF00)] Yell = 30, - [XivChatTypeInfo("Party", "p", 0xFF1E90FF)] + [XivChatTypeInfo("Party", "party", 0xFF1E90FF)] CrossParty = 32, - [XivChatTypeInfo("PvP Team", "pvp", 0xFFF4A460)] + [XivChatTypeInfo("PvP Team", "pvpt", 0xFFF4A460)] PvPTeam = 36, [XivChatTypeInfo("Crossworld Linkshell 1", "cw1", 0xFF1E90FF)] CrossLinkShell1 = 37, - [XivChatTypeInfo("Echo", null, 0xFF808080)] + [XivChatTypeInfo("Echo", "echo", 0xFF808080)] Echo = 56, SystemError = 58, GatheringSystemMessage = 60,