diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index f6ff85f..cba2eb6 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -21,7 +21,6 @@ - @@ -73,26 +72,4 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChatTwo/Ui/DbViewer.cs b/ChatTwo/Ui/DbViewer.cs index 54baf37..e04992e 100644 --- a/ChatTwo/Ui/DbViewer.cs +++ b/ChatTwo/Ui/DbViewer.cs @@ -17,7 +17,6 @@ using Dalamud.Interface.ImGuiNotification; using Lumina.Data.Files; using Lumina.Text.ReadOnly; using MoreLinq; -using Newtonsoft.Json; namespace ChatTwo.Ui; @@ -166,28 +165,12 @@ public class DbViewer : Window if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) ImGui.SetTooltip(Language.Export_Txt_Tooltip); - ImGui.SameLine(0, spacing); - using (ImRaii.Disabled(InputPath.Length == 0 || IsExporting)) - { - if (ImGuiUtil.IconButton(FontAwesomeIcon.FileExport)) - { - Notification = Plugin.Notification.AddNotification( - new Notification - { - Title = "Chat2 Json Export", - Content = Language.ChatExport_Initial, - Type = NotificationType.Info, - Minimized = false, - UserDismissable = false, - InitialDuration = TimeSpan.FromSeconds(10000), - Progress = 0.0f, - }); - CreateTempJsonFile(); - } - } - - if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) - ImGui.SetTooltip(Language.Export_Json_Tooltip); + // Hellion Chat: the JSON export button used to dump the database in + // the upstream webinterface's wire format. With the webinterface + // removed there is no consumer for that format any more, so the + // button is dropped. The Privacy tab's MessageExporter covers the + // same ground (Markdown / JSON / CSV) with channel and date filters + // and is the supported way to get history out of the plugin. var width = 350 * ImGuiHelpers.GlobalScale; var loadingIndicator = IsProcessing && ProcessingStart < Environment.TickCount64; @@ -461,136 +444,4 @@ public class DbViewer : Window }); } - private void CreateTempJsonFile() - { - IsExporting = true; - Task.Run(async () => - { - try - { - var channels = SelectedChannels.Select(pair => (byte)pair.Key).ToArray(); - - var rangeMessageEnumerator = Plugin.MessageManager.Store.GetDateRange(AfterDate, BeforeDate, channels); - var messageHistory = rangeMessageEnumerator.ToArray(); - await rangeMessageEnumerator.DisposeAsync(); - - var filteredHistory = Filter(messageHistory); - - await using var stream = new StreamWriter(Path.Join(InputPath, $"Chat2_{DateTime.Now:yyyy_dd_M__HH_mm_ss}.json")); - - var batch = 0; - var messageContainer = new Messages(); - List templates = []; - foreach (var messages in filteredHistory.Batch(5000)) - { - foreach (var message in messages) - { - templates.Add(ReadMessageContent(message)); - batch++; - } - - Notification.Progress = (float)batch / filteredHistory.Count; - Notification.Content = $"Exported {batch} of {filteredHistory.Count} messages"; - - await Task.Delay(100); - } - - messageContainer.Set = templates.ToArray(); - await stream.WriteAsync(JsonConvert.SerializeObject(messageContainer)); - templates.Clear(); - - await using (var fileStream = File.Open(Path.Join(InputPath, "gfdata.gfd"), FileMode.OpenOrCreate)) - { - await using var byteWriter = new BinaryWriter(fileStream); - byteWriter.Write(Plugin.DataManager.GetFile("common/font/gfdata.gfd")!.Data); - } - - await using (var fileStream = File.Open(Path.Join(InputPath, "fonticon_ps5.tex"), FileMode.OpenOrCreate)) - { - await using var byteWriter = new BinaryWriter(fileStream); - byteWriter.Write(Plugin.DataManager.GetFile("common/font/fonticon_ps5.tex")!.Data); - } - - await using (var fileStream = File.Open(Path.Join(InputPath, "FFXIV_Lodestone_SSF.ttf"), FileMode.OpenOrCreate)) - { - await using var byteWriter = new BinaryWriter(fileStream); - byteWriter.Write(Plugin.FontManager.GameSymFont); - } - - Notification.Progress = 1.0f; - Notification.Content = "Done!!!"; - Notification.Type = NotificationType.Success; - } - catch (Exception ex) - { - Plugin.Log.Error(ex, "Failed creating txt backup"); - - Notification.Content = "Error ..."; - Notification.Type = NotificationType.Error; - } - finally - { - IsExporting = false; - Notification.UserDismissable = true; - } - }); - } - - private MessageResponse ReadMessageContent(Message message) - { - var response = new MessageResponse - { - Id = message.Id, - Timestamp = message.Date.ToLocalTime().ToString("t", !Plugin.Config.Use24HourClock ? null : CultureInfo.CreateSpecificCulture("es-ES")) - }; - - var sender = message.Sender.Select(ProcessChunk); - var content = message.Content.Select(ProcessChunk); - response.Templates = sender.Concat(content).ToArray(); - - return response; - } - - private MessageTemplate ProcessChunk(Chunk chunk) - { - if (chunk is IconChunk { } icon) - { - var iconId = (uint)icon.Icon; - return IconUtil.GfdFileView.TryGetEntry(iconId, out _) ? new MessageTemplate {PayloadType = WebPayloadType.Icon, IconId = iconId}: MessageTemplate.Empty; - } - - if (chunk is TextChunk { } text) - { - if (chunk.Link is EmotePayload emotePayload && Plugin.Config.ShowEmotes) - { - var image = EmoteCache.GetEmote(emotePayload.Code); - - if (image is { Failed: false }) - return new MessageTemplate { PayloadType = WebPayloadType.CustomEmote, Color = 0, Content = emotePayload.Code }; - } - - var color = text.Foreground; - if (color == null && text.FallbackColour != null) - { - var type = text.FallbackColour.Value; - color = Plugin.Config.ChatColours.TryGetValue(type, out var col) ? col : type.DefaultColor(); - } - - color ??= 0; - - var userContent = text.Content; - if (Plugin.ChatLogWindow.ScreenshotMode) - { - if (chunk.Link is PlayerPayload playerPayload) - userContent = Plugin.ChatLogWindow.HidePlayerInString(userContent, playerPayload.PlayerName, playerPayload.World.RowId); - else if (Plugin.PlayerState.IsLoaded) - userContent = Plugin.ChatLogWindow.HidePlayerInString(userContent, Plugin.PlayerState.CharacterName, Plugin.PlayerState.HomeWorld.RowId); - } - - var isNotUrl = text.Link is not UriPayload; - return new MessageTemplate { PayloadType = isNotUrl ? WebPayloadType.RawText : WebPayloadType.CustomUri, Color = color.Value, Content = userContent }; - } - - return MessageTemplate.Empty; - } } diff --git a/ChatTwo/packages.lock.json b/ChatTwo/packages.lock.json index 24899aa..925d0bf 100644 --- a/ChatTwo/packages.lock.json +++ b/ChatTwo/packages.lock.json @@ -54,26 +54,6 @@ "resolved": "3.1.12", "contentHash": "iAg6zifihXEFS/t7fiHhZBGAdCp3FavsF4i2ZIDp0JfeYeDVzvmlbY1CNhhIKimaIzrzSi5M/NBFcWvZT2rB/A==" }, - "Watson.Lite": { - "type": "Direct", - "requested": "[6.3.9, )", - "resolved": "6.3.9", - "contentHash": "sDigTY8D8V7W38lfzJGiigf7xZEfp3Kw7XE7VJyeNO9mxOkv+w8HcmCsmORMDhsipDqGU0gMEsPOqORmZzRaWg==", - "dependencies": { - "CavemanTcp": "2.0.9", - "Watson.Core": "6.3.9" - } - }, - "CavemanTcp": { - "type": "Transitive", - "resolved": "2.0.9", - "contentHash": "KgIwYhPhGkBTm+wwVAmWonkKPw4xYVnutzzlIeqOLcX1fti+8d+MEGTvbern1smf3S/UpjFjihkf6XRziTddzQ==" - }, - "IpMatcher": { - "type": "Transitive", - "resolved": "1.0.5", - "contentHash": "WXNlWERj+0GN699AnMNsuJ7PfUAbU4xhOHP3nrNXLHqbOaBxybu25luSYywX1133NSlitA4YkSNmJuyPvea4sw==" - }, "MessagePack.Annotations": { "type": "Transitive", "resolved": "3.1.4", @@ -97,11 +77,6 @@ "resolved": "17.11.4", "contentHash": "mudqUHhNpeqIdJoUx2YDWZO/I9uEDYVowan89R6wsomfnUJQk6HteoQTlNjZDixhT2B4IXMkMtgZtoceIjLRmA==" }, - "RegexMatcher": { - "type": "Transitive", - "resolved": "1.0.9", - "contentHash": "RkQGXIrqHjD5h1mqefhgCbkaSdRYNRG5rrbzyw5zeLWiS0K1wq9xR3cNhQdzYR2MsKZ3GN523yRUsEQIMPxh3Q==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.10", @@ -128,27 +103,6 @@ "dependencies": { "SQLitePCLRaw.core": "2.1.10" } - }, - "Timestamps": { - "type": "Transitive", - "resolved": "1.0.11", - "contentHash": "SnWhXm3FkEStQGgUTfWMh9mKItNW032o/v8eAtFrOGqG0/ejvPPA1LdLZx0N/qqoY0TH3x11+dO00jeVcM8xNQ==" - }, - "UrlMatcher": { - "type": "Transitive", - "resolved": "3.0.1", - "contentHash": "hHBZVzFSfikrx4XsRsnCIwmGLgbNKtntnlqf4z+ygcNA6Y/L/J0x5GiZZWfXdTfpxhy5v7mlt2zrZs/L9SvbOA==" - }, - "Watson.Core": { - "type": "Transitive", - "resolved": "6.3.9", - "contentHash": "hGoadE4SLbko8yxhx5+nxGV8lEVgEquNli87lN6/eOTQEJNpK/Cs+OF0etTgFKZ4p0u5ivetoDxl82Lg6oHZEg==", - "dependencies": { - "IpMatcher": "1.0.5", - "RegexMatcher": "1.0.9", - "Timestamps": "1.0.11", - "UrlMatcher": "3.0.1" - } } } } diff --git a/ChatTwo/websiteBuild.zip b/ChatTwo/websiteBuild.zip deleted file mode 100644 index 988d9fb..0000000 Binary files a/ChatTwo/websiteBuild.zip and /dev/null differ