mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-06-06 17:41:26 -04:00
Remove message group limit setting
This commit is contained in:
parent
9b78472e05
commit
33f71c1612
9 changed files with 3 additions and 31 deletions
|
@ -26,8 +26,6 @@ namespace DiscordChatExporter.Cli.Verbs
|
||||||
// Configure settings
|
// Configure settings
|
||||||
if (Options.DateFormat.IsNotBlank())
|
if (Options.DateFormat.IsNotBlank())
|
||||||
settingsService.DateFormat = Options.DateFormat;
|
settingsService.DateFormat = Options.DateFormat;
|
||||||
if (Options.MessageGroupLimit > 0)
|
|
||||||
settingsService.MessageGroupLimit = Options.MessageGroupLimit;
|
|
||||||
|
|
||||||
// Track progress
|
// Track progress
|
||||||
Console.Write($"Exporting channel [{Options.ChannelId}]... ");
|
Console.Write($"Exporting channel [{Options.ChannelId}]... ");
|
||||||
|
|
|
@ -29,8 +29,6 @@ namespace DiscordChatExporter.Cli.Verbs
|
||||||
// Configure settings
|
// Configure settings
|
||||||
if (Options.DateFormat.IsNotBlank())
|
if (Options.DateFormat.IsNotBlank())
|
||||||
settingsService.DateFormat = Options.DateFormat;
|
settingsService.DateFormat = Options.DateFormat;
|
||||||
if (Options.MessageGroupLimit > 0)
|
|
||||||
settingsService.MessageGroupLimit = Options.MessageGroupLimit;
|
|
||||||
|
|
||||||
// Get channels
|
// Get channels
|
||||||
var channels = await dataService.GetDirectMessageChannelsAsync(Options.GetToken());
|
var channels = await dataService.GetDirectMessageChannelsAsync(Options.GetToken());
|
||||||
|
|
|
@ -30,8 +30,6 @@ namespace DiscordChatExporter.Cli.Verbs
|
||||||
// Configure settings
|
// Configure settings
|
||||||
if (Options.DateFormat.IsNotBlank())
|
if (Options.DateFormat.IsNotBlank())
|
||||||
settingsService.DateFormat = Options.DateFormat;
|
settingsService.DateFormat = Options.DateFormat;
|
||||||
if (Options.MessageGroupLimit > 0)
|
|
||||||
settingsService.MessageGroupLimit = Options.MessageGroupLimit;
|
|
||||||
|
|
||||||
// Get channels
|
// Get channels
|
||||||
var channels = await dataService.GetGuildChannelsAsync(Options.GetToken(), Options.GuildId);
|
var channels = await dataService.GetGuildChannelsAsync(Options.GetToken(), Options.GuildId);
|
||||||
|
|
|
@ -23,8 +23,5 @@ namespace DiscordChatExporter.Cli.Verbs.Options
|
||||||
|
|
||||||
[Option("dateformat", Default = null, HelpText = "Date format used in output.")]
|
[Option("dateformat", Default = null, HelpText = "Date format used in output.")]
|
||||||
public string DateFormat { get; set; }
|
public string DateFormat { get; set; }
|
||||||
|
|
||||||
[Option("grouplimit", Default = 0, HelpText = "Message group limit.")]
|
|
||||||
public int MessageGroupLimit { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,14 +18,12 @@ namespace DiscordChatExporter.Core.Services
|
||||||
private readonly ExportFormat _format;
|
private readonly ExportFormat _format;
|
||||||
private readonly ChatLog _log;
|
private readonly ChatLog _log;
|
||||||
private readonly string _dateFormat;
|
private readonly string _dateFormat;
|
||||||
private readonly int _messageGroupLimit;
|
|
||||||
|
|
||||||
public TemplateModel(ExportFormat format, ChatLog log, string dateFormat, int messageGroupLimit)
|
public TemplateModel(ExportFormat format, ChatLog log, string dateFormat)
|
||||||
{
|
{
|
||||||
_format = format;
|
_format = format;
|
||||||
_log = log;
|
_log = log;
|
||||||
_dateFormat = dateFormat;
|
_dateFormat = dateFormat;
|
||||||
_messageGroupLimit = messageGroupLimit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<MessageGroup> GroupMessages(IEnumerable<Message> messages)
|
private IEnumerable<MessageGroup> GroupMessages(IEnumerable<Message> messages)
|
||||||
|
@ -39,8 +37,7 @@ namespace DiscordChatExporter.Core.Services
|
||||||
buffer.Any() &&
|
buffer.Any() &&
|
||||||
(
|
(
|
||||||
message.Author.Id != buffer.First().Author.Id || // when author changes
|
message.Author.Id != buffer.First().Author.Id || // when author changes
|
||||||
(message.Timestamp - buffer.Last().Timestamp).TotalMinutes > 7 || // when more than 7 minutes passed since last message
|
(message.Timestamp - buffer.Last().Timestamp).TotalMinutes > 7 // when more than 7 minutes passed since last message
|
||||||
buffer.Count >= _messageGroupLimit // when group is full
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// If condition is true - flush buffer
|
// If condition is true - flush buffer
|
||||||
|
|
|
@ -36,8 +36,7 @@ namespace DiscordChatExporter.Core.Services
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create template model
|
// Create template model
|
||||||
var templateModel = new TemplateModel(format, chatLog,
|
var templateModel = new TemplateModel(format, chatLog, _settingsService.DateFormat);
|
||||||
_settingsService.DateFormat, _settingsService.MessageGroupLimit);
|
|
||||||
|
|
||||||
context.PushGlobal(templateModel.GetScriptObject());
|
context.PushGlobal(templateModel.GetScriptObject());
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace DiscordChatExporter.Core.Services
|
||||||
public bool IsAutoUpdateEnabled { get; set; } = true;
|
public bool IsAutoUpdateEnabled { get; set; } = true;
|
||||||
|
|
||||||
public string DateFormat { get; set; } = "dd-MMM-yy hh:mm tt";
|
public string DateFormat { get; set; } = "dd-MMM-yy hh:mm tt";
|
||||||
public int MessageGroupLimit { get; set; } = 20;
|
|
||||||
|
|
||||||
public AuthToken LastToken { get; set; }
|
public AuthToken LastToken { get; set; }
|
||||||
public ExportFormat LastExportFormat { get; set; } = ExportFormat.HtmlDark;
|
public ExportFormat LastExportFormat { get; set; } = ExportFormat.HtmlDark;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using DiscordChatExporter.Core.Services;
|
using DiscordChatExporter.Core.Services;
|
||||||
using DiscordChatExporter.Gui.ViewModels.Framework;
|
using DiscordChatExporter.Gui.ViewModels.Framework;
|
||||||
using Tyrrrz.Extensions;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Gui.ViewModels.Dialogs
|
namespace DiscordChatExporter.Gui.ViewModels.Dialogs
|
||||||
{
|
{
|
||||||
|
@ -20,12 +19,6 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
|
||||||
set => _settingsService.DateFormat = value;
|
set => _settingsService.DateFormat = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int MessageGroupLimit
|
|
||||||
{
|
|
||||||
get => _settingsService.MessageGroupLimit;
|
|
||||||
set => _settingsService.MessageGroupLimit = value.ClampMin(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SettingsViewModel(SettingsService settingsService)
|
public SettingsViewModel(SettingsService settingsService)
|
||||||
{
|
{
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
|
|
|
@ -25,13 +25,6 @@
|
||||||
materialDesign:HintAssist.IsFloating="True"
|
materialDesign:HintAssist.IsFloating="True"
|
||||||
Text="{Binding DateFormat}" />
|
Text="{Binding DateFormat}" />
|
||||||
|
|
||||||
<!-- Message group limit -->
|
|
||||||
<TextBox
|
|
||||||
Margin="16,8"
|
|
||||||
materialDesign:HintAssist.Hint="Message group limit"
|
|
||||||
materialDesign:HintAssist.IsFloating="True"
|
|
||||||
Text="{Binding MessageGroupLimit}" />
|
|
||||||
|
|
||||||
<!-- Auto-updates -->
|
<!-- Auto-updates -->
|
||||||
<DockPanel LastChildFill="False">
|
<DockPanel LastChildFill="False">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue