mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-07-12 17:01:55 +02:00
Add markdown link support; fold bot instructions into markdown; set TextBlock properties directly
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Avalonia.Controls.Documents;
|
using Avalonia.Controls.Documents;
|
||||||
using Avalonia.Data.Converters;
|
using Avalonia.Data.Converters;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using DiscordChatExporter.Gui.Utils.Extensions;
|
||||||
|
using DiscordChatExporter.Gui.Views.Controls;
|
||||||
using Markdig;
|
using Markdig;
|
||||||
using Markdig.Syntax;
|
using Markdig.Syntax;
|
||||||
using Markdig.Syntax.Inlines;
|
using Markdig.Syntax.Inlines;
|
||||||
@@ -78,6 +82,24 @@ public class MarkdownToInlinesConverter : IValueConverter
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LinkInline link when link.Url is not null:
|
||||||
|
{
|
||||||
|
var text = string.Concat(
|
||||||
|
link.OfType<LiteralInline>().Select(l => l.Content.ToString())
|
||||||
|
);
|
||||||
|
var url = link.Url;
|
||||||
|
inlines.Add(
|
||||||
|
new InlineUIContainer(
|
||||||
|
new HyperLink
|
||||||
|
{
|
||||||
|
Text = text,
|
||||||
|
Command = new RelayCommand(() => Process.StartShellExecute(url)),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ContainerInline container:
|
case ContainerInline container:
|
||||||
{
|
{
|
||||||
foreach (var child in container)
|
foreach (var child in container)
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ public partial class LocalizationManager
|
|||||||
""",
|
""",
|
||||||
// Token instructions (bot)
|
// Token instructions (bot)
|
||||||
[nameof(TokenBotHeader)] = "To get the token for your bot:",
|
[nameof(TokenBotHeader)] = "To get the token for your bot:",
|
||||||
[nameof(TokenBotIntro)] =
|
|
||||||
"The token is generated during bot creation. If you lost it, generate a new one:",
|
|
||||||
[nameof(TokenBotStep1)] = "1. Open Discord",
|
|
||||||
[nameof(TokenBotInstructions)] = """
|
[nameof(TokenBotInstructions)] = """
|
||||||
|
The token is generated during bot creation. If you lost it, generate a new one:
|
||||||
|
|
||||||
|
1. Open Discord [developer portal](https://discord.com/developers/applications)
|
||||||
2. Open your application's settings
|
2. Open your application's settings
|
||||||
3. Navigate to the **Bot** section on the left
|
3. Navigate to the **Bot** section on the left
|
||||||
4. Under **Token** click **Reset Token**
|
4. Under **Token** click **Reset Token**
|
||||||
@@ -41,9 +41,8 @@ public partial class LocalizationManager
|
|||||||
* Integrations using the previous token will stop working until updated
|
* Integrations using the previous token will stop working until updated
|
||||||
* Your bot needs to have the **Message Content Intent** enabled to read messages
|
* Your bot needs to have the **Message Content Intent** enabled to read messages
|
||||||
""",
|
""",
|
||||||
[nameof(TokenDeveloperPortalLinkText)] = "developer portal",
|
[nameof(TokenHelpText)] =
|
||||||
[nameof(TokenDocumentationLinkText)] = "documentation",
|
"If you have questions or issues, please refer to the [documentation](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)",
|
||||||
[nameof(TokenHelpText)] = "If you have questions or issues, please refer to the",
|
|
||||||
// Settings
|
// Settings
|
||||||
[nameof(SettingsTitle)] = "Settings",
|
[nameof(SettingsTitle)] = "Settings",
|
||||||
[nameof(ThemeLabel)] = "Theme",
|
[nameof(ThemeLabel)] = "Theme",
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ public partial class LocalizationManager
|
|||||||
""",
|
""",
|
||||||
// Token instructions (bot)
|
// Token instructions (bot)
|
||||||
[nameof(TokenBotHeader)] = "Obtenir le token pour votre bot :",
|
[nameof(TokenBotHeader)] = "Obtenir le token pour votre bot :",
|
||||||
[nameof(TokenBotIntro)] =
|
|
||||||
"Le token est généré lors de la création du bot. Si vous l'avez perdu, générez-en un nouveau :",
|
|
||||||
[nameof(TokenBotStep1)] = "1. Ouvrez Discord",
|
|
||||||
[nameof(TokenBotInstructions)] = """
|
[nameof(TokenBotInstructions)] = """
|
||||||
|
Le token est généré lors de la création du bot. Si vous l'avez perdu, générez-en un nouveau :
|
||||||
|
|
||||||
|
1. Ouvrez Discord [portail développeur](https://discord.com/developers/applications)
|
||||||
2. Ouvrez les paramètres de votre application
|
2. Ouvrez les paramètres de votre application
|
||||||
3. Naviguez vers la section **Bot** à gauche
|
3. Naviguez vers la section **Bot** à gauche
|
||||||
4. Sous **Token**, cliquez sur **Reset Token**
|
4. Sous **Token**, cliquez sur **Reset Token**
|
||||||
@@ -43,9 +43,8 @@ public partial class LocalizationManager
|
|||||||
* Les intégrations utilisant l'ancien token cesseront de fonctionner jusqu'à leur mise à jour
|
* Les intégrations utilisant l'ancien token cesseront de fonctionner jusqu'à leur mise à jour
|
||||||
* Votre bot doit avoir l'option **Message Content Intent** activée pour lire les messages
|
* Votre bot doit avoir l'option **Message Content Intent** activée pour lire les messages
|
||||||
""",
|
""",
|
||||||
[nameof(TokenDeveloperPortalLinkText)] = "portail développeur",
|
[nameof(TokenHelpText)] =
|
||||||
[nameof(TokenDocumentationLinkText)] = "documentation",
|
"Pour les questions ou problèmes, veuillez consulter la [documentation](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)",
|
||||||
[nameof(TokenHelpText)] = "Pour les questions ou problèmes, veuillez consulter la",
|
|
||||||
// Settings
|
// Settings
|
||||||
[nameof(SettingsTitle)] = "Paramètres",
|
[nameof(SettingsTitle)] = "Paramètres",
|
||||||
[nameof(ThemeLabel)] = "Thème",
|
[nameof(ThemeLabel)] = "Thème",
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ public partial class LocalizationManager
|
|||||||
""",
|
""",
|
||||||
// Token instructions (bot)
|
// Token instructions (bot)
|
||||||
[nameof(TokenBotHeader)] = "Token für Ihren Bot abrufen:",
|
[nameof(TokenBotHeader)] = "Token für Ihren Bot abrufen:",
|
||||||
[nameof(TokenBotIntro)] =
|
|
||||||
"Der Token wird bei der Bot-Erstellung generiert. Falls er verloren gegangen ist, generieren Sie einen neuen:",
|
|
||||||
[nameof(TokenBotStep1)] = "1. Öffnen Sie Discord",
|
|
||||||
[nameof(TokenBotInstructions)] = """
|
[nameof(TokenBotInstructions)] = """
|
||||||
|
Der Token wird bei der Bot-Erstellung generiert. Falls er verloren gegangen ist, generieren Sie einen neuen:
|
||||||
|
|
||||||
|
1. Öffnen Sie Discord [Entwicklerportal](https://discord.com/developers/applications)
|
||||||
2. Öffnen Sie die Einstellungen Ihrer Anwendung
|
2. Öffnen Sie die Einstellungen Ihrer Anwendung
|
||||||
3. Navigieren Sie zum Abschnitt **Bot** auf der linken Seite
|
3. Navigieren Sie zum Abschnitt **Bot** auf der linken Seite
|
||||||
4. Klicken Sie unter **Token** auf **Reset Token**
|
4. Klicken Sie unter **Token** auf **Reset Token**
|
||||||
@@ -43,9 +43,8 @@ public partial class LocalizationManager
|
|||||||
* Integrationen, die den alten Token verwenden, hören auf zu funktionieren, bis sie aktualisiert werden
|
* Integrationen, die den alten Token verwenden, hören auf zu funktionieren, bis sie aktualisiert werden
|
||||||
* Ihr Bot benötigt die aktivierte **Message Content Intent**, um Nachrichten zu lesen
|
* Ihr Bot benötigt die aktivierte **Message Content Intent**, um Nachrichten zu lesen
|
||||||
""",
|
""",
|
||||||
[nameof(TokenDeveloperPortalLinkText)] = "Entwicklerportal",
|
[nameof(TokenHelpText)] =
|
||||||
[nameof(TokenDocumentationLinkText)] = "Dokumentation",
|
"Bei Fragen oder Problemen lesen Sie die [Dokumentation](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)",
|
||||||
[nameof(TokenHelpText)] = "Bei Fragen oder Problemen lesen Sie die",
|
|
||||||
// Settings
|
// Settings
|
||||||
[nameof(SettingsTitle)] = "Einstellungen",
|
[nameof(SettingsTitle)] = "Einstellungen",
|
||||||
[nameof(ThemeLabel)] = "Design",
|
[nameof(ThemeLabel)] = "Design",
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ public partial class LocalizationManager
|
|||||||
""",
|
""",
|
||||||
// Token instructions (bot)
|
// Token instructions (bot)
|
||||||
[nameof(TokenBotHeader)] = "Cómo obtener el token para tu bot:",
|
[nameof(TokenBotHeader)] = "Cómo obtener el token para tu bot:",
|
||||||
[nameof(TokenBotIntro)] =
|
|
||||||
"El token se genera al crear el bot. Si lo perdiste, genera uno nuevo:",
|
|
||||||
[nameof(TokenBotStep1)] = "1. Abre Discord",
|
|
||||||
[nameof(TokenBotInstructions)] = """
|
[nameof(TokenBotInstructions)] = """
|
||||||
|
El token se genera al crear el bot. Si lo perdiste, genera uno nuevo:
|
||||||
|
|
||||||
|
1. Abre Discord [portal de desarrolladores](https://discord.com/developers/applications)
|
||||||
2. Abre la configuración de tu aplicación
|
2. Abre la configuración de tu aplicación
|
||||||
3. Navega a la sección **Bot** en el lado izquierdo
|
3. Navega a la sección **Bot** en el lado izquierdo
|
||||||
4. En **Token**, haz clic en **Reset Token**
|
4. En **Token**, haz clic en **Reset Token**
|
||||||
@@ -41,9 +41,8 @@ public partial class LocalizationManager
|
|||||||
* Las integraciones que usen el token anterior dejarán de funcionar hasta que se actualicen
|
* Las integraciones que usen el token anterior dejarán de funcionar hasta que se actualicen
|
||||||
* Tu bot necesita tener habilitado **Message Content Intent** para leer mensajes
|
* Tu bot necesita tener habilitado **Message Content Intent** para leer mensajes
|
||||||
""",
|
""",
|
||||||
[nameof(TokenDeveloperPortalLinkText)] = "portal de desarrolladores",
|
[nameof(TokenHelpText)] =
|
||||||
[nameof(TokenDocumentationLinkText)] = "documentación",
|
"Si tienes preguntas o problemas, consulta la [documentación](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)",
|
||||||
[nameof(TokenHelpText)] = "Si tienes preguntas o problemas, consulta la",
|
|
||||||
// Settings
|
// Settings
|
||||||
[nameof(SettingsTitle)] = "Ajustes",
|
[nameof(SettingsTitle)] = "Ajustes",
|
||||||
[nameof(ThemeLabel)] = "Tema",
|
[nameof(ThemeLabel)] = "Tema",
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ public partial class LocalizationManager
|
|||||||
""",
|
""",
|
||||||
// Token instructions (bot)
|
// Token instructions (bot)
|
||||||
[nameof(TokenBotHeader)] = "Як отримати токен для бота:",
|
[nameof(TokenBotHeader)] = "Як отримати токен для бота:",
|
||||||
[nameof(TokenBotIntro)] =
|
|
||||||
"Токен генерується під час створення бота. Якщо ви його втратили, згенеруйте новий:",
|
|
||||||
[nameof(TokenBotStep1)] = "1. Відкрийте Discord",
|
|
||||||
[nameof(TokenBotInstructions)] = """
|
[nameof(TokenBotInstructions)] = """
|
||||||
|
Токен генерується під час створення бота. Якщо ви його втратили, згенеруйте новий:
|
||||||
|
|
||||||
|
1. Відкрийте Discord [портал розробника](https://discord.com/developers/applications)
|
||||||
2. Відкрийте налаштування вашого застосунку
|
2. Відкрийте налаштування вашого застосунку
|
||||||
3. Перейдіть до розділу **Bot** ліворуч
|
3. Перейдіть до розділу **Bot** ліворуч
|
||||||
4. В розділі **Token** натисніть **Reset Token**
|
4. В розділі **Token** натисніть **Reset Token**
|
||||||
@@ -41,9 +41,8 @@ public partial class LocalizationManager
|
|||||||
* Інтеграції, що використовують попередній токен, перестануть працювати
|
* Інтеграції, що використовують попередній токен, перестануть працювати
|
||||||
* Ваш бот повинен мати включений **Message Content Intent** для читання повідомлень
|
* Ваш бот повинен мати включений **Message Content Intent** для читання повідомлень
|
||||||
""",
|
""",
|
||||||
[nameof(TokenDeveloperPortalLinkText)] = "портал розробника",
|
[nameof(TokenHelpText)] =
|
||||||
[nameof(TokenDocumentationLinkText)] = "документацію",
|
"Якщо у вас є запитання або проблеми, зверніться до [документації](https://github.com/Tyrrrz/DiscordChatExporter/tree/master/.docs)",
|
||||||
[nameof(TokenHelpText)] = "Якщо у вас є запитання або проблеми, зверніться до",
|
|
||||||
// Settings
|
// Settings
|
||||||
[nameof(SettingsTitle)] = "Налаштування",
|
[nameof(SettingsTitle)] = "Налаштування",
|
||||||
[nameof(ThemeLabel)] = "Тема",
|
[nameof(ThemeLabel)] = "Тема",
|
||||||
|
|||||||
@@ -91,11 +91,7 @@ public partial class LocalizationManager
|
|||||||
|
|
||||||
// Token instructions (bot)
|
// Token instructions (bot)
|
||||||
public string TokenBotHeader => Get();
|
public string TokenBotHeader => Get();
|
||||||
public string TokenBotIntro => Get();
|
|
||||||
public string TokenBotStep1 => Get();
|
|
||||||
public string TokenBotInstructions => Get();
|
public string TokenBotInstructions => Get();
|
||||||
public string TokenDeveloperPortalLinkText => Get();
|
|
||||||
public string TokenDocumentationLinkText => Get();
|
|
||||||
public string TokenHelpText => Get();
|
public string TokenHelpText => Get();
|
||||||
|
|
||||||
// ---- Settings ----
|
// ---- Settings ----
|
||||||
|
|||||||
@@ -107,9 +107,6 @@ public partial class DashboardViewModel : ViewModelBase
|
|||||||
private async Task ShowSettingsAsync() =>
|
private async Task ShowSettingsAsync() =>
|
||||||
await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel());
|
await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel());
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
private void ShowHelp() => Process.StartShellExecute(Program.ProjectDocumentationUrl);
|
|
||||||
|
|
||||||
private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token);
|
private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token);
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(CanPullGuilds))]
|
[RelayCommand(CanExecute = nameof(CanPullGuilds))]
|
||||||
@@ -330,13 +327,6 @@ public partial class DashboardViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
private void OpenDiscord() => Process.StartShellExecute("https://discord.com/app");
|
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
private void OpenDiscordDeveloperPortal() =>
|
|
||||||
Process.StartShellExecute("https://discord.com/developers/applications");
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||||
xmlns:components="clr-namespace:DiscordChatExporter.Gui.ViewModels.Components"
|
xmlns:components="clr-namespace:DiscordChatExporter.Gui.ViewModels.Components"
|
||||||
xmlns:controls="clr-namespace:DiscordChatExporter.Gui.Views.Controls"
|
|
||||||
xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters"
|
xmlns:converters="clr-namespace:DiscordChatExporter.Gui.Converters"
|
||||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
xmlns:materialStyles="clr-namespace:Material.Styles.Controls;assembly=Material.Styles"
|
xmlns:materialStyles="clr-namespace:Material.Styles.Controls;assembly=Material.Styles"
|
||||||
@@ -220,14 +219,6 @@
|
|||||||
<Panel IsVisible="{Binding !AvailableGuilds.Count}">
|
<Panel IsVisible="{Binding !AvailableGuilds.Count}">
|
||||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||||
<StackPanel Margin="32,16" Spacing="0">
|
<StackPanel Margin="32,16" Spacing="0">
|
||||||
<StackPanel.Styles>
|
|
||||||
<Style Selector="TextBlock">
|
|
||||||
<Setter Property="FontSize" Value="14" />
|
|
||||||
<Setter Property="FontWeight" Value="Light" />
|
|
||||||
<Setter Property="LineHeight" Value="23" />
|
|
||||||
<Setter Property="TextWrapping" Value="Wrap" />
|
|
||||||
</Style>
|
|
||||||
</StackPanel.Styles>
|
|
||||||
|
|
||||||
<!-- User token -->
|
<!-- User token -->
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
@@ -246,9 +237,17 @@
|
|||||||
Text="{Binding LocalizationManager.TokenPersonalHeader}" />
|
Text="{Binding LocalizationManager.TokenPersonalHeader}" />
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|
||||||
<TextBlock Inlines="{Binding LocalizationManager.TokenPersonalTosWarning, Converter={x:Static converters:MarkdownToInlinesConverter.Instance}}" />
|
<TextBlock Inlines="{Binding LocalizationManager.TokenPersonalTosWarning, Converter={x:Static converters:MarkdownToInlinesConverter.Instance}}"
|
||||||
|
FontSize="14"
|
||||||
|
FontWeight="Light"
|
||||||
|
LineHeight="23"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
<TextBlock Inlines="{Binding LocalizationManager.TokenPersonalInstructions, Converter={x:Static converters:MarkdownToInlinesConverter.Instance}}" />
|
<TextBlock Inlines="{Binding LocalizationManager.TokenPersonalInstructions, Converter={x:Static converters:MarkdownToInlinesConverter.Instance}}"
|
||||||
|
FontSize="14"
|
||||||
|
FontWeight="Light"
|
||||||
|
LineHeight="23"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
<!-- Bot token -->
|
<!-- Bot token -->
|
||||||
<TextBlock Margin="0,12,0,0">
|
<TextBlock Margin="0,12,0,0">
|
||||||
@@ -267,19 +266,18 @@
|
|||||||
Text="{Binding LocalizationManager.TokenBotHeader}" />
|
Text="{Binding LocalizationManager.TokenBotHeader}" />
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|
||||||
<TextBlock Text="{Binding LocalizationManager.TokenBotIntro}" />
|
<TextBlock Inlines="{Binding LocalizationManager.TokenBotInstructions, Converter={x:Static converters:MarkdownToInlinesConverter.Instance}}"
|
||||||
|
FontSize="14"
|
||||||
|
FontWeight="Light"
|
||||||
|
LineHeight="23"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
<TextBlock>
|
<TextBlock Margin="0,12,0,0"
|
||||||
<Run Text="{Binding LocalizationManager.TokenBotStep1}" />
|
FontSize="14"
|
||||||
<controls:HyperLink Command="{Binding OpenDiscordDeveloperPortalCommand}" Text="{Binding LocalizationManager.TokenDeveloperPortalLinkText}" />
|
FontWeight="Light"
|
||||||
</TextBlock>
|
LineHeight="23"
|
||||||
|
TextWrapping="Wrap"
|
||||||
<TextBlock Inlines="{Binding LocalizationManager.TokenBotInstructions, Converter={x:Static converters:MarkdownToInlinesConverter.Instance}}" />
|
Inlines="{Binding LocalizationManager.TokenHelpText, Converter={x:Static converters:MarkdownToInlinesConverter.Instance}}" />
|
||||||
|
|
||||||
<TextBlock Margin="0,12,0,0">
|
|
||||||
<Run Text="{Binding LocalizationManager.TokenHelpText}" />
|
|
||||||
<controls:HyperLink Command="{Binding ShowHelpCommand}" Text="{Binding LocalizationManager.TokenDocumentationLinkText}" />
|
|
||||||
</TextBlock>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|||||||
Reference in New Issue
Block a user