Cleaner chat log

This commit is contained in:
goat 2019-11-24 23:11:19 +09:00
parent 948b7b30b3
commit 2ea4c0c7c8
2 changed files with 14 additions and 92 deletions

View file

@ -38,86 +38,6 @@ namespace Dalamud.DiscordBot {
this.socketClient = new DiscordSocketClient(); this.socketClient = new DiscordSocketClient();
this.socketClient.Ready += SocketClientOnReady; 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<XivChatType>()) {
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) { private XivChatType GetChatTypeBySlug(string slug) {
@ -237,6 +157,8 @@ namespace Dalamud.DiscordBot {
if (!chatTypeConfigs.Any()) if (!chatTypeConfigs.Any())
return; return;
var chatTypeDetail = type.GetDetails();
var channels = chatTypeConfigs.Select(c => GetChannel(c.Channel).GetAwaiter().GetResult()); var channels = chatTypeConfigs.Select(c => GetChannel(c.Channel).GetAwaiter().GetResult());
var senderSplit = sender.Split(new[] {this.worldIcon}, StringSplitOptions.None); 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}");
} }
} }
} }

View file

@ -9,13 +9,13 @@ namespace Dalamud.Game.Chat {
None = 0, None = 0,
Debug = 1, Debug = 1,
[XivChatTypeInfo("Urgent", null, 0xFF9400D3)] [XivChatTypeInfo("Urgent", "urgent", 0xFF9400D3)]
Urgent = 2, Urgent = 2,
[XivChatTypeInfo("Notice", null, 0xFF9400D3)] [XivChatTypeInfo("Notice", "notice", 0xFF9400D3)]
Notice = 3, Notice = 3,
[XivChatTypeInfo("Say", "s", 0xFFFFFFFF)] [XivChatTypeInfo("Say", "say", 0xFFFFFFFF)]
Say = 10, Say = 10,
[XivChatTypeInfo("Shout", "shout", 0xFFFF4500)] [XivChatTypeInfo("Shout", "shout", 0xFFFF4500)]
@ -25,10 +25,10 @@ namespace Dalamud.Game.Chat {
[XivChatTypeInfo("Tell", "tell", 0xFFFF69B4)] [XivChatTypeInfo("Tell", "tell", 0xFFFF69B4)]
TellIncoming = 13, TellIncoming = 13,
[XivChatTypeInfo("Party", "p", 0xFF1E90FF)] [XivChatTypeInfo("Party", "party", 0xFF1E90FF)]
Party = 14, Party = 14,
[XivChatTypeInfo("Alliance", "a", 0xFFFF4500)] [XivChatTypeInfo("Alliance", "alliance", 0xFFFF4500)]
Alliance = 15, Alliance = 15,
[XivChatTypeInfo("Linkshell 1", "ls1", 0xFF228B22)] [XivChatTypeInfo("Linkshell 1", "ls1", 0xFF228B22)]
@ -61,24 +61,24 @@ namespace Dalamud.Game.Chat {
[XivChatTypeInfo("Novice Network", "nn", 0xFF8B4513)] [XivChatTypeInfo("Novice Network", "nn", 0xFF8B4513)]
NoviceNetwork = 27, NoviceNetwork = 27,
[XivChatTypeInfo("Custom Emotes", "nn", 0xFF8B4513)] [XivChatTypeInfo("Custom Emotes", "emote", 0xFF8B4513)]
CustomEmote = 28, CustomEmote = 28,
[XivChatTypeInfo("Standard Emotes", null, 0xFF8B4513)] [XivChatTypeInfo("Standard Emotes", "emote", 0xFF8B4513)]
StandardEmote = 29, StandardEmote = 29,
[XivChatTypeInfo("Yell", "y", 0xFFFFFF00)] [XivChatTypeInfo("Yell", "yell", 0xFFFFFF00)]
Yell = 30, Yell = 30,
[XivChatTypeInfo("Party", "p", 0xFF1E90FF)] [XivChatTypeInfo("Party", "party", 0xFF1E90FF)]
CrossParty = 32, CrossParty = 32,
[XivChatTypeInfo("PvP Team", "pvp", 0xFFF4A460)] [XivChatTypeInfo("PvP Team", "pvpt", 0xFFF4A460)]
PvPTeam = 36, PvPTeam = 36,
[XivChatTypeInfo("Crossworld Linkshell 1", "cw1", 0xFF1E90FF)] [XivChatTypeInfo("Crossworld Linkshell 1", "cw1", 0xFF1E90FF)]
CrossLinkShell1 = 37, CrossLinkShell1 = 37,
[XivChatTypeInfo("Echo", null, 0xFF808080)] [XivChatTypeInfo("Echo", "echo", 0xFF808080)]
Echo = 56, Echo = 56,
SystemError = 58, SystemError = 58,
GatheringSystemMessage = 60, GatheringSystemMessage = 60,