mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-07-07 06:39:33 +02:00
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0ea57e9b1 | |||
| 7c04db40f8 | |||
| 4588bd0496 | |||
| 3a22db14a7 | |||
| ba72927c37 | |||
| 822bab2365 | |||
| 211db11041 | |||
| 9b8985a920 | |||
| 014712b747 | |||
| d8e43d89be | |||
| 4e69ff317b | |||
| 057beaacd6 | |||
| 982ba6a76c | |||
| dccd9a2f08 | |||
| 182f24846b | |||
| 777f92a3f1 | |||
| d4be307fb1 | |||
| 2bbb585931 | |||
| 73080ecfa6 | |||
| 0745d49f44 | |||
| c16e14e9b6 | |||
| 8e36002ae7 | |||
| a2c5d2e2dd | |||
| 4e3deb409c | |||
| 512f181be2 | |||
| e04eb890e6 | |||
| 1ad42ee48b | |||
| b8a67617bc | |||
| 062427d143 | |||
| 5f343a46d1 | |||
| b3a1cbf635 | |||
| 619fe9ccf7 | |||
| 174b92cbb0 | |||
| d0873ecfa7 | |||
| cfbbc4b8e2 | |||
| ee436f8e68 | |||
| cf77cb4688 | |||
| 309e58116a | |||
| 116cdc0746 | |||
| d481f73020 | |||
| daa6f1e696 | |||
| e6f9a364e1 | |||
| 0f6841593f | |||
| 2262d0abfb | |||
| ab535233dc | |||
| dcaceaddaf | |||
| 2a787d2749 | |||
| 481ddc4cd5 | |||
| c493518eaf | |||
| 450866d1f5 | |||
| 60c8703e78 | |||
| 1c343b75f8 | |||
| b2a22ab2a9 | |||
| b2ac5d8b45 | |||
| 008c2e64aa | |||
| 576ee73bfc | |||
| db1da5545a | |||
| 5397b0db7d | |||
| e89701e3f9 | |||
| a46bf9bf11 | |||
| 8dc024d244 | |||
| 9a125db0ea | |||
| d9c35f4405 | |||
| 5846129cc6 | |||
| 6f5f747632 | |||
| 6a71c59b6d | |||
| 73574ade48 | |||
| 743db67f91 | |||
| 5d7a74eece | |||
| 129df42de4 | |||
| 6508455f3a | |||
| 50b26c557f | |||
| b709fc0f15 | |||
| c118a0bb94 | |||
| 1418bec0c7 | |||
| 750fd69a50 | |||
| b1297bb7df | |||
| 3189111a0e | |||
| 6ec2c04aa3 | |||
| 7c014bf64d | |||
| c875f8f4f0 | |||
| 69e2c337d8 | |||
| 77c770acdd |
+19
-11
@@ -2,7 +2,8 @@
|
||||
|
||||
Docker distribution of DiscordChatExporter provides a way to run the app in a virtualized and isolated environment. Due to the nature of Docker, you also don't need to install any prerequisites otherwise required by DCE.
|
||||
|
||||
Note that only the CLI flavor of DiscordChatExporter is available for use with Docker.
|
||||
> **Note**:
|
||||
> Only the CLI flavor of DiscordChatExporter is available for use with Docker.
|
||||
|
||||
## Pulling
|
||||
|
||||
@@ -14,9 +15,9 @@ docker pull tyrrrz/discordchatexporter:stable
|
||||
|
||||
Note the `:stable` tag. DiscordChatExporter images are tagged according to the following patterns:
|
||||
|
||||
- `stable`: Latest stable version release and maps to the latest GitHub release. This tag is updated with release of each new version. Recommended for personal use.
|
||||
- `latest`: Built from the latest commit and maps to the latest CI build on GitHub. This tag is updated with each new commit to `master` branch. Not recommended for everyday use, but you can use it if you want to try out some features that haven't been officially released yet.
|
||||
- `x.y.z` (e.g. `2.30.1`): Fixed version release and maps to the corresponding tag on GitHub. This tag is never updated once that version has been released. Recommended for use in automation scenarios.
|
||||
- `stable` — latest stable version release. This tag is updated with each release of a new project version. Recommended for personal use.
|
||||
- `x.y.z` (e.g. `2.30.1`) — specific stable version release. This tag is pushed when the corresponding version is released and never updated thereafter. Recommended for use in automation scenarios.
|
||||
- `latest` — latest (potentially unstable) build. This tag is updated with each new commit to the `master` branch. Not recommended, unless you want to test a new feature that has not been released in a stable version yet.
|
||||
|
||||
You can see all available tags [here](https://hub.docker.com/r/tyrrrz/discordchatexporter/tags?ordering=name).
|
||||
|
||||
@@ -34,13 +35,13 @@ To export a channel:
|
||||
docker run --rm -v /path/on/machine:/out tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
||||
```
|
||||
|
||||
If you want colored output and real-time progress reporting, pass the `-it` (interactive) option:
|
||||
If you want colored output and real-time progress reporting, pass the `-it` (interactive + pseudo-terminal) option:
|
||||
|
||||
```console
|
||||
docker run --rm -it -v /path/on/machine:/out tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
||||
```
|
||||
|
||||
Note the `-v /path/on/machine:/out` option, which instructs Docker to bind the `/out` directory inside the container to a path on your host machine. Replace `/path/on/machine` with the directory you want the files to be saved at.
|
||||
The `-v /path/on/machine:/out` option instructs Docker to bind the `/out` directory inside the container to a path on your host machine. Replace `/path/on/machine` with the directory you want the files to be saved at.
|
||||
|
||||
> **Note**:
|
||||
> If you are running SELinux, you will need to add the `:z` option after `/out`, e.g.:
|
||||
@@ -58,14 +59,21 @@ You can also use the current working directory as the output directory by specif
|
||||
|
||||
For more information, please refer to the [Dockerfile](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/DiscordChatExporter.Cli.dockerfile) and [Docker documentation](https://docs.docker.com/engine/reference/run).
|
||||
|
||||
To get your Token and Channel IDs, please refer to [this page](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
To get your Token and Channel IDs, please refer to [this page](Token-and-IDs.md).
|
||||
|
||||
## Unix permissions issues
|
||||
|
||||
This image was designed with a user running as uid:gid of 1000:1000.
|
||||
|
||||
If your current user has different IDs, and you want to generate files directly editable for your user, you might want to run the container like this:
|
||||
|
||||
```console
|
||||
mkdir data # or chown -R $(id -u):$(id -g) data
|
||||
docker run -it --rm -v $PWD/data:/out --user $(id -u):$(id -g) tyrrrz/discordchatexporter:stable export -t TOKEN -g CHANNELID
|
||||
```
|
||||
|
||||
## Environment variables
|
||||
|
||||
DiscordChatExpoter CLI accepts the `DISCORD_TOKEN` environment variable as a fallback for the `--token` option. You can set this variable either with the `--env` Docker option or with a combination of the `--env-file` Docker option and a `.env` file.
|
||||
|
||||
Please refer to the [Docker documentation](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file) for more information.
|
||||
|
||||
## Permission issues with Linux hosts
|
||||
|
||||
When bounding volumes between the container and the host, files mirrored from the Docker container will be owned by the Docker user (in most setups this is `root`). Please refer to this [issue comment](https://github.com/Tyrrrz/DiscordChatExporter/issues/800#issuecomment-1030471970) for instructions on how to override this behavior.
|
||||
|
||||
+23
-39
@@ -1,42 +1,36 @@
|
||||
# Install .NET runtime
|
||||
|
||||
**.NET v7.0 Runtime** is required by **DiscordChatExporter v2.37 and newer**.
|
||||
**.NET 8.0 Runtime** is required by **DiscordChatExporter**.
|
||||
|
||||
If you are using GUI flavor of DiscordChatExporter, the runtime will be installed automatically (since v2.27.1).
|
||||
If you are using the CLI from Docker, installing the runtime on the host machine is not needed.
|
||||
> **Note**:
|
||||
> Installing the **.NET Runtime** is not required if you running **DiscordChatExporter** using [Docker](Docker.md).
|
||||
|
||||
- Install
|
||||
- [Windows and macOS](#windows-and-macos)
|
||||
- [Linux](#linux)
|
||||
- [Docker](#docker)
|
||||
- [Verify installation](#verify-installation-optional)
|
||||
## Windows
|
||||
|
||||
## Windows and macOS
|
||||
Both the GUI and the CLI flavors of **DiscordChatExporter** for Windows come with a bootstrapper that should automatically install all the required prerequisites. Simply run the application and follow the presented instructions.
|
||||
|
||||
**Download directly from one of the links:**
|
||||
If, for some reason, you need to install the runtime manually, use one of the download links below:
|
||||
|
||||
- [.NET v7.0 Runtime for **Windows x64**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-7.0.11-windows-x64-installer)
|
||||
- [.NET v7.0 Runtime for **Windows x86**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-7.0.11-windows-x86-installer)
|
||||
- [.NET v7.0 Runtime for **Macs with Apple silicon**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-7.0.11-macos-arm64-installer)
|
||||
- [.NET v7.0 Runtime for **Macs with an Intel processor**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-7.0.11-macos-x64-installer)
|
||||
- [.NET 8.0 Runtime for **Windows x64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-windows-x86-installer)
|
||||
- [.NET 8.0 Runtime for **Windows x86**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-windows-x64-installer)
|
||||
- [.NET 8.0 Runtime for **Windows arm64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-windows-arm64-installer)
|
||||
|
||||
> **Note**:
|
||||
> [How can I tell if my computer is running a 32-bit (x86) or a 64-bit (x64) version of Windows?](https://support.microsoft.com/help/15056/windows-32-64-bit-faq)
|
||||
|
||||
## macOS
|
||||
|
||||
Use one of the download links below:
|
||||
|
||||
- [.NET 8.0 Runtime for **macOS x64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-macos-x64-installer)
|
||||
- [.NET 8.0 Runtime for **macOS arm64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-macos-arm64-installer)
|
||||
|
||||
> **Note**:
|
||||
> [Is my Mac using an Intel processor or Apple silicon?](https://support.apple.com/HT211814)
|
||||
|
||||
**Otherwise:**
|
||||
[Check out the latest version on this page](https://dotnet.microsoft.com/download/dotnet/7.0).
|
||||
Look for the download link in the '**.NET Runtime**' section, under **Installers**:
|
||||
|
||||
[](https://dotnet.microsoft.com/download/dotnet/7.0)
|
||||
> [Is my Mac using an Intel processor (x64) or Apple Silicon (arm64)?](https://support.apple.com/HT211814)
|
||||
|
||||
## Linux
|
||||
|
||||
Installing the .NET Runtime works differently depending on which Linux distribution you use.
|
||||
|
||||
Check out the instructions for your distro:
|
||||
Installing the .NET Runtime works differently depending on which Linux distribution you use. Check out the instructions for your distro:
|
||||
|
||||
- [Ubuntu](https://docs.microsoft.com/dotnet/core/install/linux-ubuntu)
|
||||
- [Debian](https://docs.microsoft.com/dotnet/core/install/linux-debian)
|
||||
@@ -44,25 +38,15 @@ Check out the instructions for your distro:
|
||||
|
||||
For other distros, please check the _'Install on Linux'_ menu on the left of [this page](https://docs.microsoft.com/dotnet/core/install/linux).
|
||||
|
||||
## Docker
|
||||
|
||||
Installing the .NET Runtime is not needed. Please refer to the [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md) page for more information.
|
||||
|
||||
## Verify installation (optional)
|
||||
|
||||
You can check which version of **.NET Runtime** is installed by following these instructions:
|
||||
You can check which version of **.NET Runtime** is installed by running the following command in a terminal:
|
||||
|
||||
### Step 1
|
||||
```console
|
||||
dotnet --info
|
||||
```
|
||||
|
||||
**Windows:** Open Command Prompt (aka `cmd`)
|
||||
|
||||
**macOS and Linux:** Open `Terminal`
|
||||
|
||||
### Step 2
|
||||
|
||||
Run `dotnet --info`
|
||||
|
||||
If the **.NET Runtime** is correctly installed, the command will output the following:
|
||||
If the **.NET Runtime** is correctly installed, the command will output something similar to the following:
|
||||
|
||||
```console
|
||||
.NET runtimes installed:
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
Welcome to the getting started page!
|
||||
Here you'll learn how to use every **DiscordChatExporter** (DCE for short) feature.
|
||||
For other things you can do with DCE, check out the [Guides](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Readme.md#Guides) section.
|
||||
For other things you can do with DCE, check out the [Guides](Readme.md#guides) section.
|
||||
|
||||
If you still have unanswered questions after reading this page or if you have encountered a problem, please visit our [FAQ & Troubleshooting](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md) section.
|
||||
If you still have unanswered questions after reading this page or if you have encountered a problem, please visit our [FAQ & Troubleshooting](Troubleshooting.md) section.
|
||||
|
||||
The information presented on this page is valid for **all** platforms.
|
||||
|
||||
## GUI or CLI?
|
||||
|
||||

|
||||
|
||||
**DCE** has two different versions:
|
||||
|
||||
- **Graphical User Interface** (**GUI**) - it's the preferred version for newcomers as it is easy to use.
|
||||
@@ -19,12 +20,12 @@ The information presented on this page is valid for **all** platforms.
|
||||
You can get it by [downloading](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest) the `DiscordChatExporter.CLI.zip` file.
|
||||
|
||||
If you're not comfortable with **Windows'** Command-line (cmd), please choose the GUI.
|
||||
[**macOS**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/MacOS.md), [**Linux**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md) and [**Docker**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md) users can only use the CLI version.
|
||||
[**macOS**](MacOS.md), [**Linux**](Linux.md) and [**Docker**](Docker.md) users can only use the CLI version.
|
||||
|
||||
There are dedicated guides for each version:
|
||||
|
||||
- [Using the GUI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-GUI.md)
|
||||
- [Using the CLI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md)
|
||||
- [Using the GUI](Using-the-GUI.md)
|
||||
- [Using the CLI](Using-the-CLI.md)
|
||||
|
||||
## File formats
|
||||
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
## Installing .NET Runtime
|
||||
|
||||
Please follow the [instructions provided here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md).
|
||||
Please follow the [instructions provided here](Dotnet.md).
|
||||
|
||||
## Downloading and using DiscordChatExporter.Cli
|
||||
|
||||
@@ -21,6 +21,6 @@ If the above command throws a "Permission denied" error, execute this command to
|
||||
chmod 644 *.dll DiscordChatExporter.*
|
||||
```
|
||||
|
||||
> [How to get Token and Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
> [How to get Token and Channel IDs](Token-and-IDs.md).
|
||||
|
||||
There's much more you can do with DCE.CLI! Read the [CLI explained](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#dcecli-commands-) page to get started.
|
||||
There's much more you can do with DCE.CLI! Read the [CLI explained](Using-the-CLI.md) page to get started.
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
|
||||
## Installing .NET Runtime
|
||||
|
||||
Please follow the [instructions provided here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md).
|
||||
Please follow the [instructions provided here](Dotnet.md).
|
||||
|
||||
## Downloading and using DiscordChatExporter.Cli
|
||||
|
||||
@@ -17,6 +17,6 @@ Please follow the [instructions provided here](https://github.com/Tyrrrz/Discord
|
||||
dotnet DiscordChatExporter.Cli.dll export -t TOKEN -c CHANNEL
|
||||
```
|
||||
|
||||
> [How to get Token and Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
> [How to get Token and Channel IDs](Token-and-IDs.md).
|
||||
|
||||
There's much more you can do with DCE.CLI! Read the [CLI explained](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#dcecli-commands-) page to get started.
|
||||
There's much more you can do with DCE.CLI! Read the [CLI explained](Using-the-CLI.md) page to get started.
|
||||
|
||||
+16
-16
@@ -2,21 +2,21 @@
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
- [Get .NET Core Runtime](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md) (Required for CLI; Installed automatically for GUI; Not required in Docker)
|
||||
- [Windows](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#gui-or-cli) | [macOS](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/MacOS.md) | [Linux](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md) | [Docker](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md)
|
||||
- [Get .NET Core Runtime](Dotnet.md) (Required for CLI; Installed automatically for GUI; Not required in Docker)
|
||||
- [Windows](Getting-started.md#gui-or-cli) | [macOS](MacOS.md) | [Linux](Linux.md) | [Docker](Docker.md)
|
||||
- Getting started:
|
||||
- [Using the GUI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#using-the-gui)
|
||||
- [Using the CLI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#using-the-cli)
|
||||
- [File formats](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats)
|
||||
- [Using the GUI](Using-the-GUI.md)
|
||||
- [Using the CLI](Using-the-CLI.md)
|
||||
- [File formats](Getting-started.md#file-formats)
|
||||
|
||||
## Guides
|
||||
|
||||
- [How to get Token and Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
||||
- [How to use message filters](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md)
|
||||
- [How to get Token and Channel IDs](Token-and-IDs.md)
|
||||
- [How to use message filters](Message-filters.md)
|
||||
- Export scheduling with CLI:
|
||||
- [Windows](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Scheduling-Windows.md)
|
||||
- [macOS](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Scheduling-MacOS.md)
|
||||
- [Linux](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Scheduling-Linux.md)
|
||||
- [Windows](Scheduling-Windows.md)
|
||||
- [macOS](Scheduling-MacOS.md)
|
||||
- [Linux](Scheduling-Linux.md)
|
||||
|
||||
## Video tutorial
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
|
||||
## FAQ & Troubleshooting
|
||||
|
||||
- [General questions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#general)
|
||||
- [First steps help](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#first-steps)
|
||||
- [It's crashing/failing](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#DCE-is-crashingfailing)
|
||||
- [.NET Core Runtime is required](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#net-core-runtime-is-required)
|
||||
- [Errors](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#errors)
|
||||
- [**More help**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md)
|
||||
- [General questions](Troubleshooting.md#general)
|
||||
- [First steps help](Troubleshooting.md#first-steps)
|
||||
- [It's crashing/failing](Troubleshooting.md#DCE-is-crashingfailing)
|
||||
- [.NET Core Runtime is required](Troubleshooting.md#net-core-runtime-is-required)
|
||||
- [Errors](Troubleshooting.md#errors)
|
||||
- [**More help**](Troubleshooting.md)
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# Scheduling exports with Cron
|
||||
|
||||
Make sure you already have **DiscordChatExporter.CLI** and **.NET Core** properly installed ([instructions here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md)).
|
||||
Make sure you already have **DiscordChatExporter.CLI** and **.NET Core** properly installed ([instructions here](Linux.md)).
|
||||
|
||||
You can use Cron on macOS, but [this method](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-MacOS.md) is preferred.
|
||||
|
||||
---
|
||||
## Creating the script
|
||||
|
||||
1. Open Terminal and create a new text file with `nano /path/to/DiscordChatExporter/cron.sh`
|
||||
|
||||
@@ -66,8 +64,8 @@ exit 0
|
||||
|
||||
3. Replace:
|
||||
|
||||
- `tokenhere` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
- `channelhere` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
- `tokenhere` with your [Token](Token-and-IDs.md).
|
||||
- `channelhere` with a [Channel ID](Token-and-IDs.md).
|
||||
- `dceFOLDERpathhere` with DCE's **directory path** (e.g. `/path/to/folder`, NOT `/path/to/folder/DiscordChatExporter.dll`).
|
||||
- `filenamehere` with the exported channel's filename, without spaces.
|
||||
- `dirhere` with the export directory (e.g. /home/user/Documents/Discord\ Exports).
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Scheduling on macOS is a bit tricky, but it should work if you follow the instructions accordingly.
|
||||
|
||||
Make sure you already have **DiscordChatExporter.CLI** and **.NET Core** properly installed ([instructions here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/macOS-usage-instructions.md)).
|
||||
Make sure you already have **DiscordChatExporter.CLI** and **.NET Core** properly installed ([instructions here](MacOS.md)).
|
||||
|
||||
## Creating the script
|
||||
|
||||
@@ -70,8 +70,8 @@ exit 0
|
||||
|
||||
4. Replace:
|
||||
|
||||
- `tokenhere` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
||||
- `channelhere` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
||||
- `tokenhere` with your [Token](Token-and-IDs.md)
|
||||
- `channelhere` with a [Channel ID](Token-and-IDs.md)
|
||||
- `dceFOLDERpathhere` with DCE's **directory's path** (e.g. `/Users/user/Desktop/DiscordChatExporterFolder`, NOT `/Users/user/Desktop/DiscordChatExporterFolder/DiscordChatExporter.DLL`)
|
||||
- `filenamehere` with the exported channel's filename, without spaces
|
||||
- `dirhere` with the directory you want the files to be saved at (e.g. `/Users/user/Documents/Discord\ Exports`)
|
||||
@@ -168,7 +168,7 @@ Omitted keys are interpreted as wildcards, for example, if you delete the Minute
|
||||
|
||||
Be aware that if you set the day to '31', the script will only run on months that have the 31st day.
|
||||
|
||||
**Check the examples below ([or skip to step 3 (loading the file)](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-MacOS.md#3-loading-the-plist-into-launchctl)):**
|
||||
**Check the examples below ([or skip to step 3 (loading the file)](#3-loading-the-plist-into-launchctl)):**
|
||||
|
||||
Export everyday at 5:15 PM:
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
We'll be using [DiscordChatExporter CLI](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest), PowerShell, and Task Scheduler.
|
||||
|
||||
## Creating the script
|
||||
|
||||
1. Open a text editor such as Notepad and paste:
|
||||
|
||||
```console
|
||||
# Info: https://github.com/Tyrrrz/DiscordChatExporter/wiki
|
||||
# Info: https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs
|
||||
|
||||
$TOKEN = "tokenhere"
|
||||
$CHANNEL = "channelhere"
|
||||
@@ -31,8 +33,8 @@ exit
|
||||
|
||||
2. Replace:
|
||||
|
||||
- `tokenhere` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
||||
- `channelhere` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
||||
- `tokenhere` with your [Token](Token-and-IDs.md)
|
||||
- `channelhere` with a [Channel ID](Token-and-IDs.md)
|
||||
- `exefolderhere` with the .exe **directory's path** (e.g. C:\Users\User\Desktop\DiscordChatExporter)
|
||||
- `filenamehere` with a filename without spaces
|
||||
- `dirhere` with the export directory (e.g. C:\Users\User\Documents\Exports)
|
||||
|
||||
@@ -48,12 +48,12 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
||||
<br clear="right" />
|
||||
<br />
|
||||
|
||||
4. <img width="500" align="right" src="https://i.imgur.com/rnZG8Id.png" />Click the text box labelled `Filter` and type `library`. The entries will filter down to a single entry named `library`.
|
||||
4. <img width="500" align="right" src="https://i.imgur.com/rnZG8Id.png" />Click the text box labelled `Filter` and type `messages`. The entries will filter down to a single request named `messages`. If the request doesn't appear, switch to any other Discord channel to trigger it.
|
||||
|
||||
<br clear="right" />
|
||||
<br />
|
||||
|
||||
5. <img width="500" align="right" src="https://i.imgur.com/29dE3fR.png" />Click the entry named `library`. A panel will open to the right and display details about the entry. Click the `Headers` tab if it isn't already active.
|
||||
5. <img width="500" align="right" src="https://i.imgur.com/29dE3fR.png" />Click the entry named `messages`. A panel will open to the right and display details about the entry. Click the `Headers` tab if it isn't already active.
|
||||
|
||||
<br clear="right" />
|
||||
<br />
|
||||
@@ -136,12 +136,12 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
||||
<br clear="right" />
|
||||
<br />
|
||||
|
||||
3. <img width="500" align="right" src="https://i.imgur.com/efUCfBO.png" />Type `library` into the filter. The network request list will filter out any entries not containing the string `library`.
|
||||
3. <img width="500" align="right" src="https://i.imgur.com/efUCfBO.png" />Type `messages` into the filter. The network request list will filter out any entries not containing the string `messages`. If the request doesn't appear, switch to any other Discord channel to trigger it.
|
||||
|
||||
<br clear="right" />
|
||||
<br />
|
||||
|
||||
4. <img width="500" align="right" src="https://i.imgur.com/cdJZ7Q1.png" />Click `library`. The [network request details pane](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html) will display. The [headers tab](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html#network-monitor-request-details-headers-tab) should be active by default. If it isn’t, click it.
|
||||
4. <img width="500" align="right" src="https://i.imgur.com/cdJZ7Q1.png" />Click `messages`. The [network request details pane](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html) will display. The [headers tab](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html#network-monitor-request-details-headers-tab) should be active by default. If it isn’t, click it.
|
||||
|
||||
<br clear="right" />
|
||||
<br />
|
||||
@@ -232,7 +232,7 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
||||
|
||||
4. Launch Discord.
|
||||
|
||||
5. To find your user token, continue [here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#in-chrome).
|
||||
5. To find your user token, continue [here](#in-chrome).
|
||||
|
||||
#### Via settings menu (BetterDiscord only)
|
||||
|
||||
@@ -252,7 +252,7 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
||||
<br />
|
||||
|
||||
4. Press <kbd>Esc</kbd>. The settings page will close.
|
||||
5. To find your user token, continue [here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#in-chrome).
|
||||
5. To find your user token, continue [here](#in-chrome).
|
||||
|
||||
## How to get a Bot Token
|
||||
|
||||
|
||||
+16
-21
@@ -20,7 +20,7 @@ A token can be used to log into your account, so treat it like a password and ne
|
||||
|
||||
### How can I reset my token?
|
||||
|
||||
Follow the [instructions here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
Follow the [instructions here](Token-and-IDs.md).
|
||||
|
||||
### Will I get banned if I use this?
|
||||
|
||||
@@ -66,31 +66,26 @@ No.
|
||||
|
||||
### How can I find my token?
|
||||
|
||||
Check the following page: [Obtaining token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
||||
Check the following page: [Obtaining token](Token-and-IDs.md)
|
||||
|
||||
### When I open DCE a black window pops up quickly or nothing shows up
|
||||
|
||||
If you have [.NET Core Runtime correctly installed](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md), you might have downloaded the CLi flavor, try [downloading the GUI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#gui-or-cli) instead.
|
||||
|
||||
### I can't open DCE, it sends me to a Visual Studio webpage
|
||||
|
||||
Check the following page:
|
||||
[Installation and usage](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Readme.md#installation--usage)
|
||||
If you have [.NET Core Runtime correctly installed](Dotnet.md), you might have downloaded the CLi flavor, try [downloading the GUI](Getting-started.md#gui-or-cli) instead.
|
||||
|
||||
### How do I run DCE on macOS or Linux?
|
||||
|
||||
Check the following pages:
|
||||
|
||||
- [macOS usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/MacOS.md)
|
||||
- [Linux usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md)
|
||||
- [macOS usage instructions](MacOS.md)
|
||||
- [Linux usage instructions](Linux.md)
|
||||
|
||||
### How can I set DCE to export automatically at certain times?
|
||||
|
||||
Check the following pages to learn how to schedule **DiscordChatExporter.CLI** runs (advanced):
|
||||
|
||||
- [Windows scheduling](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-windows.md)
|
||||
- [macOS scheduling](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-MacOS.md)
|
||||
- [Linux scheduling](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-Linux.md)
|
||||
- [Windows scheduling](Scheduling-Windows.md)
|
||||
- [macOS scheduling](Scheduling-MacOS.md)
|
||||
- [Linux scheduling](Scheduling-Linux.md)
|
||||
|
||||
### The exported file is too large, I can't open it
|
||||
|
||||
@@ -98,13 +93,13 @@ Try opening it with a different program, try partitioning or use a different fil
|
||||
|
||||
### DCE is crashing/failing
|
||||
|
||||
Check the following page: [Installing .NET Core Runtime](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md)
|
||||
Check the following page: [Installing .NET Core Runtime](Dotnet.md)
|
||||
|
||||
If you already have .NET Core installed, please check if your problem is a [known issue](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue) before [opening a bug report](https://github.com/Tyrrrz/DiscordChatExporter/issues/new).
|
||||
|
||||
### .NET Core Runtime is required
|
||||
|
||||
Check the following page: [Installing .NET Core Runtime](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md)
|
||||
Check the following page: [Installing .NET Core Runtime](Dotnet.md)
|
||||
|
||||
### I see messages in the export, but they have no content
|
||||
|
||||
@@ -116,25 +111,25 @@ Your bot is missing the 'Message Content Intent'. Go to the [Discord Developer P
|
||||
|
||||
Check the following page:
|
||||
|
||||
- [Using the CLI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#using-the-cli)
|
||||
- [Using the CLI](Using-the-CLI.md)
|
||||
|
||||
If you're using **Docker**, please refer to the [Docker Usage Instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md) instead.
|
||||
If you're using **Docker**, please refer to the [Docker Usage Instructions](Docker.md) instead.
|
||||
|
||||
### Where can I find the 'Channel IDs'?
|
||||
|
||||
Check the following page:
|
||||
|
||||
- [Obtaining Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
||||
- [Obtaining Channel IDs](Token-and-IDs.md)
|
||||
|
||||
### I can't find Docker exported chats
|
||||
|
||||
Check the following page:
|
||||
|
||||
- [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/docker)
|
||||
- [Docker usage instructions](Docker.md)
|
||||
|
||||
### I can't export Direct Messages
|
||||
|
||||
Make sure you're [copying the DM Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-a-direct-message-channel-id), not the person's user ID.
|
||||
Make sure you're [copying the DM Channel ID](Token-and-IDs.md#how-to-get-a-direct-message-channel-id), not the person's user ID.
|
||||
|
||||
## Errors
|
||||
|
||||
@@ -149,7 +144,7 @@ DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Authenticati
|
||||
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Requested resource does not exist.
|
||||
```
|
||||
|
||||
↳ Check your channel ID, it might be invalid. [Read this if you need help](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
↳ Check your channel ID, it might be invalid. [Read this if you need help](Token-and-IDs.md).
|
||||
|
||||
```console
|
||||
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Access is forbidden.
|
||||
|
||||
+73
-169
@@ -3,8 +3,8 @@
|
||||
## Guide
|
||||
|
||||
> **Note**:
|
||||
> Make sure you have [.NET Core installed](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md) before attempting to run the commands below.
|
||||
> **Docker** users, please refer to the [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md).
|
||||
> Make sure you have [.NET Core installed](Dotnet.md) before attempting to run the commands below.
|
||||
> **Docker** users, please refer to the [Docker usage instructions](Docker.md).
|
||||
|
||||
## Step 1
|
||||
|
||||
@@ -25,7 +25,8 @@ You can also drag and drop the folder on **every platform**.
|
||||
|
||||
## Step 3
|
||||
|
||||
Now we're ready to run the commands. The examples on this page follow the Windows file path format, change the file paths according to your system.
|
||||
Now we're ready to run the commands. The examples on this page follow the Windows file path format, change the file
|
||||
paths according to your system.
|
||||
|
||||
Type the following in Command Prompt (Terminal), then press ENTER to run it. This will list DCE's options.
|
||||
|
||||
@@ -33,52 +34,36 @@ Type the following in Command Prompt (Terminal), then press ENTER to run it. Thi
|
||||
dotnet DiscordChatExporter.Cli.dll
|
||||
```
|
||||
|
||||
> **Docker** users, please refer to the [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md).
|
||||
> **Docker** users, please refer to the [Docker usage instructions](Docker.md).
|
||||
|
||||
## CLI commands
|
||||
|
||||
| Command | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
|
||||
| [export](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#export) | Exports a channel |
|
||||
| [exportdm](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#exportdm) | Exports all direct message channels |
|
||||
| [exportguild](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#exportguild) | Exports all channels within the specified server |
|
||||
| [exportall](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#exportall) | Exports all accessible channels |
|
||||
| [channels](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#channels) | Outputs the list of channels in the given server |
|
||||
| [dm](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#dm) | Outputs the list of direct message channels |
|
||||
| [guilds](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#guilds) | Outputs the list of accessible servers |
|
||||
| [guide](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#guide) | Explains how to obtain token, guild, and channel ID |
|
||||
| Command | Description |
|
||||
|-------------------------|------------------------------------------------------|
|
||||
| export | Exports a channel |
|
||||
| exportdm | Exports all direct message channels |
|
||||
| exportguild | Exports all channels within the specified server |
|
||||
| exportall | Exports all accessible channels |
|
||||
| channels | Outputs the list of channels in the given server |
|
||||
| dm | Outputs the list of direct message channels |
|
||||
| guilds | Outputs the list of accessible servers |
|
||||
| guide | Explains how to obtain token, server, and channel ID |
|
||||
|
||||
To use the commands, you'll need a token. For the instructions on how to get a token, please refer to [this page](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md), or run `dotnet DiscordChatExporter.Cli.dll guide`.
|
||||
To get help with a specific command, please run:
|
||||
To use the commands, you'll need a token. For the instructions on how to get a token, please refer to [this page](Token-and-IDs.md), or run `dotnet DiscordChatExporter.Cli.dll guide`.
|
||||
|
||||
To get help with a specific command, run:
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll command -h
|
||||
dotnet DiscordChatExporter.Cli.dll command --help
|
||||
```
|
||||
|
||||
### `export`
|
||||
For example, to figure out how to use the `export` command, run:
|
||||
|
||||
With this command, you can export **server channels** and **direct messages**.
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll export --help
|
||||
```
|
||||
|
||||
| | Option | Description |
|
||||
| ------ | --------------------------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| **\*** | [-c](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Channel ID(s)](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-guild-id-or-guild-channel-id) |
|
||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent after this date |
|
||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent before this date |
|
||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false |
|
||||
| | [--media-dir](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Directory to store assets from all exported channels in the same place |
|
||||
| | [--locale](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#changing-the-date-format) | Format used when writing dates. Default: en-US |
|
||||
| | -h | Shows help text |
|
||||
|
||||
> **Note**:
|
||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
||||
|
||||
#### Basic usage
|
||||
## Export a specific channel
|
||||
|
||||
You can quickly export with DCE's default settings by using just `-t token` and `-c channelid`.
|
||||
|
||||
@@ -88,7 +73,8 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555
|
||||
|
||||
#### Changing the format
|
||||
|
||||
You can change the export format to `HtmlDark`, `HtmlLight`, `PlainText` `Json` or `Csv` with `-f format`. The default format is `HtmlDark`.
|
||||
You can change the export format to `HtmlDark`, `HtmlLight`, `PlainText` `Json` or `Csv` with `-f format`. The default
|
||||
format is `HtmlDark`.
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -f Json
|
||||
@@ -104,7 +90,8 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -o myserver.htm
|
||||
|
||||
#### Changing the output directory
|
||||
|
||||
You can change the export directory by using `-o` and providing a path that ends with a slash or does not have a file extension.
|
||||
You can change the export directory by using `-o` and providing a path that ends with a slash or does not have a file
|
||||
extension.
|
||||
If any of the folders in the path have a space in its name, escape them with quotes (").
|
||||
|
||||
```console
|
||||
@@ -123,18 +110,20 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -o "C:\Discord
|
||||
|
||||
#### Generating the filename and output directory dynamically
|
||||
|
||||
You can use template tokens to generate the output file path based on the guild and channel metadata.
|
||||
You can use template tokens to generate the output file path based on the server and channel metadata.
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -o "C:\Discord Exports\%G\%T\%C.html"
|
||||
```
|
||||
|
||||
Assuming you are exporting a channel named `"my-channel"` in the `"Text channels"` category from a server called `"My server"`, you will get the following output file path: `C:\Discord Exports\My server\Text channels\my-channel.html`
|
||||
Assuming you are exporting a channel named `"my-channel"` in the `"Text channels"` category from a server
|
||||
called `"My server"`, you will get the following output file
|
||||
path: `C:\Discord Exports\My server\Text channels\my-channel.html`
|
||||
|
||||
Here is the full list of supported template tokens:
|
||||
|
||||
- `%g` - guild ID
|
||||
- `%G` - guild name
|
||||
- `%g` - server ID
|
||||
- `%G` - server name
|
||||
- `%t` - category ID
|
||||
- `%T` - category name
|
||||
- `%c` - channel ID
|
||||
@@ -163,7 +152,8 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -p 20mb
|
||||
#### Downloading assets
|
||||
|
||||
If this option is set, the export will include additional files such as user avatars, attached files, images, etc.
|
||||
Only files that are referenced by the export are downloaded, which means that, for example, user avatars will not be downloaded when using the plain text (TXT) export format.
|
||||
Only files that are referenced by the export are downloaded, which means that, for example, user avatars will not be
|
||||
downloaded when using the plain text (TXT) export format.
|
||||
A folder containing the assets will be created along with the exported chat. They must be kept together.
|
||||
|
||||
```console
|
||||
@@ -172,7 +162,8 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --media
|
||||
|
||||
#### Reusing assets
|
||||
|
||||
Previously downloaded assets can be reused to skip redundant downloads as long as the chat is always exported to the same folder. Using this option can speed up future exports. This option requires the `--media` option.
|
||||
Previously downloaded assets can be reused to skip redundant downloads as long as the chat is always exported to the
|
||||
same folder. Using this option can speed up future exports. This option requires the `--media` option.
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --media --reuse-media
|
||||
@@ -180,7 +171,8 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --media --reuse
|
||||
|
||||
#### Changing the media directory
|
||||
|
||||
By default, the media directory is created alongside the exported chat. You can change this by using `--media-dir` and providing a path that ends with a slash. All of the exported media will be stored in this directory.
|
||||
By default, the media directory is created alongside the exported chat. You can change this by using `--media-dir` and
|
||||
providing a path that ends with a slash. All of the exported media will be stored in this directory.
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --media --media-dir "C:\Discord Media"
|
||||
@@ -188,7 +180,8 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --media --media
|
||||
|
||||
#### Changing the date format
|
||||
|
||||
You can customize how dates are formatted in the exported files by using `--locale` and inserting one of Discord's locales. The default locale is `en-US`.
|
||||
You can customize how dates are formatted in the exported files by using `--locale` and inserting one of Discord's
|
||||
locales. The default locale is `en-US`.
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --locale "de-DE"
|
||||
@@ -211,67 +204,32 @@ dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --after "2019-0
|
||||
```
|
||||
|
||||
**Messages sent in a date range**
|
||||
Use `--before` and `--after` to export messages sent during the provided date range. E.g. messages sent between September 17th, 2019 11:34 PM and September 18th:
|
||||
Use `--before` and `--after` to export messages sent during the provided date range. E.g. messages sent between
|
||||
September 17th, 2019 11:34 PM and September 18th:
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --after "2019-09-17 23:34" --before "2019-09-18"
|
||||
```
|
||||
|
||||
You can try different formats like `17-SEP-2019 11:34 PM` or even refine your ranges down to milliseconds `17-SEP-2019 23:45:30.6170`!
|
||||
You can try different formats like `17-SEP-2019 11:34 PM` or even refine your ranges down to
|
||||
milliseconds `17-SEP-2019 23:45:30.6170`!
|
||||
Don't forget to quote (") the date if it has spaces!
|
||||
More info about .NET date formats [here](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings).
|
||||
More info about .NET date
|
||||
formats [here](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings).
|
||||
|
||||
### `exportdm`
|
||||
### Export channels from a specific server
|
||||
|
||||
This command exports all your **direct messages**.
|
||||
To export all channels in a specific server, use the `exportguild` command and provide the server ID through the `-g|--guild` option:
|
||||
|
||||
| | Option | Description |
|
||||
| ------ | --------------------------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| **\*** | [-c](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Channel ID(s)](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-guild-id-or-guild-channel-id) |
|
||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent after this date |
|
||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent before this date |
|
||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false |
|
||||
| | [--media-dir](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Directory to store assets from all exported channels in the same place |
|
||||
| | [--locale](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#changing-the-date-format) | Format used when writing dates. Default: en-US |
|
||||
| | -h | Shows help text |
|
||||
|
||||
> **Note**:
|
||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
||||
|
||||
### `exportguild`
|
||||
|
||||
This command exports all channels of a **server**.
|
||||
|
||||
| | Option | Description |
|
||||
| ------ | ------------------------------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| **\*** | -g | [Server ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-guild-id-or-guild-channel-id) |
|
||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent after this date |
|
||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent before this date |
|
||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false |
|
||||
| | [--media-dir](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Directory to store assets from all exported channels in the same place |
|
||||
| | [--locale](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#changing-the-date-format) | Format used when writing dates. Default: en-US |
|
||||
| | [--include-threads](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#including-threads) | Specify whether to include threads (and which type) in the export. By default, threads are not included. It has possible values of `none`, `active`, or `all`, indicating which threads should be included. To include both active and archived threads, use `--include-threads all`. |
|
||||
| | [--include-vc](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#including-voice-channels) | Include voice channels in the export. Default: true |
|
||||
| | -h | Shows help text |
|
||||
|
||||
> **Note**:
|
||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll exportguild -t "mfa.Ifrn" -g 21814
|
||||
```
|
||||
|
||||
#### Including threads
|
||||
|
||||
By default, threads are not included in the export. You can change this behavior by using `--include-threads` and specifying which threads should be included. It has possible values of `none`, `active`, or `all`, indicating which threads should be included. To include both active and archived threads, use `--include-threads all`.
|
||||
By default, threads are not included in the export. You can change this behavior by using `--include-threads` and
|
||||
specifying which threads should be included. It has possible values of `none`, `active`, or `all`, indicating which
|
||||
threads should be included. To include both active and archived threads, use `--include-threads all`.
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll exportguild -t "mfa.Ifrn" -g 21814 --include-threads all
|
||||
@@ -279,36 +237,21 @@ dotnet DiscordChatExporter.Cli.dll exportguild -t "mfa.Ifrn" -g 21814 --include-
|
||||
|
||||
#### Including voice channels
|
||||
|
||||
By default, voice channels are included in the export. You can change this behavior by using `--include-vc` and specifying whether to include voice channels in the export. It has possible values of `true` or `false`, to exclude voice channels, use `--include-vc false`.
|
||||
By default, voice channels are included in the export. You can change this behavior by using `--include-vc` and
|
||||
specifying whether to include voice channels in the export. It has possible values of `true` or `false`, to exclude
|
||||
voice channels, use `--include-vc false`.
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll exportguild -t "mfa.Ifrn" -g 21814 --include-vc false
|
||||
```
|
||||
|
||||
### `exportall`
|
||||
### Export all channels
|
||||
|
||||
This command exports **all accessible channels**, including server channels and DMs.
|
||||
To export all accessible channels, use the `exportall` command:
|
||||
|
||||
| | Option | Description |
|
||||
| ------ | ------------------------------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent after this date |
|
||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#date-ranges) | Only include messages sent before this date |
|
||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false |
|
||||
| | [--media-dir](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#downloading-assets) | Directory to store assets from all exported channels in the same place |
|
||||
| | [--locale](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#changing-the-date-format) | Format used when writing dates. Default: en-US |
|
||||
| | [--include-threads](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#including-threads) | Specify whether to include threads (and which type) in the export. By default, threads are not included. It has possible values of `none`, `active`, or `all`, indicating which threads should be included. To include both active and archived threads, use `--include-threads all`. |
|
||||
| | [--include-vc](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#including-voice-channels) | Include voice channels in the export. Default: true |
|
||||
| | [--include-dm](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#excluding-dms) | Include direct messages in the export. Default: true |
|
||||
| | -h | Shows help text |
|
||||
|
||||
> **Note**:
|
||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll exportall -t "mfa.Ifrn"
|
||||
```
|
||||
|
||||
#### Excluding DMs
|
||||
|
||||
@@ -318,65 +261,26 @@ To exclude DMs, add the `--include-dm false` option.
|
||||
dotnet DiscordChatExporter.Cli.dll exportall -t "mfa.Ifrn" --include-dm false
|
||||
```
|
||||
|
||||
### `channels`
|
||||
### List channels in a server
|
||||
|
||||
This command outputs a **server's channels** in the following format:
|
||||
`Channel ID | Channel Name`
|
||||
To save the output to a file, run the command below. If the file already exists, it will be overwritten.
|
||||
|
||||
| | Option | Description |
|
||||
| ------ | ---------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| **\*** | -g | [Server ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-guild-id-or-guild-channel-id) |
|
||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
||||
| | [--include-threads](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#including-threads) | Specify whether to include threads (and which type) in the output. By default, threads are not included. It has possible values of `none`, `active`, or `all`, indicating which threads should be included. To include both active and archived threads, use `--include-threads all`. |
|
||||
| | [--include-vc](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Using-the-CLI.md#including-voice-channels) | Include voice channels in the output. Default: true |
|
||||
| | -h | Shows help text |
|
||||
|
||||
> **Note**:
|
||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
||||
|
||||
To save the output to a file, run the command with `> C:\path\…` like the example below. If the file already exists, it will be overwritten.
|
||||
To list the channels available in a specific server, use the `channels` command and provide the server ID through the `-g|--guild` option:
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll channels -t "mfa.Ifrn" -g 21814 > C:\path\to\output.txt
|
||||
dotnet DiscordChatExporter.Cli.dll channels -t "mfa.Ifrn" -g 21814
|
||||
```
|
||||
|
||||
### `dm`
|
||||
### List direct message channels
|
||||
|
||||
This command outputs a list of your **direct messages**.
|
||||
|
||||
| | Option | Description |
|
||||
| ------ | ---------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
||||
| | -h | Shows help text |
|
||||
|
||||
> **Note**:
|
||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
||||
|
||||
To save the output to a file, run the command with `> C:\path\…` like the example below. If the file already exists, it will be overwritten.
|
||||
To list all DM channels accessible to the current account, use the `dm` command:
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll dm -t "mfa.Ifrn" > C:\path\to\output.txt
|
||||
dotnet DiscordChatExporter.Cli.dll dm -t "mfa.Ifrn"
|
||||
```
|
||||
|
||||
### `guilds`
|
||||
### List servers
|
||||
|
||||
This command outputs a list of your **servers**.
|
||||
|
||||
| | Option | Description |
|
||||
| ------ | ---------------------------------------------------------------------------------------------------- | ----------- |
|
||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
||||
| | -h | Shows help text |
|
||||
|
||||
> **Note**:
|
||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
||||
|
||||
To save the output to a file, run the command with `> C:\path\…` like the example below. If the file already exists, it will be overwritten.
|
||||
To list all servers accessible by the current account, use the `guilds` command:
|
||||
|
||||
```console
|
||||
dotnet DiscordChatExporter.Cli.dll guilds -t "mfa.Ifrn" > C:\path\to\output.txt
|
||||
```
|
||||
|
||||
### `guide`
|
||||
|
||||
This command explains [how to get your token, guild, and channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
||||
```
|
||||
@@ -46,7 +46,7 @@ In this screen you can customize the following:
|
||||
|
||||
- **Partition limit** (Optional) - Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb). For example, a channel with 36 messages set to be partitioned every 10 messages will output 4 files.
|
||||
|
||||
- **Message Filter** (Optional) - Special notation for filtering the messages that get included in the export. See [Message filters](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) for more info.
|
||||
- **Message Filter** (Optional) - Special notation for filtering the messages that get included in the export. See [Message filters](Message-filters.md) for more info.
|
||||
|
||||
- **Format markdown** (Optional) - Disable markdown processing when exporting. You can use this to produce JSON or plain text exports without unwrapping mentions, custom emoji, and certain other special tokens.
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ body:
|
||||
required: true
|
||||
- label: I have provided a descriptive title for this issue
|
||||
required: true
|
||||
- label: I have made sure that that this bug is reproducible on the latest version of the application
|
||||
- label: I have made sure that this bug is reproducible on the latest version of the application
|
||||
required: true
|
||||
- label: I have provided all the information needed to reproduce this bug as efficiently as possible
|
||||
required: true
|
||||
|
||||
@@ -1,35 +1,44 @@
|
||||
name: docker
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- "*"
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
# Outputs from this job aren't really used, but it's here to verify that
|
||||
# the Dockerfile builds correctly on pull requests.
|
||||
build:
|
||||
pack:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Install Docker Buildx
|
||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # 3.0.0
|
||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||
|
||||
- name: Build image
|
||||
run: >
|
||||
docker buildx build
|
||||
docker buildx build .
|
||||
--file DiscordChatExporter.Cli.dockerfile
|
||||
--platform linux/amd64,linux/arm64
|
||||
--build-arg VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
||||
--output type=tar,dest=DiscordChatExporter.Cli.Docker.tar
|
||||
.
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # 3.1.3
|
||||
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
||||
with:
|
||||
name: DiscordChatExporter.Cli.Docker
|
||||
path: DiscordChatExporter.Cli.Docker.tar
|
||||
@@ -37,17 +46,20 @@ jobs:
|
||||
|
||||
deploy:
|
||||
# Deploy to DockerHub only on tag push or master branch push
|
||||
if: ${{ github.event_name == 'push' && (github.ref_type == 'tag' || github.ref_type == 'branch' && github.ref_name == 'master') }}
|
||||
if: ${{ github.ref_type == 'tag' || github.ref_type == 'branch' && github.ref_name == 'master' }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Install Docker Buildx
|
||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # 3.0.0
|
||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||
|
||||
- name: Login to DockerHub
|
||||
run: >
|
||||
@@ -56,11 +68,11 @@ jobs:
|
||||
|
||||
- name: Build & push image
|
||||
run: >
|
||||
docker buildx build
|
||||
docker buildx build .
|
||||
--file DiscordChatExporter.Cli.dockerfile
|
||||
--platform linux/amd64,linux/arm64
|
||||
--build-arg VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
||||
--push
|
||||
--tag tyrrrz/discordchatexporter:latest
|
||||
${{ github.ref_type == 'tag' && '--tag tyrrrz/discordchatexporter:$GITHUB_REF_NAME' || '' }}
|
||||
${{ github.ref_type == 'tag' && '--tag tyrrrz/discordchatexporter:stable' || '' }}
|
||||
.
|
||||
|
||||
+59
-15
@@ -1,8 +1,15 @@
|
||||
name: main
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- "*"
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||
@@ -10,27 +17,53 @@ env:
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
format:
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Install .NET
|
||||
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # 3.2.0
|
||||
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Verify formatting
|
||||
run: >
|
||||
dotnet build
|
||||
-t:CSharpierFormat
|
||||
--configuration Release
|
||||
|
||||
test:
|
||||
# Tests need access to secrets, so we can't run them against PRs because of limited trust
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Install .NET
|
||||
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Run tests
|
||||
# Tests need access to secrets, so we can't run them against PRs because of limited trust
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
env:
|
||||
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
||||
run: >
|
||||
dotnet test
|
||||
-p:CSharpier_Bypass=true
|
||||
--configuration Release
|
||||
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
|
||||
--collect:"XPlat Code Coverage"
|
||||
@@ -39,7 +72,7 @@ jobs:
|
||||
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
|
||||
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # 3.1.4
|
||||
uses: codecov/codecov-action@f30e4959ba63075080d4f7f90cacc18d9f3fafd7 # v4.0.0
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
@@ -51,40 +84,47 @@ jobs:
|
||||
- DiscordChatExporter.Gui
|
||||
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Install .NET
|
||||
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # 3.2.0
|
||||
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Publish app
|
||||
run: >
|
||||
dotnet publish ${{ matrix.app }}
|
||||
-p:Version=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
||||
-p:CSharpier_Bypass=true
|
||||
--output ${{ matrix.app }}/bin/publish/
|
||||
--configuration Release
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # 3.1.3
|
||||
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
||||
with:
|
||||
name: ${{ matrix.app }}
|
||||
path: ${{ matrix.app }}/bin/publish/
|
||||
if-no-files-found: error
|
||||
|
||||
release:
|
||||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
|
||||
if: ${{ github.ref_type == 'tag' }}
|
||||
|
||||
needs:
|
||||
- format
|
||||
- test
|
||||
- pack
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
@@ -96,7 +136,7 @@ jobs:
|
||||
gh release create ${{ github.ref_name }}
|
||||
--repo ${{ github.event.repository.full_name }}
|
||||
--title ${{ github.ref_name }}
|
||||
--notes "[Changelog](${{ github.event.repository.html_url }}/blob/${{ github.ref_name }}/Changelog.md)"
|
||||
--generate-notes
|
||||
--verify-tag
|
||||
|
||||
deploy:
|
||||
@@ -115,13 +155,15 @@ jobs:
|
||||
asset: DiscordChatExporter
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2
|
||||
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
|
||||
with:
|
||||
name: ${{ matrix.app }}
|
||||
path: ${{ matrix.app }}/
|
||||
@@ -142,6 +184,8 @@ jobs:
|
||||
notify:
|
||||
needs: deploy
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -156,6 +200,6 @@ jobs:
|
||||
body: |
|
||||
{
|
||||
"avatar_url": "https://raw.githubusercontent.com/${{ github.event.repository.full_name }}/${{ github.ref_name }}/favicon.png",
|
||||
"content": "**${{ github.event.repository.name }}** v${{ github.ref_name }} has been released!\n🔗 [Download](<${{ github.event.repository.html_url }}/releases/tag/${{ github.ref_name }}>) • [Changelog](<${{ github.event.repository.html_url }}/blob/${{ github.ref_name }}/Changelog.md>)"
|
||||
"content": "[**${{ github.event.repository.name }}**](<${{ github.event.repository.html_url }}>) v${{ github.ref_name }} has been released!"
|
||||
}
|
||||
retry-count: 5
|
||||
|
||||
+6
-17
@@ -1,23 +1,12 @@
|
||||
# User-specific files
|
||||
.vs/
|
||||
.idea/
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
.idea/
|
||||
.vs/
|
||||
.vscode/
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
[Xx]64/
|
||||
[Xx]86/
|
||||
[Bb]uild/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
bin/
|
||||
obj/
|
||||
|
||||
# Coverage
|
||||
*.opencover.xml
|
||||
# Test results
|
||||
TestResults/
|
||||
-629
@@ -1,629 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## v2.42.3 (09-Nov-2023)
|
||||
|
||||
- JSON changes:
|
||||
- Added the `video` field to the embed object, which may contain additional information about an embedded video resource.
|
||||
- CSV changes:
|
||||
- Fixed an issue where the `Date` field was incorrectly formatted. Now, the dates follow the `ISO 8601` standard.
|
||||
|
||||
## v2.42.2 (26-Oct-2023)
|
||||
|
||||
- General changes:
|
||||
- Fixed an issue where trying to export a channel that contained application interactions with empty command names crashed the application.
|
||||
|
||||
## v2.42.1 (19-Oct-2023)
|
||||
|
||||
- General changes:
|
||||
- Improved the error message shown when trying to export a forum channel. Such channels cannot be exported directly, you need to fetch and export their individual threads instead.
|
||||
- CLI changes:
|
||||
- Fixed an issue where fetching threads with `[` or `]` in their name crashed the application.
|
||||
|
||||
## v2.42 (12-Oct-2023)
|
||||
|
||||
- General changes:
|
||||
- Fixed an issue where the "reuse assets" option did not work as intended due to Discord recently introducing signatures in the CDN URLs. (Thanks [@slatinsky](https://github.com/slatinsky))
|
||||
- CLI changes:
|
||||
- Added progress reporting for the "fetching channels" stage of the `exportguild` and `exportall` commands. (Thanks [@slatinsky](https://github.com/slatinsky))
|
||||
|
||||
## v2.41.2 (05-Oct-2023)
|
||||
|
||||
- General changes:
|
||||
- Added a check that will trigger an error if the provided bot account does not have the message content intent enabled. Unlike the previous attempt, this approach does not rely on heuristics.
|
||||
|
||||
## v2.41.1 (28-Sep-2023)
|
||||
|
||||
- CLI changes:
|
||||
- Fixed an issue where the export failed to export channels with an empty name.
|
||||
|
||||
## v2.41 (15-Sep-2023)
|
||||
|
||||
- General changes:
|
||||
- Replaced the "date format" option with a "locale" option. Now, you can choose one of the locales supported by the Discord app, and DiscordChatExporter will infer all the required date, time, and number formats automatically. In GUI, the locale can be selected from the settings window. In CLI, the locale can be specified using the `--locale` option (e.g. `--locale "en-US"`). By default, the current system locale is used.
|
||||
- Optimized the algorithm for fetching threads to improve performance. (Thanks [@slatinsky](https://github.com/slatinsky))
|
||||
- GUI changes:
|
||||
- Improved the initial load time after submitting the token. Now, only the guilds are loaded initially, and the channels are loaded on-demand when the user selects a guild. This should significantly improve performance for accounts with many guilds.
|
||||
- Added an option to include threads in the channel list, which is configurable in settings. When enabled, threads will appear at the bottom of the list, grouped by the parent channel. Note that pulling threads (especially archived threads) can be a very time-consuming process, depending on the guild size. By default, threads are not included.
|
||||
- CLI changes:
|
||||
- Added a warning when using the `--bot` option, informing that it's obsolete and shouldn't be used.
|
||||
- Changed the `--include-threads` option on the `channels` command from a switch (boolean) option, to an enum (choice) option. It now has possible values of `none`, `active`, or `all`, indicating which threads should be included. To include both active and archived threads, use `--include-threads all`. For backwards compatibility, the `--include-threads` option can still be used as a switch, in which case it will be treated as `--include-threads active`. Note that pulling threads (especially archived threads) can be a very time-consuming process, depending on the guild size.
|
||||
- Added the `--include-threads` option to the `exportguild` and `exportall` commands. Using this option, you can specify whether to include threads (and which type) in the export. By default, threads are not included.
|
||||
- Added the `--include-vc` option to the `channels` command. Using this option, you can specify whether to include voice-channel-accompanying text channels in the output. By default, these channels are included.
|
||||
- Changed the progress reporting behavior of export commands such that tasks are now hidden on completion if parallelization is enabled (i.e. `--parallel` is set to `2` or higher). This should help improve visual clarity when exporting many channels in parallel.
|
||||
|
||||
## v2.40.4 (11-Aug-2023)
|
||||
|
||||
- HTML changes:
|
||||
- Fixed an issue where the "call lasted for X minutes" system message was unnecessarily too precise. Now, it's rounded to the nearest minute.
|
||||
- Fixed an issue where multi-line quote blocks with empty lines in the middle were rendered as separate blocks.
|
||||
- JSON changes:
|
||||
- Added the `users` field to the reaction object, containing an array with limited information about the users that reacted with that particular emoji. (Thanks [@slatinsky](https://github.com/slatinsky))
|
||||
|
||||
## v2.40.3 (29-Jul-2023)
|
||||
|
||||
- GUI changes:
|
||||
- Fixed an issue where guild categories were rendered with blank names.
|
||||
|
||||
## v2.40.2 (27-Jul-2023)
|
||||
|
||||
- General changes:
|
||||
- Improved error reporting on unexpected HTTP errors.
|
||||
- CLI changes:
|
||||
- Fixed an issue which caused a crash when trying to export a private (but accessible) channel inside a private (but not accessible) category.
|
||||
|
||||
## v2.40.1 (21-Jul-2023)
|
||||
|
||||
- General changes:
|
||||
- Fixed an issue where the fallback avatar (i.e. the avatar used for when the user doesn't have a custom one set) was not resolved properly for users that don't have a discriminator.
|
||||
- CLI changes:
|
||||
- Added the `--include-vc` option to the `exportall` and `exportguild` commands, which instructs whether to include voice-channel-accompanying text channels in the export. By default, this is set to `true` to match the previous behavior. To disable the option, use `--include-vc false`.
|
||||
- GUI changes:
|
||||
- Replaced the blur effect applied to the token text box with a password mask.
|
||||
- JSON format changes:
|
||||
- Added the `exportedAt` field to the export metadata, which contains the timestamp corresponding to when the export was created. (Thanks [@slatinsky](https://github.com/slatinsky))
|
||||
- Added the `roles` field to the object describing a user. This field contains an array of objects that describe the roles assigned to the user. (Thanks [@slatinsky](https://github.com/slatinsky))
|
||||
|
||||
## v2.40 (08-Jun-2023)
|
||||
|
||||
- General changes:
|
||||
- Added support for users that don't have discriminators.
|
||||
- Added a precondition check that verifies whether the requested channel contains any messages for the specified period, before starting the export process. This check works by comparing the export bounds against the ID of the last message in the channel, which is provided by the Discord API as part of the channel metadata. When exporting many channels in batches (e.g. using the `exportall` command), this check may eliminate a significant number of unnecessary API calls and speed up the export process.
|
||||
- CLI changes:
|
||||
- Extended the `channels` command with the `--include-threads` option. When this option is provided, the command will include channel threads in the output. (Thanks [@WAUthethird](https://github.com/WAUthethird))
|
||||
- Simplified the information in the `guide` command related to the extraction of DM channel IDs. Discord now provides a native way of copying IDs of DM channels, so the previous devtools-based workaround is no longer necessary.
|
||||
- GUI changes:
|
||||
- Added a blur effect to the token text box, which activates when the control loses focus. This is done to reduce the risk of accidentally exposing the token when taking screenshots.
|
||||
- HTML format changes:
|
||||
- Added support for the header markdown syntax.
|
||||
- Added support for the list markdown syntax.
|
||||
|
||||
## v2.39.1 (10-Mar-2023)
|
||||
|
||||
- Fixed an issue where messages containing mentions of users that left the server (but haven't deleted their account) were incorrectly rendered as `@Unknown`.
|
||||
- Fixed an issue where messages containing video links were not rendered correctly in the HTML export. Now, they are rendered using a video player and the referenced assets are pulled if the "download assets" option is enabled.
|
||||
|
||||
## v2.39 (25-Feb-2023)
|
||||
|
||||
- Added an option to specify the directory path for downloaded assets. This can be used, in combination with the "reuse assets" option, to have a shared asset directory for multiple exports. In GUI, this option can be found in the advanced section of the export dialog. In CLI, it's available as `--media-dir <path>`. (Thanks [@96-LB](https://github.com/96-LB))
|
||||
- Added support for server-level user avatars. If a user has a custom avatar set on the server, it will be rendered instead of their main avatar.
|
||||
- CLI changes:
|
||||
- Extended the `exportall` command with the `--data-package` option. You can use this option to provide the path to your personal data package (`package.zip` file), requested from Discord. When provided, the command will pull channels listed in the package instead of using the Discord API to query them. This can be particularly useful if you want to export DM channels that have been closed, as the personal data package should still contain their IDs.
|
||||
- HTML format changes:
|
||||
- Added support for rendering group DM channel invites.
|
||||
- Changed the primary font from `Whitney` to `gg sans` to match the new Discord design.
|
||||
- Fixed an issue where the external font sometimes failed to load if the export was created with the "download assets" option enabled.
|
||||
- Fixed an issue where `gifv` attachments were incorrectly treated as images instead of video files.
|
||||
|
||||
## v2.38 (16-Feb-2023)
|
||||
|
||||
- General changes:
|
||||
- Added an option to disable markdown processing when exporting. You can use this to produce JSON or plain text exports without unwrapping mentions, custom emoji, and certain other special tokens. In GUI, this option can be found in the export dialog. In CLI, it's available as the `--markdown <true|false>` flag.
|
||||
- Added support for different formatting options when rendering timestamps (i.e. the `f` in `<t:1234567890:f>`). As an exception, relative timestamps are formatted as regular timestamps since that makes more sense in a static export. Currently, all formatting options are rendered based on the `English (US)` locale, with the intent to make that more configurable in the future.
|
||||
- Changed the default date format from `dd-MMM-yy hh:mm tt` to `MM/dd/yyyy h:mm tt` to match the date format used by Discord for message timestamps when the `English (US)` language is selected. This should make the default date format more consistent with other non-configurable date formats used by DiscordChatExporter. In the future, this setting will most likely be removed entirely in favor of a more flexible approach.
|
||||
- Updated the usage guide with additional steps required to retrieve the user token.
|
||||
- Fixed an issue where certain user mentions were incorrectly rendered as `@Unknown`.
|
||||
- Fixed an issue where some embed images were rendered using their actual URLs instead of Discord proxy URLs.
|
||||
- GUI changes:
|
||||
- Added a text box for specifying the output path when exporting channels. It can be used to set an output path that uses template tokens, which previously required hacky workarounds. This text box can be left empty, in which case clicking on the "Export" button will open the file or folder picker dialog, matching the previous behavior.
|
||||
- Added a notification when the application is updated to a new version, containing the changelog link.
|
||||
- Moved the "reuse assets" option from the settings dialog to the export dialog.
|
||||
- Replaced the lock icon in the token text box with a key icon, to better reflect the purpose of the input.
|
||||
- Minor cosmetic improvements.
|
||||
- CLI changes:
|
||||
- Changed the behavior of the `export` command when providing IDs of category channels. Now, instead of displaying an error, the command will export all channels contained within the corresponding categories.
|
||||
- HTML format changes:
|
||||
- Added proper support for more system notification messages.
|
||||
- Added support for rendering server invites. Now, if the message contains an invite link, the export will show the server icon and include additional information, such as the name of the server and the target channel.
|
||||
- Changed the preamble part of the export to show the channel icon when available, instead of the default Discord logo. This is only available for group DM channels. (Thanks [@CanePlayz](https://github.com/CanePlayz))
|
||||
- Fixed an issue where some miscellaneous characters were incorrectly treated as emoji, which resulted in them being rendered as broken images. (Thanks [@CanePlayz](https://github.com/CanePlayz))
|
||||
- Fixed an issue where messages triggered by app interactions were not rendered as replies.
|
||||
- Fixed an issue where server cross-posts were not rendered correctly.
|
||||
- JSON format changes:
|
||||
- Added an `iconUrl` field for the top-level `channel` object, which specifies the URL of the channel icon. This is only available for group DM channels.
|
||||
- Added a `code` field for reactions, which specifies the code of the associated emoji. For standard Unicode emoji, this is equal to the emoji alias (e.g. `slightly_smiling_face`). For custom Discord emoji, this is equal to the emoji name (same as the already existing `name` field).
|
||||
- Added an `interaction` field for messages, which contains information about the app interaction that triggered that response, if applicable.
|
||||
|
||||
## v2.37.2 (27-Jan-2023)
|
||||
|
||||
- Updated the links inside the application to point to the new documentation site. (Thanks [@CanePlayz](https://github.com/CanePlayz))
|
||||
- [CLI] Fixed an issue that there was no visual indication that an export task has failed before the whole process has completed.
|
||||
- Fixed an issue where the application sometimes crashed when it couldn't establish an HTTP connection to the target server.
|
||||
|
||||
## v2.37.1 (10-Jan-2023)
|
||||
|
||||
- [HTML] Fixed an issue where the export failed because it failed to resolve standard emoji image assets. Switched to a different CDN provider to mitigate this. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- [GUI] Fixed an application crash that happened when the user attempted to close the same dialog multiple times in a very short time.
|
||||
|
||||
## v2.37 (08-Jan-2023)
|
||||
|
||||
- Switched from .NET 6.0 to .NET 7.0. If running on Windows, the application should update all required prerequisites automatically. Alternatively, you can download the latest version of the runtime for your system [here](https://dotnet.microsoft.com/download/dotnet/7.0).
|
||||
- Updated rate limit handling to adjust automatically based on the response headers. This may result in exports taking longer than before on bot accounts, but it makes it less likely for Discord to throttle you. Exports with user accounts shouldn't be affected too much by this change.
|
||||
- Optimized snowflake parsing by removing unnecessary checks. (Thanks [@Kuba_Z2](https://github.com/KubaZ2))
|
||||
- [Docker] Optimized the Docker image size by using the Alpine base image and publishing a self-contained distribution. (Thanks [@Velithris](https://github.com/Zireael-N))
|
||||
- Fixed an issue where exporting a channel whose name ends with a dot would fail on Windows with default output path. The dots are now trimmed in file and directory names to match the behavior of Windows Explorer.
|
||||
|
||||
## v2.36.4 (29-Oct-2022)
|
||||
|
||||
- Changed all mentions of "media" in the context of "download media" or "reuse media" to "assets". CLI options will retain their existing names for backwards compatibility.
|
||||
- [HTML] Fixed an issue which prevented emoji used inside message content from being downloaded when "download assets" option is enabled. (Thanks [@Roberto Blázquez](https://github.com/xBaank))
|
||||
|
||||
## v2.36.3 (21-Oct-2022)
|
||||
|
||||
- [GUI] Fixed an issue where opening a dialog did not prevent user interactions with background UI elements using keyboard. This sometimes caused the application to crash in weird ways.
|
||||
- [Docker] Fixed an issue where DiscordChatExporter was running as root inside the container, making the exported files inaccessible to the host. (Thanks [@Benjamin Just](https://github.com/BamButz))
|
||||
|
||||
## v2.36.2 (08-Oct-2022)
|
||||
|
||||
- Removed the message content intent check because the heuristics turned out to be not reliable enough.
|
||||
- Fixed an issue where the runtime manifest included the wrong target runtime version. This resulted in the application failing to launch for some users when upgrading from earlier versions.
|
||||
|
||||
## v2.36.1 (24-Sep-2022)
|
||||
|
||||
- Added a check that will trigger an error if the provided bot account does not have the message content intent enabled. Note, however, that this check is based on heuristics which may result in false negatives.
|
||||
- Fixed an issue where certain transient HTTP errors were not retried.
|
||||
- Fixed an issue which caused the export process to fail with the `IndexOutOfRangeException` exception on certain automated messages.
|
||||
- Fixed an issue which caused the export process to fail on unrecognized embed types.
|
||||
|
||||
## v2.36 (16-Sep-2022)
|
||||
|
||||
- [HTML] Added support for rendering GIFV embeds. They will now render as videos that automatically play when you hover your mouse over them. (Thanks [@gan-of-culture](https://github.com/gan-of-culture))
|
||||
- [HTML] Added support for rendering system notification messages, such as when a user joins a server or when a messages gets pinned. Previously, such messages were rendered as regular text messages, but now they look similar to how they're presented in the Discord client. (Thanks [@gan-of-culture](https://github.com/gan-of-culture))
|
||||
- [CLI] Improved the wording of the error message that's shown when exporting multiple channels and the provided output path is ambiguous. It now mentions that you can resolve the ambiguity by adding a slash at the end of the path.
|
||||
|
||||
## v2.35.2 (08-Sep-2022)
|
||||
|
||||
- Updated usage guide to mention the need to enable "Message Content Intent" to use a bot as a medium for exporting messages.
|
||||
- [CLI] Fixed an issue where passing an existing directory as the output path failed when exporting multiple channels (for example, when running `exportdm`). An ambiguous output path will now always be treated as a directory path if that directory already exists. If it doesn't exist, it will be treated as a file path, matching the previous behavior.
|
||||
|
||||
## v2.35.1 (26-Aug-2022)
|
||||
|
||||
- Added `~` character as an alias for `-` when negating a message filter. This should make it easier to use negated filters from CLI where the dash character already has other meanings.
|
||||
- Extended retry logic to encompass all server-side errors from Discord API, instead of only `500 Internal Server Error`.
|
||||
- [CLI] Attempt to export multiple channels will now fail if provided with an output path that is neither a directory, nor a file name template. Previously, this resulted in all channels being exported to the same file, overwriting each other.
|
||||
- Fixed an issue where a text message filter didn't work if it started with a character that's also the first character in one of the named filters (e.g. `from` or `mentions`).
|
||||
- Fixed an issue where a text message filter didn't work correctly if it was enclosed in parentheses.
|
||||
- Fixed an issue where categories were displayed alongside regular channels in the channel list, both in GUI and in CLI (when using the `guild` command).
|
||||
- [CLI] Fixed an issue where an output path starting with a tilde on Linux was not expanded properly into a full path. (Thanks [@TSRBerry](https://github.com/TSRBerry))
|
||||
|
||||
## v2.35 (02-Jul-2022)
|
||||
|
||||
- Added support for exporting text chat in voice channels. These channels are now also displayed when browsing in the GUI and in the CLI when executing the `channels` command.
|
||||
- [GUI] Direct message channels are now sorted by the timestamp of their last message, similarly to how they appear in the Discord client.
|
||||
- [GUI] Removed artificial grouping of direct message channels into "Private" and "Group".
|
||||
- [CLI] Added runtime bootstrapper capabilities to the CLI flavor of DiscordChatExporter on Windows. Now, if you attempt to run the application without the required prerequisites installed, you will be provided with an option to install them automatically.
|
||||
- [CLI] Fixed outdated information in the usage guide. (Thanks [@Clint Herron](https://github.com/HanClinto))
|
||||
- [CLI] Added whitespace padding to the output of `guilds`, `channels`, and `dm` to make the tables look more uniform.
|
||||
- [HTML] Added hyperlinks to message timestamps, which allows you to quickly copy a link to a specific message in the export. (Thanks [@Philipp C. Heckel](https://github.com/binwiederhier))
|
||||
- [HTML] Added minification. Chat exports in HTML format are now 30-35% smaller than before.
|
||||
- [HTML] Added support for rendering embeds of Twitter posts that contain multiple images. Previously, this resulted in multiple separate embeds instead of one.
|
||||
- [HTML] Added support for rendering embeds of YouTube Shorts videos.
|
||||
- [HTML] Text content is now hidden if the message only contains a link to an image and nothing else. The link itself is resolved as an image embed.
|
||||
- [HTML] Fixed an issue where some emoji that included a zero-width-joiner rune were not rendered correctly due to a wrong Twemoji URL being generated. (Thanks [@Ethan](https://github.com/ethanndickson))
|
||||
- [HTML] Fixed an issue where replies to a message that contained a quote (i.e. `>`) were not rendered correctly.
|
||||
- [HTML] Fixed an issue where code blocks with language highlighting did not have the correct background color.
|
||||
- Added file name template token that resolves to the current date (`%d`). (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- Updated the usage guide to replace the instructions for retrieving the user token with those that appear to work for more people.
|
||||
- Updated the usage guide to feature the TOS warning more prominently.
|
||||
- [Docker] Changed internal working directory from `/app/out` to `/out`. This was an unintended breaking change. Please update your volume binding configuration from `-v /path/on/machine:/app/out` to `-v /path/on/machine:/out`.
|
||||
|
||||
## v2.34.1 (01-Jun-2022)
|
||||
|
||||
- Improved retry policy to handle more transient errors. This should result in fewer errors exporting a channel due to timeout.
|
||||
- Added `has:pin` message filter. You can use it to limit exported messages to those that have been pinned. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- Fixed an issue which caused the export to fail when processing stickers that have no name.
|
||||
|
||||
## v2.34 (10-Apr-2022)
|
||||
|
||||
- [HTML] Reworked layout to be more consistent with Discord.
|
||||
- [HTML] Changed user profile picture dimensions from `128x128` to `512x512`. (Thanks [@Chris Helder](https://github.com/TheDude53))
|
||||
- [HTML] Improved image scaling for Chromium-based browsers. This should result in higher quality images across the entire export.
|
||||
- [HTML] Hovering over messages will now show short timestamps on the left, indicating the time that the individual messages of the group were sent.
|
||||
- [HTML] Using "download media" option will now also download scripts, styles, fonts, and other similar resources used by the export.
|
||||
- [HTML] Image attachments will now use the provided description as alt text.
|
||||
- [HTML] Fixed a few layout inconsistencies related to embeds.
|
||||
- [GUI] Added a few clickable links to the usage guide to make the process of locating tokens easier.
|
||||
|
||||
## v2.33.2 (07-Mar-2022)
|
||||
|
||||
- Actually fixed it this time.
|
||||
|
||||
## v2.33.1 (07-Mar-2022)
|
||||
|
||||
- Fixed an issue where the application silently failed to run if the system didn't have .NET Runtime 6.0.2 installed. If you continue seeing this issue, please uninstall all existing .NET runtimes from your computer and then try running the application again.
|
||||
|
||||
## v2.33 (06-Mar-2022)
|
||||
|
||||
- Added messages informing about war in Ukraine and available ways to help.
|
||||
- Added support for rendering stickers in HTML and JSON. Lottie-based stickers currently cannot be displayed in HTML exports (see [#803](https://github.com/Tyrrrz/DiscordChatExporter/issues/803)).
|
||||
- Added a new `reaction:` message filter which can be used to check if someone reacted to a message with a specific emoji. You can either pass the emoji name (e.g. `reaction:LUL`) or its ID (e.g. `reaction:41771983429993937`).
|
||||
- [GUI] Added auto-detection for dark mode. If your system is configured to prefer dark mode in applications, DiscordChatExporter will use it by default instead of light mode.
|
||||
- Fixed an issue which caused the export process to crash when downloading media files with extremely long file extensions. (Thanks [@Tomlacko](https://github.com/Tomlacko))
|
||||
- Fixed an issue which caused the export process to crash on invalid mentions.
|
||||
- [GUI] Fixed an issue where the time pickers used to specify export ranges always displayed time in 12-hour format, instead of respecting the system locale.
|
||||
|
||||
## v2.32 (27-Jan-2022)
|
||||
|
||||
- Token kind (user or bot) is now detected automatically. Removed the button to switch token kind in GUI. Option `-b|--bot` in CLI is now deprecated and does nothing.
|
||||
- Updated user token extraction guide to reflect the fact that devtools are no longer accessible in the desktop version of Discord client. The recommended workaround is to open Discord in browser. (Thanks [@Dhananjay-JSR](https://github.com/Dhananjay-JSR))
|
||||
- Fixed an issue which caused an error when parsing invalid date timestamps. Such timestamps are now rendered as "Invalid date", similarly to how the Discord client does it.
|
||||
- Fixed an issue which caused an error when parsing certain embed fields.
|
||||
- Fixed an issue which caused an error when parsing a mention to a user that has no username.
|
||||
- [GUI] Minor visual fixes.
|
||||
|
||||
## v2.31.1 (15-Dec-2021)
|
||||
|
||||
- Fixed an issue which caused an error when parsing certain custom emoji reactions.
|
||||
- [GUI] Improved user interface.
|
||||
|
||||
## v2.31 (06-Dec-2021)
|
||||
|
||||
- Changed target runtime of the application (both GUI and CLI) from .NET 3.1 to .NET 6. Those using the GUI version will not need to take any action as the application should install the necessary prerequisites automatically. Those using the CLI version will need to download and install .NET 6 runtime manually [from here](https://dotnet.microsoft.com/download/dotnet/6.0) (look for ".NET Runtime 6.0.x" section on the right and choose the distribution appropriate for your system).
|
||||
- [HTML] Updated layout design to match Discord more closely. (Thanks [@Artem](https://github.com/Scarg))
|
||||
- [HTML] Fixed an issue where markdown inside channel topic was not rendered correctly. (Thanks [@Emily](https://github.com/emillly-b))
|
||||
- [HTML] Fixed an issue where the layout was broken for messages containing text in right-to-left languages. (Thanks [@Emily](https://github.com/emillly-b))
|
||||
- Fixed an issue where text filters weren't matching content inside of embeds.
|
||||
- [GUI] Fixed a multitude of issues related to the bootstrapper.
|
||||
|
||||
## v2.30.1 (28-Aug-2021)
|
||||
|
||||
- [HTML] Changed user avatars to render using higher resolution images. (Thanks [@Chris Helder](https://github.com/TheDude53))
|
||||
- Fixed an issue where `has:file` message filter was not recognized. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- Fixed an issue where a unix timestamp marker with an invalid offset crashed the export process.
|
||||
|
||||
## v2.30 (08-Aug-2021)
|
||||
|
||||
- [HTML] Added special casing for Spotify track embeds to render them directly using an embedded player.
|
||||
- [HTML] Added special casing for plain image embeds to render them like image attachments.
|
||||
- [HTML] Added tooltip text for unix timestamp markers which shows the full date represented by the timestamp, regardless of configured date format.
|
||||
- [HTML] Updated the fallback text shown when the referenced message could not be loaded to make it more explicit.
|
||||
- [HTML] Updated styling of quoted text in markdown to more closely resemble how it looks in Discord.
|
||||
- [HTML] Fixed an issue where some file formats were not correctly recognized as image or video attachments, which affected how they were rendered.
|
||||
- [HTML] Fixed an issue where formatting inside named links (e.g. `[**Bold link**](https://example.com)`) was not being parsed.
|
||||
- [HTML] Fixed an issue where inline embed fields were missing horizontal spacing between columns.
|
||||
- [HTML] Fixed other minor styling issues.
|
||||
|
||||
## v2.29 (19-Jul-2021)
|
||||
|
||||
- Added support for message filtering, which is accessible as an additional export parameter in the GUI and as the `--filter` option in the CLI. Message filters use a special syntax similar to Discord's search query syntax to allow specifying which messages should be included in the export. For example, you can limit the export to only include messages that contain image attachments (`has:image`) or messages from a certain user (`from:Tyrrrz`) or messages containing certain words (`hello world`), etc. You can also combine filters together (`hi mentions:Tyrrrz`, `from:Tyrrrz | from:96-LB`, `(mentions:Tyrrrz | from:Tyrrrz) has:image`) or negate them (`-has:link`). More thorough documentation coming soon. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- Added support for rendering mentions of voice channels, in addition to text channels.
|
||||
- Added support for rendering unix timestamp markers. Currently, style markers are ignored and timestamps are always rendered with the format configured in settings (or provided via `--date-format` option).
|
||||
- Updated in-app instructions for obtaining a user token. (Thanks [@Yudi](https://github.com/Yudi) and [@virtuallyvlad](https://github.com/virtuallyvlad))
|
||||
- [HTML] Improved visual appearance of the reference symbol (Г-shaped line in replies) to make it more closely resemble Discord's styling.
|
||||
- [HTML] Added more specific fallback text used when rendering referenced messages that contain no text content but have attachments or embeds.
|
||||
- [HTML] Fixed an issue where a broken embed author icon occupied visual space, ruining the embed layout. (Thanks [@Cliff J.](https://github.com/CliffJameston))
|
||||
- [GUI] Improved handling for fatal errors that may occur when attempting to export a channel. These errors are now displayed in a popup, allowing the user to try again instead of having the application crash completely.
|
||||
- [CLI] Fixed an issue where an attempt to export a channel resulted in `NotSupportedException` when the default encoding was set to `UTF8`.
|
||||
- [CLI] Fixed an issue where providing an incorrectly formatted partition limit via `-p|--partition` option resulted in a non-descriptive and unhelpful error.
|
||||
- Improved "Requested resource does not exist" error message by including the ID of the requested resource.
|
||||
|
||||
## v2.28 (19-Jun-2021)
|
||||
|
||||
- [HTML] Added special casing for YouTube video embeds to render them directly using an embedded player. (Thanks [@quentinmay](https://github.com/quentinmay))
|
||||
- [HTML] Added support for rendering standard emoji by code. Such emoji may sometimes be found in messages sent by bots or through webhooks. (Thanks [@CanePlayz](https://github.com/CanePlayz) and [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- [HTML] Changed tooltips on standard emoji to show emoji code instead of their raw string representations. (Thanks [@CanePlayz](https://github.com/CanePlayz) and [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- [HTML] Added tooltips on individual messages to show when those messages were sent.
|
||||
- [HTML] Updated colors and minor styling elements to match Discord's new style direction after rebranding.
|
||||
- [HTML] Updated Twemoji URLs to use SVG image variants for better rendering quality.
|
||||
- [HTML] Changed user avatar URLs to include predetermined size query parameter for better rendering quality.
|
||||
- Changed embed rendering logic to prefer Discord-proxied URLs for external content, in order to avoid unnecessary HTTP requests to third parties.
|
||||
- Fixed an issue where exporting with media sometimes resulted in a crash due to lack of permissions to change file attributes. These errors are now ignored, which means that the creation, write, and access dates of downloaded files may sometimes not match the dates provided by Discord's CDN.
|
||||
- [HTML] Fixed styling issues when rendering embed footers.
|
||||
- [HTML] Fixed an issue where links didn't render properly inside referenced messages.
|
||||
- [HTML] Fixed an issue where standalone emoji were incorrectly enlarged inside referenced messages.
|
||||
- [HTML] Fixed an issue where clicking on a referenced message revealed spoilers inside of it.
|
||||
- [GUI] Fixed an issue where the list of missing components, reported by the prerequisite check at application startup, included Windows updates that were not applicable to the user's system due to the fact that other superseding updates have already been installed. This issue only affected users running DiscordChatExporter on Windows 7.
|
||||
- [GUI] Fixed a few other minor issues related to the prerequisite installation window.
|
||||
|
||||
## v2.27.1 (08-Jun-2021)
|
||||
|
||||
- [GUI] Application will now detect if the required .NET Runtime or any of its prerequisites are missing and prompt the user to download and install them automatically. **Experimental feature, please test it out and report any issues you may find!**
|
||||
- [CLI] Fixed an issue where the application crashed when exporting a channel that had square brackets as part of its name or category name. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
|
||||
## v2.27 (24-Apr-2021)
|
||||
|
||||
- Added partitioning by file size. You can now use values such as `10mb` to indicate a size-based cut off point, in addition to values like `10` to indicate a number of messages. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- [CLI] Improved formatting and progress reporting.
|
||||
- [CLI] Changed `export` command so that it can accept multiple channel IDs passed to `-c|--channel` option. This makes it possible to export multiple channels at once while benefiting from parallelization.
|
||||
- [JSON] Added `color` field to message author. This is a hex string that represents user's color, inherited from their roles. (Thanks [@rtm516](https://github.com/rtm516))
|
||||
- [JSON] Added `categoryId` field to the root. This represents the ID of the category channel that the currently exported channel belongs to. (Thanks [@rtm516](https://github.com/rtm516))
|
||||
- [JSON] Fixed an issue where user discriminator was written without leading zeroes. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- [JSON] Fixed an issue where the application sometimes crashed with an error saying `']' invalid without a matching open`, which was just a validation message that masked the actual error behind the failure. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- Fixed an issue where progress was not reported correctly if the channel didn't have any messages in the specified time range.
|
||||
|
||||
## v2.26.1 (06-Feb-2021)
|
||||
|
||||
- [CLI] Added support for file name templates, which allow you to dynamically generate output file names based on channel and guild metadata. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- Fixed an issue where the application sometimes crashed with `Invalid snowflake` message when exporting chat logs that contained invalid or outdated mentions. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
|
||||
## v2.26 (29-Dec-2020)
|
||||
|
||||
- [HTML] Added support for replies. (Thanks [@Sanqui](https://github.com/Sanqui))
|
||||
- [HTML] Improved styling of non-media attachments (regular files, i.e. not video, audio, or image). (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
||||
- [HTML] Improved initial export performance.
|
||||
- [JSON] Relaxed escaping rules for unicode characters. (Thanks [@Sanqui](https://github.com/Sanqui))
|
||||
- [JSON] Added support for replies. (Thanks [@Sanqui](https://github.com/Sanqui))
|
||||
- [CLI] Added channel names to errors shown on failures when exporting multiple channels. (Thanks [@Sanqui](https://github.com/Sanqui))
|
||||
- [CLI] Added support for passing message IDs (snowflakes) to `--after` and `--before` options. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- Files downloaded by the "download referenced media" option now have their dates set according to the `Last-Modified` header provided by Discord CDN. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- Fixed an issue where the application sometimes crashed with `NullReferenceException` when retrying a failed HTTP request.
|
||||
- Migrated to Discord API v8.
|
||||
|
||||
## v2.25 (23-Nov-2020)
|
||||
|
||||
- [JSON] Added `mentions` property to the output. This contains users referenced inside the message text, but doesn't include mentions in embeds. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- [HTML] Added better previews for attached video and audio. They are now rendered using a browser native player element. The actual file path can still be retrieved by right clicking and selecting "Copy file path". (Thanks [@sas41](https://github.com/sas41))
|
||||
- [CLI] Fixed an issue where using `--media` option without providing a rooted path via `--output` option triggered an error.
|
||||
- [CLI] Fixed an issue where using `--reuse-media` option without also providing `--media` option was accepted, but didn't actually do anything. Now this produces an error instead. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
|
||||
## v2.24 (24-Oct-2020)
|
||||
|
||||
- [CLI] Updated to [CliFx v1.5](https://github.com/Tyrrrz/CliFx), which brings some UX improvements.
|
||||
- [GUI] Added dark mode, which can be enabled in settings. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- [GUI] Improved the UX in a few minor places.
|
||||
- [JSON] Added `embed.color` property to the output. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- Added additional date formats: `unix` to write dates as a unix timestamp and `unixms` for the milliseconds version. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- Added retry policy for downloading media content. This is mostly a workaround for transient failures that sometimes may occur when downloading assets referenced from embeds. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
- Added an option to reuse already downloaded media to avoid redundant network requests. It can be enabled in settings in GUI, or by passing `--reuse-media` in CLI. To facilitate this feature, the file name strategy has been changed as well -- now instead of relying on the original file name and adding `(n)` to the end in case of duplicates, a URL hash is injected in every file name. This also means that when the "reuse media" option is disabled, existing files inside the media directory may be overwritten. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
||||
|
||||
## v2.23 (14-Sep-2020)
|
||||
|
||||
- [CLI] Added a command to export all channels across all servers. Use `exportall` to do it. (Thanks [@wyattscarpenter](https://github.com/wyattscarpenter))
|
||||
- [HTML] Fixed an issue where Whitney fonts were not being loaded properly, causing the browser to fall back to Helvetica.
|
||||
- Fixed an issue where self-contained export crashed occasionally. This usually happened when the server hosting the file did not serve the stream properly. Such files are now ignored after the first failed attempt.
|
||||
|
||||
## v2.22 (12-Aug-2020)
|
||||
|
||||
- [GUI] Improved the channel list by adding collapsible category groups. (Thanks [@CarJem Generations](https://github.com/CarJem))
|
||||
- [GUI] Improved exporting options by adding a set of controls that can be used to limit the date range of the export down to minutes. Previously it was only possible to configure the date range without the time component. (Thanks [@CarJem Generations](https://github.com/CarJem))
|
||||
- [HTML] Fixed an issue where the export didn't reflect changes in nicknames between messages sent by bots. This affected chat logs that contained interactions with the Tupperbox bot. (Thanks [@CarJem Generations](https://github.com/CarJem))
|
||||
- [CLI] Fixed an issue where the application crashed if there were two environment variables defined that had the same name but in different case.
|
||||
|
||||
## v2.21.2 (30-Jul-2020)
|
||||
|
||||
- [GUI] When copy-pasting token, any surrounding spaces are now discarded, in addition to double quotes.
|
||||
- [HTML] Changed underlying templating engine to provide higher performance and better error messages. New templating engine adds a small cold start, but any export after the first should be faster.
|
||||
- Changed naming schema for downloaded media so that it follows `<original filename> (nn)` format rather than `<original filename>-salt`.
|
||||
- [HTML] Fixed an issue where downloaded media was sometimes inaccessible due to reserved characters appearing in the URL.
|
||||
- Fixed an issue where the application crashed when trying to download media with a file name that exceeds system's maximum allowed length.
|
||||
- Fixed an issue where the application crashed when trying to download media with illegal characters in the file name.
|
||||
|
||||
## v2.21.1 (19-Jul-2020)
|
||||
|
||||
- Fixed an issue where the export crashed if an embedded image has been deleted. Such media files are now ignored.
|
||||
- Changed the naming convention for downloaded media files so that the original file names are used when possible.
|
||||
|
||||
## v2.21 (18-Jul-2020)
|
||||
|
||||
- Added a new option that enables self-contained exports for all output formats. You can turn it on in the export setup dialog in GUI or using the `--media` option in CLI. When using this, the application will additionally download any media content directly referenced from the exported file instead of linking back to Discord CDN. The files which are downloaded include: guild icons, user avatars, attachments, embedded images, reaction emoji. Note that only files which are actually referenced by the export are downloaded, which means that, for example, user avatars will not be downloaded when using plain text export format. This option is not meant to enable complete offline viewing for HTML exports, but rather to make it easier to archive media content that may eventually get deleted from Discord servers. Also keep in mind that this option may make the export drastically slower and the total file size larger.
|
||||
- Changed "discordapp.com" to "discord.com" where applicable as Discord is migrating to a new domain. CDN will remain on "cdn.discordapp.com" for the foreseeable future.
|
||||
|
||||
Note that all existing and current HTML exports will likely not render accurately because Discord enabled CORS for their font resources, which prevents them from loading locally. Please refer to [issue #322](https://github.com/Tyrrrz/DiscordChatExporter/issues/322) for discussion on this topic.
|
||||
|
||||
## v2.20 (27-Apr-2020)
|
||||
|
||||
- [CLI] Added environment variables as fallback for `--token` and `--bot` options. They are `DISCORD_TOKEN` and `DISCORD_TOKEN_BOT` respectively.
|
||||
- [GUI] Fixed a crash that occurred if the application was closed in the middle of an auto-update.
|
||||
- [GUI] Added a link to project's wiki in the usage guide.
|
||||
- [HTML] Added full spoiler support for text and images. To spoil the hidden content you now need to click on it, similarly to how it works in Discord. (Thanks [@FM-96](https://github.com/FM-96))
|
||||
- [HTML] Updated grammar for consecutive single-line quotes. Previously they appeared separately, now they're grouped together as if it was one multi-line quote instead.
|
||||
- [HTML] Fixed an issue where messages sent by the same bot but with different usernames were grouped together when they shouldn't be.
|
||||
- [HTML] Updated grammar for single-line code blocks to accept double backticks as synonymous with single backticks. This change makes code blocks appear the same, whether they were inserted manually or using Discord's buggy markdown preview mode.
|
||||
- [HTML] Fixed styling inconsistencies and other minor issues.
|
||||
- [TXT/JSON] Fixed an issue where markdown was not parsed correctly in embed fields.
|
||||
- [HTML] Changed markdown formatting in embeds so it follows the same set of rules as in Discord.
|
||||
- Added channel category to the default file name used when exporting chat logs.
|
||||
- [HTML/TXT/JSON] Added channel category to exported metadata.
|
||||
- [CLI] Updated commands to also show channel category as well as channel name wherever relevant.
|
||||
- Starting with this release, Docker images will have new tags: `stable` for latest stable release and `2.20` for a specific version.
|
||||
|
||||
## v2.19 (26-Mar-2020)
|
||||
|
||||
- Added parallel exporting. This option allows you to export multiple channels faster by doing it in parallel. You can configure the parallel limit in settings (GUI) or with the `--parallel` option (CLI). Default value is `1`, which means there is no parallelization. Warning: be careful when using this option, as this will result in higher volume of concurrent HTTP requests sent to Discord, which might get you flagged. Use at your own risk.
|
||||
- [HTML] Added support for user colors. User names are now appropriately colored according to the assigned guild roles.
|
||||
- [HTML] Added support for nicknames. User names are replaced with nicknames where it's applicable. It's still possible to see the full user name by hovering your mouse over the nickname.
|
||||
- [HTML] Improved styling for mentions to bring it more in line with how it looks in Discord.
|
||||
|
||||
## v2.18 (04-Feb-2020)
|
||||
|
||||
- Added JSON export format. It's a structured data format which is easy to parse. If you're using DiscordChatExporter to export chat logs for further ingestion by another tool, this is most likely the format you will want to use.
|
||||
- [GUI] You can now quickly jump to a specific channel in a list. For example, if you want to jump to a channel named "General", you can simply press the 'g' key in the channel list view. You can also press 'g', 'e' and 'n' in quick succession which will jump to the next channel that starts with "gen". This mechanic is consistent with other Windows applications.
|
||||
- [CLI] Improved help text screen.
|
||||
|
||||
## v2.17 (12-Jan-2020)
|
||||
|
||||
- Fixed an issue where an empty file was produced when exporting a channel with no messages (for specified period). With the new behavior, no file will be created and instead a message will be shown to the user informing of the failure.
|
||||
- [HTML/TXT] Added message count to the bottom of the file. This number shows how many messages were exported as part of the current file. Prior to 2.16 this number was present along with the rest of the metadata at the top, then removed due to changes in the exporter, and now brought back at the end of the file instead.
|
||||
- [HTML] Fixed an issue where some emoji were not properly rendered.
|
||||
- [GUI] Added a setting that lets you configure whether to remember the last used token. Previously it was the default behavior, but now you can disable it if you don't want the token persisted on your system.
|
||||
|
||||
## v2.16 (08-Dec-2019)
|
||||
|
||||
- Migrated from .NET Framework to .NET Core. To run this and future versions of DiscordChatExporter you will need [.NET Core runtime for desktop apps](https://dotnet.microsoft.com/download/dotnet-core/3.1/runtime) (for GUI/CLI version on Windows) or [.NET Core base runtime](https://dotnet.microsoft.com/download/dotnet-core/3.1) (for CLI version on Windows, Linux or macOS).
|
||||
- Reworked the exporter engine to render output using streaming data source. This means that only a very small portion of messages are cached in memory when exporting. In other words, you are only limited by storage space and not how much RAM you have, so you can now export terabytes of chat logs without hitting out of memory exceptions. I still recommend using partitions if you're exporting very large chat logs (250k+ messages) to HTML, unless you want your computer to catch fire when you try to open the export in browser.
|
||||
- Changed how partitioned files are named, due to the fact that total number of partitions is no longer known ahead of time.
|
||||
- Added a warning about automating user accounts to the usage guide in both GUI and CLI versions.
|
||||
- Added support for announcement (news) channels. You will now be able to see them in the list and export them.
|
||||
- Fixed various issues that resulted in exceptions during export process.
|
||||
- [HTML/TXT] Removed message count from the metadata. Due to the fact that the messages are exported as they are streamed, total number of messages is not known ahead of time.
|
||||
- [HTML] Changed default color of the embed color pill to match the theme.
|
||||
- [HTML] Changed emoji parser to be less greedy. As a result it should match fewer character sequences that look like emoji but really aren't, but on the other hand it might miss some actual emoji. This means that some standard emoji (i.e. not custom server emoji) may not look like in Discord. This is a compromise I'm willing to take because detecting emoji in text is really hard to get right and not worth it at all.
|
||||
- [HTML] Some other minor styling adjustments.
|
||||
- [CSV] Replaced semicolons (;) with (,) as separators.
|
||||
|
||||
Please note that CSV export is most likely not going to receive future updates and will remain only as an option for those who wish to use it for text analysis. In other words, it won't contain any of the rich media features like embeds. If you're currently using CSV as a structured output to feed into your program, JSON output will replace that in the future.
|
||||
|
||||
## v2.15 (15-Sep-2019)
|
||||
|
||||
- Improved markdown parser and made it even faster for non-HTML formats.
|
||||
- [HTML] Added support for block quotes.
|
||||
- [HTML] Links pointing to a Discord message will now navigate to the linked message inside exported chat log if it's there.
|
||||
- [HTML] Updated light theme to match how it looks in Discord after recent changes.
|
||||
- [HTML] Added indication for when a message is pinned. Pinned messages now have a tinted background.
|
||||
- [HTML] Fixed an issue where multiline code blocks sometimes had incorrect formatting applied to them.
|
||||
- [TXT] Added indication for when a message is pinned. Pinned messages now have `(pinned)` next to timestamp and author.
|
||||
- [CSV] Added message author's user ID to output.
|
||||
- [GUI] Streamlined auto-update process a bit.
|
||||
- [GUI] Added some tooltips.
|
||||
|
||||
## v2.14 (15-Jun-2019)
|
||||
|
||||
- [TXT] Added support for embeds.
|
||||
- [TXT] Added support for reactions.
|
||||
- [CSV] Added support for reactions.
|
||||
- [TXT] Changed how attachments are rendered.
|
||||
|
||||
## v2.13.1 (06-Jun-2019)
|
||||
|
||||
- Fixed an issue where the app sometimes crashed when exporting due to `System.InvalidCastException`.
|
||||
- [HTML] Added `data-user-id` attribute to `span.chatlog__author-name`. The value of this attribute is author's Discord user ID.
|
||||
|
||||
## v2.13 (15-May-2019)
|
||||
|
||||
- Updated usage instructions.
|
||||
- [HTML] Added BOT tags to messages posted by bots.
|
||||
- [GUI] UI will now be disabled when exporting.
|
||||
- [GUI] Notification informing that the export has completed will now appear after all exports have completed, instead of each of them separately.
|
||||
|
||||
## v2.12.1 (12-Apr-2019)
|
||||
|
||||
- [GUI] Fixed an issue where the app crashed when trying to export multiple channels.
|
||||
- [HTML] Fixed an issue where some of the emoji were rendered via Twemoji while Discord renders them as plain text.
|
||||
- [HTML] Fixed an issue where emoji weren't jumbo if there were more than one of them.
|
||||
|
||||
## v2.12 (11-Apr-2019)
|
||||
|
||||
- Improved markdown parsing performance which speeds up the final stage of exporting by around 4.5 times.
|
||||
- Improved performance when exporting as PlainText or CSV.
|
||||
- [GUI] Fixed an issue where the app would freeze up and report as "not responding" during the final stage of exporting.
|
||||
- [CLI] Fixed an issue where it would say "Completed" after exporting a chat log, even if the process failed.
|
||||
|
||||
## v2.11 (14-Mar-2019)
|
||||
|
||||
- [HTML] Added syntax highlighting for multiline code blocks via Highlight.js.
|
||||
- Added retry policy for all 5xx status codes to prevent random crashes.
|
||||
|
||||
## v2.10.2 (10-Mar-2019)
|
||||
|
||||
- [HTML] Updated message grouping algorithm to make it the same as in Discord. Removed "message group limit" setting and parameter.
|
||||
- [HTML] Added small margin at the end of the chatlog so it doesn't look like it was truncated.
|
||||
- [CLI] Fixed an issue where the app would crash if stdout was redirected. Progress will not be reported in such cases.
|
||||
|
||||
## v2.10.1 (06-Mar-2019)
|
||||
|
||||
- [HTML] Fixed an issue where multiple emoji on a single line would get rendered as one emoji.
|
||||
- [HTML] Fixed an issue where an open square bracket character would incorrectly render as an emoji.
|
||||
- [HTML] Added alt text to emoji images so that they will be rendered using default font when Twemoji images are not available.
|
||||
|
||||
## v2.10 (03-Mar-2019)
|
||||
|
||||
- [HTML] Reworked the entire markdown parsing engine which fixes numerous rendering inconsistencies (over 15 issues fixed).
|
||||
- [HTML] Added support for animated emoji.
|
||||
- [HTML] Standard emoji are now rendered using Twemoji, the same image set that Discord uses.
|
||||
- [HTML] Fixed an issue where video attachments would render incorrectly.
|
||||
- [HTML] Minor fixes in styling.
|
||||
- [GUI] Aggregated export progress is now shown in the taskbar.
|
||||
- [GUI] Checkmarks are now displayed next to channels that are selected.
|
||||
- [CLI] Added progress reporting when exporting chat logs.
|
||||
|
||||
## v2.9.1 (10-Feb-2019)
|
||||
|
||||
- Fixed an issue where some of the last messages in a channel would sometimes not get exported.
|
||||
|
||||
## v2.9 (09-Feb-2019)
|
||||
|
||||
- Added categories to channel list in GUI. Channels are now also grouped by category.
|
||||
- Added ability to export multiple channels at once in GUI by selecting them with shift or ctrl keys.
|
||||
- Added CLI command to export all available channels in a guild (`exportguild`).
|
||||
- Added CLI command to export all direct message channels (`exportdm`).
|
||||
- Added retry policy for 503 status code errors to prevent random crashes.
|
||||
- Changed how channels are exported in GUI. Now you need to select them first and then click a button to export. You can also double click a single channel to export it as before.
|
||||
- Improved default file name generation by adding date ranges and channel ID to the file name.
|
||||
- Improved naming of files exported with partitioning.
|
||||
- Improved usage instructions.
|
||||
- Improved GUI layout and styling.
|
||||
- Fixed an issue where dialogs would sometimes appear over other windows.
|
||||
- Fixed an issue where launching DiscordChatExporter from Windows Start Menu would make it crash.
|
||||
|
||||
## v2.8 (03-Nov-2018)
|
||||
|
||||
- Added support for partitioning which lets you split the output into multiple files by setting the partition message limit (`-p` parameter for CLI).
|
||||
- Exported file will no longer open automatically on completion.
|
||||
- Reduced amount of memory used during exporting.
|
||||
- Disabled message grouping in PlainText export.
|
||||
- Improved encoding of newlines in CSV export.
|
||||
- Improved error messages in the GUI app during crashes.
|
||||
|
||||
## v2.7 (14-Sep-2018)
|
||||
|
||||
- Updated instructions on how to obtain the user token.
|
||||
- Expanded CLI with new commands: `channels` (get a list of channels in a guild), `dm` (get a list of DM channels), `guilds` (get a list of guilds), on top of `export` (export chatlog).
|
||||
- Improved help text and error messages in CLI.
|
||||
- In CLI, the file name will be automatically generated if the provided output file path is a directory.
|
||||
|
||||
## v2.6 (25-Jul-2018)
|
||||
|
||||
- Added support for bot tokens as an alternative to user tokens. For GUI, use the button in the top-left to switch between user and bot token. For CLI, pass the `--bot` switch to indicate that the given token is a bot token.
|
||||
- Added support for animated avatars.
|
||||
|
||||
## v2.5.1 (01-Jul-2018)
|
||||
|
||||
- Fixed a bug that would prevent timestamps from rendering properly in CSV and PlainText exports.
|
||||
- Fixed incorrect layout in CSV export.
|
||||
- Improved readability of PlainText export.
|
||||
|
||||
## v2.5 (28-Jun-2018)
|
||||
|
||||
- Added support for embeds and webhooks (HTML only).
|
||||
- Implemented progress reporting when downloading messages.
|
||||
- Added support for reactions (HTML only).
|
||||
- Selected date range is now shown in the export (HTML and PlainText).
|
||||
- Added placeholders for guild icons to display while the icons are loading.
|
||||
- Added support for jumbo emoji (custom emoji only).
|
||||
- Added basic retry policy for 429 error responses.
|
||||
- Added validation for from/to dates in the UI which prevents choosing invalid date ranges.
|
||||
- Added an error message when trying to export a deleted channel.
|
||||
|
||||
## v2.4.1 (15-Apr-2018)
|
||||
|
||||
- Added CSV export format.
|
||||
- Channels are now ordered by name in the UI.
|
||||
- Exported file is now always opened upon completion.
|
||||
|
||||
## v2.4 (08-Apr-2018)
|
||||
|
||||
- Added channel topic to output.
|
||||
- Added a command-line interface alternative to the current graphical user interface.
|
||||
- Implemented application auto-update (can be disabled in settings).
|
||||
- Improved some GUI elements and replaced some dialogs with notifications.
|
||||
- Fixed a lot of issues with the markdown processor.
|
||||
- Fixed DM group chats that have a custom name being shown as blank in the list.
|
||||
|
||||
## v2.3 (27-Oct-2017)
|
||||
|
||||
- Improved message date filtering, it's now marginally faster.
|
||||
- Fixed underscores not recognized as italics in markdown.
|
||||
- Added support for custom emoji.
|
||||
- Added support for user and role mentions.
|
||||
- Added support for channel mentions.
|
||||
- Fixed text in pre blocks not being wrapped correctly.
|
||||
- Added workaround for non-default message types.
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Version>2.42.3</Version>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Version>999.9.9-dev</Version>
|
||||
<Company>Tyrrrz</Company>
|
||||
<Copyright>Copyright (c) Oleksii Holub</Copyright>
|
||||
<LangVersion>preview</LangVersion>
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AngleSharp" Version="1.0.5" />
|
||||
<PackageReference Include="AngleSharp" Version="1.0.7" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.1" PrivateAssets="all" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.7" PrivateAssets="all" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" PrivateAssets="all" />
|
||||
<PackageReference Include="JsonExtensions" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="ReflectionMagic" Version="5.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" />
|
||||
<PackageReference Include="xunit" Version="2.6.4" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -57,7 +57,7 @@ public static class ExportWrapper
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { channelId },
|
||||
ChannelIds = [channelId],
|
||||
ExportFormat = format,
|
||||
OutputPath = filePath,
|
||||
Locale = "en-US",
|
||||
@@ -105,7 +105,7 @@ public static class ExportWrapper
|
||||
if (message is null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Message '{messageId}' does not exist in the export of channel '{channelId}'."
|
||||
$"Message #{messageId} not found in the export of channel #{channelId}."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public static class ExportWrapper
|
||||
if (message.ValueKind == JsonValueKind.Undefined)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Message '{messageId}' does not exist in the export of channel '{channelId}'."
|
||||
$"Message #{messageId} not found in the export of channel #{channelId}."
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DateRangeSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
||||
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
After = Snowflake.FromDate(after)
|
||||
@@ -45,24 +45,20 @@ public class DateRangeSpecs
|
||||
timestamps
|
||||
.Should()
|
||||
.BeEquivalentTo(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 09, 08, 14, 26, 35, TimeSpan.Zero)
|
||||
},
|
||||
],
|
||||
o =>
|
||||
{
|
||||
return o.Using<DateTimeOffset>(
|
||||
o.Using<DateTimeOffset>(
|
||||
ctx =>
|
||||
ctx.Subject
|
||||
.Should()
|
||||
ctx.Subject.Should()
|
||||
.BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
||||
)
|
||||
.WhenTypeIs<DateTimeOffset>();
|
||||
}
|
||||
.WhenTypeIs<DateTimeOffset>()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,7 +73,7 @@ public class DateRangeSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
||||
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
Before = Snowflake.FromDate(before)
|
||||
@@ -95,22 +91,18 @@ public class DateRangeSpecs
|
||||
timestamps
|
||||
.Should()
|
||||
.BeEquivalentTo(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
new DateTimeOffset(2021, 07, 19, 13, 34, 18, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 19, 15, 58, 48, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 19, 17, 23, 58, TimeSpan.Zero)
|
||||
},
|
||||
],
|
||||
o =>
|
||||
{
|
||||
return o.Using<DateTimeOffset>(
|
||||
o.Using<DateTimeOffset>(
|
||||
ctx =>
|
||||
ctx.Subject
|
||||
.Should()
|
||||
ctx.Subject.Should()
|
||||
.BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
||||
)
|
||||
.WhenTypeIs<DateTimeOffset>();
|
||||
}
|
||||
.WhenTypeIs<DateTimeOffset>()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -126,7 +118,7 @@ public class DateRangeSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
||||
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
Before = Snowflake.FromDate(before),
|
||||
@@ -145,23 +137,19 @@ public class DateRangeSpecs
|
||||
timestamps
|
||||
.Should()
|
||||
.BeEquivalentTo(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
|
||||
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero)
|
||||
},
|
||||
],
|
||||
o =>
|
||||
{
|
||||
return o.Using<DateTimeOffset>(
|
||||
o.Using<DateTimeOffset>(
|
||||
ctx =>
|
||||
ctx.Subject
|
||||
.Should()
|
||||
ctx.Subject.Should()
|
||||
.BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
||||
)
|
||||
.WhenTypeIs<DateTimeOffset>();
|
||||
}
|
||||
.WhenTypeIs<DateTimeOffset>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CliFx.Infrastructure;
|
||||
@@ -25,7 +26,7 @@ public class FilterSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
||||
ChannelIds = [ChannelIds.FilterTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
MessageFilter = MessageFilter.Parse("some text")
|
||||
@@ -37,7 +38,7 @@ public class FilterSpecs
|
||||
.EnumerateArray()
|
||||
.Select(j => j.GetProperty("content").GetString())
|
||||
.Should()
|
||||
.ContainSingle("Some random text");
|
||||
.AllSatisfy(c => c.Contains("Some random text", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -50,7 +51,7 @@ public class FilterSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
||||
ChannelIds = [ChannelIds.FilterTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
MessageFilter = MessageFilter.Parse("from:Tyrrrz")
|
||||
@@ -66,7 +67,7 @@ public class FilterSpecs
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task I_can_filter_the_export_to_only_include_messages_that_contain_the_specified_content()
|
||||
public async Task I_can_filter_the_export_to_only_include_messages_that_contain_images()
|
||||
{
|
||||
// Arrange
|
||||
using var file = TempFile.Create();
|
||||
@@ -75,7 +76,7 @@ public class FilterSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
||||
ChannelIds = [ChannelIds.FilterTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
MessageFilter = MessageFilter.Parse("has:image")
|
||||
@@ -87,7 +88,7 @@ public class FilterSpecs
|
||||
.EnumerateArray()
|
||||
.Select(j => j.GetProperty("content").GetString())
|
||||
.Should()
|
||||
.ContainSingle("This has image");
|
||||
.AllSatisfy(c => c.Contains("This has image", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -100,7 +101,7 @@ public class FilterSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
||||
ChannelIds = [ChannelIds.FilterTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
MessageFilter = MessageFilter.Parse("has:pin")
|
||||
@@ -112,7 +113,32 @@ public class FilterSpecs
|
||||
.EnumerateArray()
|
||||
.Select(j => j.GetProperty("content").GetString())
|
||||
.Should()
|
||||
.ContainSingle("This is pinned");
|
||||
.AllSatisfy(c => c.Contains("This is pinned", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task I_can_filter_the_export_to_only_include_messages_that_contain_guild_invites()
|
||||
{
|
||||
// Arrange
|
||||
using var file = TempFile.Create();
|
||||
|
||||
// Act
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = [ChannelIds.FilterTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
MessageFilter = MessageFilter.Parse("has:invite")
|
||||
}.ExecuteAsync(new FakeConsole());
|
||||
|
||||
// Assert
|
||||
Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||
.GetProperty("messages")
|
||||
.EnumerateArray()
|
||||
.Select(j => j.GetProperty("content").GetString())
|
||||
.Should()
|
||||
.AllSatisfy(c => c.Contains("This has invite", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -125,7 +151,7 @@ public class FilterSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
||||
ChannelIds = [ChannelIds.FilterTestCases],
|
||||
ExportFormat = ExportFormat.Json,
|
||||
OutputPath = file.Path,
|
||||
MessageFilter = MessageFilter.Parse("mentions:Tyrrrz")
|
||||
@@ -137,6 +163,6 @@ public class FilterSpecs
|
||||
.EnumerateArray()
|
||||
.Select(j => j.GetProperty("content").GetString())
|
||||
.Should()
|
||||
.ContainSingle("This has mention");
|
||||
.AllSatisfy(c => c.Contains("This has mention", StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,7 @@ public class HtmlAttachmentSpecs
|
||||
.QuerySelectorAll("a")
|
||||
.Select(e => e.GetAttribute("href"))
|
||||
.Should()
|
||||
.Contain(
|
||||
u =>
|
||||
u.StartsWith(
|
||||
"https://cdn.discordapp.com/attachments/885587741654536192/885587844964417596/Test.txt",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
);
|
||||
.Contain(u => u.Contains("Test.txt", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -52,13 +46,7 @@ public class HtmlAttachmentSpecs
|
||||
.QuerySelectorAll("img")
|
||||
.Select(e => e.GetAttribute("src"))
|
||||
.Should()
|
||||
.Contain(
|
||||
u =>
|
||||
u.StartsWith(
|
||||
"https://cdn.discordapp.com/attachments/885587741654536192/885654862430359613/bird-thumbnail.png",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
);
|
||||
.Contain(u => u.Contains("bird-thumbnail.png", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AngleSharp.Dom;
|
||||
using DiscordChatExporter.Cli.Tests.Infra;
|
||||
@@ -54,7 +55,7 @@ public class HtmlEmbedSpecs
|
||||
.QuerySelectorAll("img")
|
||||
.Select(e => e.GetAttribute("src"))
|
||||
.WhereNotNull()
|
||||
.Where(s => s.EndsWith("f8w05ja8s4e61.png"))
|
||||
.Where(s => s.Contains("f8w05ja8s4e61.png", StringComparison.Ordinal))
|
||||
.Should()
|
||||
.ContainSingle();
|
||||
}
|
||||
@@ -91,8 +92,9 @@ public class HtmlEmbedSpecs
|
||||
.WhereNotNull()
|
||||
.Where(
|
||||
s =>
|
||||
s.EndsWith(
|
||||
"i_am_currently_feeling_slight_displeasure_of_what_you_have_just_sent_lqrem.mp4"
|
||||
s.Contains(
|
||||
"i_am_currently_feeling_slight_displeasure_of_what_you_have_just_sent_lqrem.mp4",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
)
|
||||
.Should()
|
||||
@@ -113,7 +115,7 @@ public class HtmlEmbedSpecs
|
||||
.QuerySelectorAll("source")
|
||||
.Select(e => e.GetAttribute("src"))
|
||||
.WhereNotNull()
|
||||
.Where(s => s.EndsWith("tooncasm-test-copy.mp4"))
|
||||
.Where(s => s.Contains("tooncasm-test-copy.mp4", StringComparison.Ordinal))
|
||||
.Should()
|
||||
.ContainSingle();
|
||||
}
|
||||
@@ -148,6 +150,26 @@ public class HtmlEmbedSpecs
|
||||
iframeUrl.Should().StartWith("https://open.spotify.com/embed/track/1LHZMWefF9502NPfArRfvP");
|
||||
}
|
||||
|
||||
[Fact(Skip = "Twitch does not allow embeds from inside local HTML files")]
|
||||
public async Task I_can_export_a_channel_that_contains_a_message_with_a_Twitch_clip_embed()
|
||||
{
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1196
|
||||
|
||||
// Act
|
||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||
ChannelIds.EmbedTestCases,
|
||||
Snowflake.Parse("1207002986128216074")
|
||||
);
|
||||
|
||||
// Assert
|
||||
var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src");
|
||||
iframeUrl
|
||||
.Should()
|
||||
.StartWith(
|
||||
"https://clips.twitch.tv/embed?clip=SpicyMildCiderThisIsSparta--PQhbllrvej_Ee7v"
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task I_can_export_a_channel_that_contains_a_message_with_a_YouTube_video_embed()
|
||||
{
|
||||
@@ -176,15 +198,49 @@ public class HtmlEmbedSpecs
|
||||
);
|
||||
|
||||
// Assert
|
||||
message
|
||||
var imageUrls = message
|
||||
.QuerySelectorAll("img")
|
||||
.Select(e => e.GetAttribute("src"))
|
||||
.ToArray();
|
||||
|
||||
imageUrls
|
||||
.Should()
|
||||
.ContainInOrder(
|
||||
"https://images-ext-1.discordapp.net/external/-n--xW3EHH_3jlrheVkMXHCM7T86b5Ty4-MzXCT4m1Q/https/pbs.twimg.com/media/FVYIzYPWAAAMBqZ.png",
|
||||
"https://images-ext-2.discordapp.net/external/z5nEmGeEldV-kswydGLhqUsFHbb5AWHtdvc9XT6N5rE/https/pbs.twimg.com/media/FVYJBWJWAAMNAx2.png",
|
||||
"https://images-ext-2.discordapp.net/external/gnip03SawMB6uZLagN5sRDpA_1Ap1CcEhMbJfK1z6WQ/https/pbs.twimg.com/media/FVYJHiRX0AANZcz.png",
|
||||
"https://images-ext-2.discordapp.net/external/jl1v6cCbLaGmiwmKU-ZkXnF4cFsJ39f9A3-oEdqPdZs/https/pbs.twimg.com/media/FVYJNZNXwAAPnVG.png"
|
||||
.Contain(
|
||||
u =>
|
||||
u.EndsWith(
|
||||
"https/pbs.twimg.com/media/FVYIzYPWAAAMBqZ.png",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
);
|
||||
|
||||
imageUrls
|
||||
.Should()
|
||||
.Contain(
|
||||
u =>
|
||||
u.EndsWith(
|
||||
"https/pbs.twimg.com/media/FVYJBWJWAAMNAx2.png",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
);
|
||||
|
||||
imageUrls
|
||||
.Should()
|
||||
.Contain(
|
||||
u =>
|
||||
u.EndsWith(
|
||||
"https/pbs.twimg.com/media/FVYJHiRX0AANZcz.png",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
);
|
||||
|
||||
imageUrls
|
||||
.Should()
|
||||
.Contain(
|
||||
u =>
|
||||
u.EndsWith(
|
||||
"https/pbs.twimg.com/media/FVYJNZNXwAAPnVG.png",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
);
|
||||
|
||||
message.QuerySelectorAll(".chatlog__embed").Should().ContainSingle();
|
||||
@@ -202,6 +258,6 @@ public class HtmlEmbedSpecs
|
||||
);
|
||||
|
||||
// Assert
|
||||
message.Text().Should().Contain("DiscordChatExporter TestServer");
|
||||
message.Text().Should().Contain("DiscordChatExporter Test Server");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class HtmlGroupingSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.GroupingTestCases },
|
||||
ChannelIds = [ChannelIds.GroupingTestCases],
|
||||
ExportFormat = ExportFormat.HtmlDark,
|
||||
OutputPath = file.Path
|
||||
}.ExecuteAsync(new FakeConsole());
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PartitioningSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
||||
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||
ExportFormat = ExportFormat.HtmlDark,
|
||||
OutputPath = filePath,
|
||||
PartitionLimit = PartitionLimit.Parse("3")
|
||||
@@ -45,7 +45,7 @@ public class PartitioningSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
||||
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||
ExportFormat = ExportFormat.HtmlDark,
|
||||
OutputPath = filePath,
|
||||
PartitionLimit = PartitionLimit.Parse("1kb")
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SelfContainedSpecs
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
Token = Secrets.DiscordToken,
|
||||
ChannelIds = new[] { ChannelIds.SelfContainedTestCases },
|
||||
ChannelIds = [ChannelIds.SelfContainedTestCases],
|
||||
ExportFormat = ExportFormat.HtmlDark,
|
||||
OutputPath = filePath,
|
||||
ShouldDownloadAssets = true
|
||||
|
||||
@@ -5,11 +5,9 @@ using PathEx = System.IO.Path;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Tests.Utils;
|
||||
|
||||
internal partial class TempDir : IDisposable
|
||||
internal partial class TempDir(string path) : IDisposable
|
||||
{
|
||||
public string Path { get; }
|
||||
|
||||
public TempDir(string path) => Path = path;
|
||||
public string Path { get; } = path;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -5,11 +5,9 @@ using PathEx = System.IO.Path;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Tests.Utils;
|
||||
|
||||
internal partial class TempFile : IDisposable
|
||||
internal partial class TempFile(string path) : IDisposable
|
||||
{
|
||||
public string Path { get; }
|
||||
|
||||
public TempFile(string path) => Path = path;
|
||||
public string Path { get; } = path;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
# -- Build
|
||||
# Specify the platform here so that we pull the SDK image matching the host platform,
|
||||
# instead of the target platform specified during build by the `--platform` option.
|
||||
# Use the .NET 8.0 preview because the `--arch` option is only available in that version.
|
||||
# https://github.com/dotnet/dotnet-docker/issues/4388#issuecomment-1459038566
|
||||
# TODO: switch images to Alpine once .NET 8.0 is released.
|
||||
# Currently, the correct preview version is only available on Debian.
|
||||
# https://github.com/dotnet/dotnet-docker/blob/main/samples/selecting-tags.md
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-preview AS build
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
|
||||
|
||||
# Expose the target architecture set by the `docker build --platform` option, so that
|
||||
# we can build the assembly for the correct platform.
|
||||
ARG TARGETARCH
|
||||
|
||||
WORKDIR /tmp/dce
|
||||
# Allow setting the assembly version from the build command
|
||||
ARG VERSION=0.0.0
|
||||
|
||||
WORKDIR /tmp/app
|
||||
|
||||
COPY favicon.ico .
|
||||
COPY NuGet.config .
|
||||
@@ -22,6 +20,7 @@ COPY DiscordChatExporter.Cli DiscordChatExporter.Cli
|
||||
|
||||
# Publish a self-contained assembly so we can use a slimmer runtime image
|
||||
RUN dotnet publish DiscordChatExporter.Cli \
|
||||
-p:Version=$VERSION \
|
||||
-p:CSharpier_Bypass=true \
|
||||
--configuration Release \
|
||||
--self-contained \
|
||||
@@ -31,23 +30,31 @@ RUN dotnet publish DiscordChatExporter.Cli \
|
||||
|
||||
# -- Run
|
||||
# Use `runtime-deps` instead of `runtime` because we have a self-contained assembly
|
||||
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:7.0 AS run
|
||||
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS run
|
||||
|
||||
LABEL org.opencontainers.image.title="DiscordChatExporter.Cli"
|
||||
LABEL org.opencontainers.image.description="DiscordChatExporter is an application that can be used to export message history from any Discord channel to a file."
|
||||
LABEL org.opencontainers.image.authors="tyrrrz.me"
|
||||
LABEL org.opencontainers.image.url="https://github.com/Tyrrrz/DiscordChatExporter"
|
||||
LABEL org.opencontainers.image.source="https://github.com/Tyrrrz/DiscordChatExporter/blob/master/DiscordChatExporter.Cli.dockerfile"
|
||||
LABEL org.opencontainers.image.source="https://github.com/Tyrrrz/DiscordChatExporter"
|
||||
LABEL org.opencontainers.image.licenses="MIT"
|
||||
|
||||
# Create a non-root user to run the app, so that the output files can be accessed by the host
|
||||
# Alpine image doesn't come with the ICU libraries pre-installed, so we need to install them manually.
|
||||
# We need the full ICU data because we allow the user to specify any locale for formatting purposes.
|
||||
RUN apk add --no-cache icu-libs icu-data-full
|
||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
||||
ENV LC_ALL=en_US.UTF-8
|
||||
ENV LANG=en_US.UTF-8
|
||||
|
||||
# Use a non-root user to ensure that the files shared with the host are accessible by the host user
|
||||
# https://github.com/Tyrrrz/DiscordChatExporter/issues/851
|
||||
RUN adduser --disabled-password --no-create-home dce
|
||||
USER dce
|
||||
# https://github.com/Tyrrrz/DiscordChatExporter/issues/1174
|
||||
RUN apk add --no-cache su-exec
|
||||
RUN addgroup -S -g 1000 dce && adduser -S -H -G dce -u 1000 dce
|
||||
|
||||
# This directory is exposed to the user for mounting purposes, so it's important that it always
|
||||
# stays the same for backwards compatibility.
|
||||
WORKDIR /out
|
||||
|
||||
COPY --from=build /tmp/dce/DiscordChatExporter.Cli/bin/publish /opt/dce
|
||||
ENTRYPOINT ["/opt/dce/DiscordChatExporter.Cli"]
|
||||
COPY --from=build /tmp/app/DiscordChatExporter.Cli/bin/publish /opt/app
|
||||
COPY docker-entrypoint.sh /opt/app
|
||||
ENTRYPOINT ["/opt/app/docker-entrypoint.sh"]
|
||||
|
||||
@@ -4,6 +4,7 @@ using CliFx;
|
||||
using CliFx.Attributes;
|
||||
using CliFx.Infrastructure;
|
||||
using DiscordChatExporter.Core.Discord;
|
||||
using DiscordChatExporter.Core.Utils;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Commands.Base;
|
||||
|
||||
@@ -37,17 +38,24 @@ public abstract class DiscordCommandBase : ICommand
|
||||
{
|
||||
using (console.WithForegroundColor(ConsoleColor.DarkYellow))
|
||||
{
|
||||
console
|
||||
.Error
|
||||
.WriteLine(
|
||||
"Warning: Option --bot is deprecated and should not be used. "
|
||||
+ "The type of the provided token is now inferred automatically. "
|
||||
+ "Please update your workflows as this option may be completely removed in a future version."
|
||||
);
|
||||
console.Error.WriteLine(
|
||||
"Warning: The --bot option is deprecated and should not be used. "
|
||||
+ "The token type is now inferred automatically. "
|
||||
+ "Please update your workflows as this option may be completely removed in a future version."
|
||||
);
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
|
||||
// Note about interactivity for Docker
|
||||
if (console.IsOutputRedirected && Docker.IsRunningInContainer)
|
||||
{
|
||||
console.Error.WriteLine(
|
||||
"Note: Output streams are redirected, rich console interactions are disabled. "
|
||||
+ "If you are running this command in Docker, consider allocating a pseudo-terminal for better user experience (docker run -it ...)."
|
||||
);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -16,7 +15,6 @@ using DiscordChatExporter.Core.Exceptions;
|
||||
using DiscordChatExporter.Core.Exporting;
|
||||
using DiscordChatExporter.Core.Exporting.Filtering;
|
||||
using DiscordChatExporter.Core.Exporting.Partitioning;
|
||||
using DiscordChatExporter.Core.Utils;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
using Gress;
|
||||
using Spectre.Console;
|
||||
@@ -31,8 +29,8 @@ public abstract class ExportCommandBase : DiscordCommandBase
|
||||
"output",
|
||||
'o',
|
||||
Description = "Output file or directory path. "
|
||||
+ "Directory path must end with a slash to avoid ambiguity. "
|
||||
+ "If a directory is specified, file names will be generated automatically. "
|
||||
+ "If a directory is specified, file names will be generated automatically based on the channel names and export parameters. "
|
||||
+ "Directory paths must end with a slash to avoid ambiguity. "
|
||||
+ "Supports template tokens, see the documentation for more info."
|
||||
)]
|
||||
public string OutputPath
|
||||
@@ -119,8 +117,12 @@ public abstract class ExportCommandBase : DiscordCommandBase
|
||||
)]
|
||||
public string DateFormat { get; init; } = "MM/dd/yyyy h:mm tt";
|
||||
|
||||
[CommandOption("locale", Description = "Locale to use when formatting dates and numbers.")]
|
||||
public string Locale { get; init; } = CultureInfo.CurrentCulture.Name;
|
||||
[CommandOption(
|
||||
"locale",
|
||||
Description = "Locale to use when formatting dates and numbers. "
|
||||
+ "If not specified, the default system locale will be used."
|
||||
)]
|
||||
public string? Locale { get; init; }
|
||||
|
||||
[CommandOption("utc", Description = "Normalize all timestamps to UTC+0.")]
|
||||
public bool IsUtcNormalizationEnabled { get; init; } = false;
|
||||
@@ -163,13 +165,14 @@ public abstract class ExportCommandBase : DiscordCommandBase
|
||||
|| OutputPath.Contains('%')
|
||||
// Otherwise, require an existing directory or an unambiguous directory path
|
||||
|| Directory.Exists(OutputPath)
|
||||
|| PathEx.IsDirectoryPath(OutputPath);
|
||||
|| Path.EndsInDirectorySeparator(OutputPath);
|
||||
|
||||
if (!isValidOutputPath)
|
||||
{
|
||||
throw new CommandException(
|
||||
"Attempted to export multiple channels, but the output path is neither a directory nor a template. "
|
||||
+ "If the provided output path is meant to be treated as a directory, make sure it ends with a slash."
|
||||
+ "If the provided output path is meant to be treated as a directory, make sure it ends with a slash. "
|
||||
+ $"Provided output path: '{OutputPath}'."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -244,11 +247,9 @@ public abstract class ExportCommandBase : DiscordCommandBase
|
||||
// Print the result
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
{
|
||||
await console
|
||||
.Output
|
||||
.WriteLineAsync(
|
||||
$"Successfully exported {channels.Count - errorsByChannel.Count} channel(s)."
|
||||
);
|
||||
await console.Output.WriteLineAsync(
|
||||
$"Successfully exported {channels.Count - errorsByChannel.Count} channel(s)."
|
||||
);
|
||||
}
|
||||
|
||||
// Print errors
|
||||
@@ -258,11 +259,9 @@ public abstract class ExportCommandBase : DiscordCommandBase
|
||||
|
||||
using (console.WithForegroundColor(ConsoleColor.Red))
|
||||
{
|
||||
await console
|
||||
.Error
|
||||
.WriteLineAsync(
|
||||
$"Failed to export {errorsByChannel.Count} the following channel(s):"
|
||||
);
|
||||
await console.Error.WriteLineAsync(
|
||||
$"Failed to export {errorsByChannel.Count} the following channel(s):"
|
||||
);
|
||||
}
|
||||
|
||||
foreach (var (channel, error) in errorsByChannel)
|
||||
@@ -324,51 +323,33 @@ public abstract class ExportCommandBase : DiscordCommandBase
|
||||
// Support Ukraine callout
|
||||
if (!IsUkraineSupportMessageDisabled)
|
||||
{
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"┌────────────────────────────────────────────────────────────────────┐"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"│ Thank you for supporting Ukraine <3 │"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"│ │"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"│ As Russia wages a genocidal war against my country, │"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"│ I'm grateful to everyone who continues to │"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"│ stand with Ukraine in our fight for freedom. │"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"│ │"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"│ Learn more: https://tyrrrz.me/ukraine │"
|
||||
);
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
"└────────────────────────────────────────────────────────────────────┘"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"┌────────────────────────────────────────────────────────────────────┐"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"│ Thank you for supporting Ukraine <3 │"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"│ │"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"│ As Russia wages a genocidal war against my country, │"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"│ I'm grateful to everyone who continues to │"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"│ stand with Ukraine in our fight for freedom. │"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"│ │"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"│ Learn more: https://tyrrrz.me/ukraine │"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
"└────────────────────────────────────────────────────────────────────┘"
|
||||
);
|
||||
console.Output.WriteLine("");
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ExportAllCommand : ExportCommandBase
|
||||
[CommandOption("include-dm", Description = "Include direct message channels.")]
|
||||
public bool IncludeDirectChannels { get; init; } = true;
|
||||
|
||||
[CommandOption("include-guilds", Description = "Include guild channels.")]
|
||||
[CommandOption("include-guilds", Description = "Include server channels.")]
|
||||
public bool IncludeGuildChannels { get; init; } = true;
|
||||
|
||||
[CommandOption("include-vc", Description = "Include voice channels.")]
|
||||
@@ -54,9 +54,9 @@ public class ExportAllCommand : ExportCommandBase
|
||||
await foreach (var guild in Discord.GetUserGuildsAsync(cancellationToken))
|
||||
{
|
||||
// Regular channels
|
||||
await console
|
||||
.Output
|
||||
.WriteLineAsync($"Fetching channels for guild '{guild.Name}'...");
|
||||
await console.Output.WriteLineAsync(
|
||||
$"Fetching channels for server '{guild.Name}'..."
|
||||
);
|
||||
|
||||
var fetchedChannelsCount = 0;
|
||||
await console
|
||||
@@ -94,9 +94,9 @@ public class ExportAllCommand : ExportCommandBase
|
||||
// Threads
|
||||
if (ThreadInclusionMode != ThreadInclusionMode.None)
|
||||
{
|
||||
await console
|
||||
.Output
|
||||
.WriteLineAsync($"Fetching threads for guild '{guild.Name}'...");
|
||||
await console.Output.WriteLineAsync(
|
||||
$"Fetching threads for server '{guild.Name}'..."
|
||||
);
|
||||
|
||||
var fetchedThreadsCount = 0;
|
||||
await console
|
||||
@@ -126,9 +126,9 @@ public class ExportAllCommand : ExportCommandBase
|
||||
}
|
||||
);
|
||||
|
||||
await console
|
||||
.Output
|
||||
.WriteLineAsync($"Fetched {fetchedThreadsCount} thread(s).");
|
||||
await console.Output.WriteLineAsync(
|
||||
$"Fetched {fetchedThreadsCount} thread(s)."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,9 +180,9 @@ public class ExportAllCommand : ExportCommandBase
|
||||
|
||||
using (console.WithForegroundColor(ConsoleColor.Red))
|
||||
{
|
||||
await console
|
||||
.Error
|
||||
.WriteLineAsync("Failed to access the following channel(s):");
|
||||
await console.Error.WriteLineAsync(
|
||||
"Failed to access the following channel(s):"
|
||||
);
|
||||
}
|
||||
|
||||
foreach (var dumpChannel in inaccessibleChannels)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CliFx.Attributes;
|
||||
using CliFx.Infrastructure;
|
||||
@@ -13,10 +12,10 @@ using Spectre.Console;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Commands;
|
||||
|
||||
[Command("exportguild", Description = "Exports all channels within the specified guild.")]
|
||||
[Command("exportguild", Description = "Exports all channels within the specified server.")]
|
||||
public class ExportGuildCommand : ExportCommandBase
|
||||
{
|
||||
[CommandOption("guild", 'g', Description = "Guild ID.")]
|
||||
[CommandOption("guild", 'g', Description = "Server ID.")]
|
||||
public required Snowflake GuildId { get; init; }
|
||||
|
||||
[CommandOption("include-vc", Description = "Include voice channels.")]
|
||||
|
||||
@@ -12,10 +12,10 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Commands;
|
||||
|
||||
[Command("channels", Description = "Get the list of channels in a guild.")]
|
||||
[Command("channels", Description = "Get the list of channels in a server.")]
|
||||
public class GetChannelsCommand : DiscordCommandBase
|
||||
{
|
||||
[CommandOption("guild", 'g', Description = "Guild ID.")]
|
||||
[CommandOption("guild", 'g', Description = "Server ID.")]
|
||||
public required Snowflake GuildId { get; init; }
|
||||
|
||||
[CommandOption("include-vc", Description = "Include voice channels.")]
|
||||
@@ -64,9 +64,9 @@ public class GetChannelsCommand : DiscordCommandBase
|
||||
foreach (var channel in channels)
|
||||
{
|
||||
// Channel ID
|
||||
await console
|
||||
.Output
|
||||
.WriteAsync(channel.Id.ToString().PadRight(channelIdMaxLength, ' '));
|
||||
await console.Output.WriteAsync(
|
||||
channel.Id.ToString().PadRight(channelIdMaxLength, ' ')
|
||||
);
|
||||
|
||||
// Separator
|
||||
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||
@@ -88,11 +88,9 @@ public class GetChannelsCommand : DiscordCommandBase
|
||||
await console.Output.WriteAsync(" * ");
|
||||
|
||||
// Thread ID
|
||||
await console
|
||||
.Output
|
||||
.WriteAsync(
|
||||
channelThread.Id.ToString().PadRight(channelThreadIdMaxLength, ' ')
|
||||
);
|
||||
await console.Output.WriteAsync(
|
||||
channelThread.Id.ToString().PadRight(channelThreadIdMaxLength, ' ')
|
||||
);
|
||||
|
||||
// Separator
|
||||
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||
@@ -108,9 +106,9 @@ public class GetChannelsCommand : DiscordCommandBase
|
||||
|
||||
// Thread status
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
await console
|
||||
.Output
|
||||
.WriteLineAsync(channelThread.IsArchived ? "Archived" : "Active");
|
||||
await console.Output.WriteLineAsync(
|
||||
channelThread.IsArchived ? "Archived" : "Active"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class GetDirectChannelsCommand : DiscordCommandBase
|
||||
foreach (var channel in channels)
|
||||
{
|
||||
// Channel ID
|
||||
await console
|
||||
.Output
|
||||
.WriteAsync(channel.Id.ToString().PadRight(channelIdMaxLength, ' '));
|
||||
await console.Output.WriteAsync(
|
||||
channel.Id.ToString().PadRight(channelIdMaxLength, ' ')
|
||||
);
|
||||
|
||||
// Separator
|
||||
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||
|
||||
@@ -9,7 +9,7 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Commands;
|
||||
|
||||
[Command("guilds", Description = "Gets the list of accessible guilds.")]
|
||||
[Command("guilds", Description = "Gets the list of accessible servers.")]
|
||||
public class GetGuildsCommand : DiscordCommandBase
|
||||
{
|
||||
public override async ValueTask ExecuteAsync(IConsole console)
|
||||
|
||||
@@ -6,29 +6,25 @@ using CliFx.Infrastructure;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Commands;
|
||||
|
||||
[Command("guide", Description = "Explains how to obtain the token, guild or channel ID.")]
|
||||
[Command("guide", Description = "Explains how to obtain the token, server or channel ID.")]
|
||||
public class GuideCommand : ICommand
|
||||
{
|
||||
public ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
// User token
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
console.Output.WriteLine("To get user token:");
|
||||
console.Output.WriteLine("To get the token for your personal account:");
|
||||
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
" * Automating user accounts is technically against TOS — USE AT YOUR OWN RISK!"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
" * Automating user accounts is technically against TOS — USE AT YOUR OWN RISK!"
|
||||
);
|
||||
console.Output.WriteLine(" 1. Open Discord in your web browser and login");
|
||||
console.Output.WriteLine(" 2. Open any server or direct message channel");
|
||||
console.Output.WriteLine(" 3. Press Ctrl+Shift+I to show developer tools");
|
||||
console.Output.WriteLine(" 4. Navigate to the Network tab");
|
||||
console.Output.WriteLine(" 5. Press Ctrl+R to reload");
|
||||
console.Output.WriteLine(" 6. Switch between random channels to trigger network requests");
|
||||
console
|
||||
.Output
|
||||
.WriteLine(" 7. Search for a request containing \"messages?limit=50\" or similar");
|
||||
console.Output.WriteLine(" 7. Search for a request that starts with \"messages\"");
|
||||
console.Output.WriteLine(" 8. Select the Headers tab on the right");
|
||||
console.Output.WriteLine(" 9. Scroll down to the Request Headers section");
|
||||
console.Output.WriteLine(" 10. Copy the value of the \"authorization\" header");
|
||||
@@ -36,43 +32,44 @@ public class GuideCommand : ICommand
|
||||
|
||||
// Bot token
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
console.Output.WriteLine("To get bot token:");
|
||||
console.Output.WriteLine("To get the token for your bot:");
|
||||
|
||||
console.Output.WriteLine(" 1. Go to Discord developer portal");
|
||||
console.Output.WriteLine(" 2. Open your application's settings");
|
||||
console.Output.WriteLine(" 3. Navigate to the Bot section on the left");
|
||||
console.Output.WriteLine(" 4. Under Token click Copy");
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
" * Your bot needs to have Message Content Intent enabled to read messages"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
" * Your bot needs to have the Message Content Intent enabled to read messages"
|
||||
);
|
||||
console.Output.WriteLine();
|
||||
|
||||
// Guild or channel ID
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
console.Output.WriteLine("To get guild ID or channel ID:");
|
||||
console.Output.WriteLine("To get the ID of a server or a channel:");
|
||||
|
||||
console.Output.WriteLine(" 1. Open Discord");
|
||||
console.Output.WriteLine(" 2. Open Settings");
|
||||
console.Output.WriteLine(" 3. Go to Advanced section");
|
||||
console.Output.WriteLine(" 4. Enable Developer Mode");
|
||||
console
|
||||
.Output
|
||||
.WriteLine(
|
||||
" 5. Right-click on the desired guild or channel and click Copy Server ID or Copy Channel ID"
|
||||
);
|
||||
console.Output.WriteLine(
|
||||
" 5. Right-click on the desired server or channel and click Copy Server ID or Copy Channel ID"
|
||||
);
|
||||
console.Output.WriteLine();
|
||||
|
||||
// Docs link
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
console
|
||||
.Output
|
||||
.WriteLine("If you have questions or issues, please refer to the documentation:");
|
||||
{
|
||||
console.Output.WriteLine(
|
||||
"If you have questions or issues, please refer to the documentation:"
|
||||
);
|
||||
}
|
||||
|
||||
using (console.WithForegroundColor(ConsoleColor.DarkCyan))
|
||||
console
|
||||
.Output
|
||||
.WriteLine("https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs");
|
||||
{
|
||||
console.Output.WriteLine(
|
||||
"https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs"
|
||||
);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CliFx" Version="2.3.4" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.1" PrivateAssets="all" />
|
||||
<PackageReference Include="CliFx" Version="2.3.5" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.7" PrivateAssets="all" />
|
||||
<PackageReference Include="Deorcify" Version="1.0.2" PrivateAssets="all" />
|
||||
<PackageReference Include="DotnetRuntimeBootstrapper" Version="2.5.1" PrivateAssets="all" />
|
||||
<PackageReference Include="DotnetRuntimeBootstrapper" Version="2.5.2" PrivateAssets="all" />
|
||||
<PackageReference Include="Gress" Version="2.1.1" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.47.0" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.48.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord.Data.Common;
|
||||
|
||||
@@ -11,7 +10,7 @@ public static class ImageCdn
|
||||
// Standard emoji are rendered through Twemoji
|
||||
public static string GetStandardEmojiUrl(string emojiName)
|
||||
{
|
||||
var runes = emojiName.GetRunes().ToArray();
|
||||
var runes = emojiName.EnumerateRunes().ToArray();
|
||||
|
||||
// Variant selector rune is skipped in Twemoji IDs,
|
||||
// except when the emoji also contains a zero-width joiner.
|
||||
|
||||
@@ -31,6 +31,9 @@ public partial record Embed(
|
||||
public SpotifyTrackEmbedProjection? TryGetSpotifyTrack() =>
|
||||
SpotifyTrackEmbedProjection.TryResolve(this);
|
||||
|
||||
public TwitchClipEmbedProjection? TryGetTwitchClip() =>
|
||||
TwitchClipEmbedProjection.TryResolve(this);
|
||||
|
||||
public YouTubeVideoEmbedProjection? TryGetYouTubeVideo() =>
|
||||
YouTubeVideoEmbedProjection.TryResolve(this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||
|
||||
public partial record TwitchClipEmbedProjection(string ClipId)
|
||||
{
|
||||
public string Url => $"https://clips.twitch.tv/embed?clip={ClipId}&parent=localhost";
|
||||
}
|
||||
|
||||
public partial record TwitchClipEmbedProjection
|
||||
{
|
||||
private static string? TryParseClipId(string embedUrl)
|
||||
{
|
||||
// https://clips.twitch.tv/SpookyTenuousPidgeonPanicVis
|
||||
{
|
||||
var clipId = Regex
|
||||
.Match(embedUrl, @"clips\.twitch\.tv/(.*?)(?:\?|&|/|$)")
|
||||
.Groups[1]
|
||||
.Value;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(clipId))
|
||||
return clipId;
|
||||
}
|
||||
|
||||
// https://twitch.tv/clip/SpookyTenuousPidgeonPanicVis
|
||||
{
|
||||
var clipId = Regex
|
||||
.Match(embedUrl, @"twitch\.tv/clip/(.*?)(?:\?|&|/|$)")
|
||||
.Groups[1]
|
||||
.Value;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(clipId))
|
||||
return clipId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TwitchClipEmbedProjection? TryResolve(Embed embed)
|
||||
{
|
||||
if (embed.Kind != EmbedKind.Video)
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(embed.Url))
|
||||
return null;
|
||||
|
||||
var clipId = TryParseClipId(embed.Url);
|
||||
if (string.IsNullOrWhiteSpace(clipId))
|
||||
return null;
|
||||
|
||||
return new TwitchClipEmbedProjection(clipId);
|
||||
}
|
||||
}
|
||||
@@ -100,8 +100,7 @@ public partial record Message
|
||||
{
|
||||
// Concatenate all images into one embed
|
||||
var images = embed
|
||||
.Images
|
||||
.Concat(trailingEmbeds.SelectMany(e => e.Images))
|
||||
.Images.Concat(trailingEmbeds.SelectMany(e => e.Images))
|
||||
.ToArray();
|
||||
|
||||
normalizedEmbeds.Add(embed with { Images = images });
|
||||
|
||||
@@ -7,7 +7,12 @@ using JsonExtensions.Reading;
|
||||
namespace DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
// https://discord.com/developers/docs/resources/sticker#sticker-resource
|
||||
public record Sticker(Snowflake Id, string Name, StickerFormat Format, string SourceUrl)
|
||||
public partial record Sticker(Snowflake Id, string Name, StickerFormat Format, string SourceUrl)
|
||||
{
|
||||
public bool IsImage => Format != StickerFormat.Lottie;
|
||||
}
|
||||
|
||||
public partial record Sticker
|
||||
{
|
||||
public static Sticker Parse(JsonElement json)
|
||||
{
|
||||
@@ -22,6 +27,7 @@ public record Sticker(Snowflake Id, string Name, StickerFormat Format, string So
|
||||
StickerFormat.Png => "png",
|
||||
StickerFormat.Apng => "png",
|
||||
StickerFormat.Lottie => "json",
|
||||
StickerFormat.Gif => "gif",
|
||||
_ => throw new InvalidOperationException($"Unknown sticker format '{format}'.")
|
||||
}
|
||||
);
|
||||
|
||||
@@ -4,5 +4,6 @@ public enum StickerFormat
|
||||
{
|
||||
Png = 1,
|
||||
Apng = 2,
|
||||
Lottie = 3
|
||||
Lottie = 3,
|
||||
Gif = 4
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@ using JsonExtensions.Reading;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord;
|
||||
|
||||
public class DiscordClient
|
||||
public class DiscordClient(string token)
|
||||
{
|
||||
private readonly string _token;
|
||||
private readonly Uri _baseUri = new("https://discord.com/api/v10/", UriKind.Absolute);
|
||||
|
||||
private TokenKind? _resolvedTokenKind;
|
||||
|
||||
public DiscordClient(string token) => _token = token;
|
||||
|
||||
private async ValueTask<HttpResponseMessage> GetResponseAsync(
|
||||
string url,
|
||||
TokenKind tokenKind,
|
||||
@@ -40,12 +36,10 @@ public class DiscordClient
|
||||
|
||||
// Don't validate because the token can have special characters
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/828
|
||||
request
|
||||
.Headers
|
||||
.TryAddWithoutValidation(
|
||||
"Authorization",
|
||||
tokenKind == TokenKind.Bot ? $"Bot {_token}" : _token
|
||||
);
|
||||
request.Headers.TryAddWithoutValidation(
|
||||
"Authorization",
|
||||
tokenKind == TokenKind.Bot ? $"Bot {token}" : token
|
||||
);
|
||||
|
||||
var response = await Http.Client.SendAsync(
|
||||
request,
|
||||
@@ -61,13 +55,11 @@ public class DiscordClient
|
||||
// rate limits and that's just way too much effort.
|
||||
// https://discord.com/developers/docs/topics/rate-limits
|
||||
var remainingRequestCount = response
|
||||
.Headers
|
||||
.TryGetValue("X-RateLimit-Remaining")
|
||||
.Headers.TryGetValue("X-RateLimit-Remaining")
|
||||
?.Pipe(s => int.Parse(s, CultureInfo.InvariantCulture));
|
||||
|
||||
var resetAfterDelay = response
|
||||
.Headers
|
||||
.TryGetValue("X-RateLimit-Reset-After")
|
||||
.Headers.TryGetValue("X-RateLimit-Reset-After")
|
||||
?.Pipe(s => double.Parse(s, CultureInfo.InvariantCulture))
|
||||
.Pipe(TimeSpan.FromSeconds);
|
||||
|
||||
@@ -618,7 +610,7 @@ public class DiscordClient
|
||||
if (!application.IsMessageContentIntentEnabled)
|
||||
{
|
||||
throw new DiscordChatExporterException(
|
||||
"Bot account does not have the Message Content Intent enabled.",
|
||||
"Provided bot account does not have the Message Content Intent enabled.",
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,9 @@ using JsonExtensions.Reading;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord.Dump;
|
||||
|
||||
public partial class DataDump
|
||||
public partial class DataDump(IReadOnlyList<DataDumpChannel> channels)
|
||||
{
|
||||
public IReadOnlyList<DataDumpChannel> Channels { get; }
|
||||
|
||||
public DataDump(IReadOnlyList<DataDumpChannel> channels) => Channels = channels;
|
||||
public IReadOnlyList<DataDumpChannel> Channels { get; } = channels;
|
||||
}
|
||||
|
||||
public partial class DataDump
|
||||
@@ -48,7 +46,7 @@ public partial class DataDump
|
||||
if (entry is null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Could not find the channel index inside the data package."
|
||||
"Failed to locate the channel index inside the data package."
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,26 +22,27 @@ public partial record struct Snowflake
|
||||
public static Snowflake FromDate(DateTimeOffset instant) =>
|
||||
new(((ulong)instant.ToUnixTimeMilliseconds() - 1420070400000UL) << 22);
|
||||
|
||||
public static Snowflake? TryParse(string? str, IFormatProvider? formatProvider = null)
|
||||
public static Snowflake? TryParse(string? value, IFormatProvider? formatProvider = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return null;
|
||||
|
||||
// As number
|
||||
if (ulong.TryParse(str, NumberStyles.None, formatProvider, out var value))
|
||||
return new Snowflake(value);
|
||||
if (ulong.TryParse(value, NumberStyles.None, formatProvider, out var number))
|
||||
return new Snowflake(number);
|
||||
|
||||
// As date
|
||||
if (DateTimeOffset.TryParse(str, formatProvider, DateTimeStyles.None, out var instant))
|
||||
if (DateTimeOffset.TryParse(value, formatProvider, DateTimeStyles.None, out var instant))
|
||||
return FromDate(instant);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Snowflake Parse(string str, IFormatProvider? formatProvider) =>
|
||||
TryParse(str, formatProvider) ?? throw new FormatException($"Invalid snowflake '{str}'.");
|
||||
public static Snowflake Parse(string value, IFormatProvider? formatProvider) =>
|
||||
TryParse(value, formatProvider)
|
||||
?? throw new FormatException($"Invalid snowflake '{value}'.");
|
||||
|
||||
public static Snowflake Parse(string str) => Parse(str, null);
|
||||
public static Snowflake Parse(string value) => Parse(value, null);
|
||||
}
|
||||
|
||||
public partial record struct Snowflake : IComparable<Snowflake>, IComparable
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncKeyedLock" Version="6.2.2" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.1" PrivateAssets="all" />
|
||||
<PackageReference Include="AsyncKeyedLock" Version="6.2.4" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.7" PrivateAssets="all" />
|
||||
<PackageReference Include="Gress" Version="2.1.1" />
|
||||
<PackageReference Include="JsonExtensions" Version="1.2.0" />
|
||||
<PackageReference Include="Polly" Version="8.1.0" />
|
||||
<PackageReference Include="RazorBlade" Version="0.4.4" />
|
||||
<PackageReference Include="Polly" Version="8.2.0" />
|
||||
<PackageReference Include="RazorBlade" Version="0.5.0" />
|
||||
<PackageReference Include="Superpower" Version="3.0.0" />
|
||||
<PackageReference Include="WebMarkupMin.Core" Version="2.14.0" />
|
||||
<PackageReference Include="YoutubeExplode" Version="6.3.7" />
|
||||
<PackageReference Include="YoutubeExplode" Version="6.3.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
namespace DiscordChatExporter.Core.Exceptions;
|
||||
|
||||
public class DiscordChatExporterException : Exception
|
||||
public class DiscordChatExporterException(
|
||||
string message,
|
||||
bool isFatal = false,
|
||||
Exception? innerException = null
|
||||
) : Exception(message, innerException)
|
||||
{
|
||||
public bool IsFatal { get; }
|
||||
|
||||
public DiscordChatExporterException(string message, bool isFatal = false)
|
||||
: base(message)
|
||||
{
|
||||
IsFatal = isFatal;
|
||||
}
|
||||
public bool IsFatal { get; } = isFatal;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,8 @@ using Gress;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
public class ChannelExporter
|
||||
public class ChannelExporter(DiscordClient discord)
|
||||
{
|
||||
private readonly DiscordClient _discord;
|
||||
|
||||
public ChannelExporter(DiscordClient discord) => _discord = discord;
|
||||
|
||||
public async ValueTask ExportChannelAsync(
|
||||
ExportRequest request,
|
||||
IProgress<Percentage>? progress = null,
|
||||
@@ -24,7 +20,9 @@ public class ChannelExporter
|
||||
if (request.Channel.Kind == ChannelKind.GuildForum)
|
||||
{
|
||||
throw new DiscordChatExporterException(
|
||||
"Channel is a forum and cannot be exported directly. "
|
||||
$"Channel '{request.Channel.Name}' "
|
||||
+ $"of guild '{request.Guild.Name}' "
|
||||
+ $"is a forum and cannot be exported directly. "
|
||||
+ "You need to pull its threads and export them individually."
|
||||
);
|
||||
}
|
||||
@@ -32,14 +30,20 @@ public class ChannelExporter
|
||||
// Check if the channel is empty
|
||||
if (request.Channel.IsEmpty)
|
||||
{
|
||||
throw new DiscordChatExporterException("Channel does not contain any messages.");
|
||||
throw new DiscordChatExporterException(
|
||||
$"Channel '{request.Channel.Name}' "
|
||||
+ $"of guild '{request.Guild.Name}' "
|
||||
+ $"does not contain any messages."
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the 'after' boundary is valid
|
||||
if (request.After is not null && !request.Channel.MayHaveMessagesAfter(request.After.Value))
|
||||
{
|
||||
throw new DiscordChatExporterException(
|
||||
"Channel does not contain any messages within the specified period."
|
||||
$"Channel '{request.Channel.Name}' "
|
||||
+ $"of guild '{request.Guild.Name}' "
|
||||
+ $"does not contain any messages within the specified period."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,18 +54,20 @@ public class ChannelExporter
|
||||
)
|
||||
{
|
||||
throw new DiscordChatExporterException(
|
||||
"Channel does not contain any messages within the specified period."
|
||||
$"Channel '{request.Channel.Name}' "
|
||||
+ $"of guild '{request.Guild.Name}' "
|
||||
+ $"does not contain any messages within the specified period."
|
||||
);
|
||||
}
|
||||
|
||||
// Build context
|
||||
var context = new ExportContext(_discord, request);
|
||||
var context = new ExportContext(discord, request);
|
||||
await context.PopulateChannelsAndRolesAsync(cancellationToken);
|
||||
|
||||
// Export messages
|
||||
await using var messageExporter = new MessageExporter(context);
|
||||
await foreach (
|
||||
var message in _discord.GetMessagesAsync(
|
||||
var message in discord.GetMessagesAsync(
|
||||
request.Channel.Id,
|
||||
request.After,
|
||||
request.Before,
|
||||
@@ -70,20 +76,36 @@ public class ChannelExporter
|
||||
)
|
||||
)
|
||||
{
|
||||
// Resolve members for referenced users
|
||||
foreach (var user in message.GetReferencedUsers())
|
||||
await context.PopulateMemberAsync(user, cancellationToken);
|
||||
try
|
||||
{
|
||||
// Resolve members for referenced users
|
||||
foreach (var user in message.GetReferencedUsers())
|
||||
await context.PopulateMemberAsync(user, cancellationToken);
|
||||
|
||||
// Export the message
|
||||
if (request.MessageFilter.IsMatch(message))
|
||||
await messageExporter.ExportMessageAsync(message, cancellationToken);
|
||||
// Export the message
|
||||
if (request.MessageFilter.IsMatch(message))
|
||||
await messageExporter.ExportMessageAsync(message, cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Provide more context to the exception, to simplify debugging based on error messages
|
||||
throw new DiscordChatExporterException(
|
||||
$"Failed to export message #{message.Id} "
|
||||
+ $"in channel '{request.Channel.Name}' (#{request.Channel.Id}) "
|
||||
+ $"of guild '{request.Guild.Name} (#{request.Guild.Id})'.",
|
||||
ex is not DiscordChatExporterException dex || dex.IsFatal,
|
||||
ex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Throw if no messages were exported
|
||||
if (messageExporter.MessagesExported <= 0)
|
||||
{
|
||||
throw new DiscordChatExporterException(
|
||||
"Channel does not contain any matching messages within the specified period."
|
||||
$"Channel '{request.Channel.Name}' (#{request.Channel.Id}) "
|
||||
+ $"of guild '{request.Guild.Name}' (#{request.Guild.Id}) "
|
||||
+ $"does not contain any matching messages within the specified period."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -8,15 +9,10 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal partial class CsvMessageWriter : MessageWriter
|
||||
internal partial class CsvMessageWriter(Stream stream, ExportContext context)
|
||||
: MessageWriter(stream, context)
|
||||
{
|
||||
private readonly TextWriter _writer;
|
||||
|
||||
public CsvMessageWriter(Stream stream, ExportContext context)
|
||||
: base(stream, context)
|
||||
{
|
||||
_writer = new StreamWriter(stream);
|
||||
}
|
||||
private readonly TextWriter _writer = new StreamWriter(stream);
|
||||
|
||||
private async ValueTask<string> FormatMarkdownAsync(
|
||||
string markdown,
|
||||
@@ -127,7 +123,7 @@ internal partial class CsvMessageWriter
|
||||
{
|
||||
private static string CsvEncode(string value)
|
||||
{
|
||||
value = value.Replace("\"", "\"\"");
|
||||
value = value.Replace("\"", "\"\"", StringComparison.Ordinal);
|
||||
return $"\"{value}\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal partial class ExportAssetDownloader
|
||||
internal partial class ExportAssetDownloader(string workingDirPath, bool reuse)
|
||||
{
|
||||
private static readonly AsyncKeyedLocker<string> Locker =
|
||||
new(o =>
|
||||
@@ -23,25 +23,16 @@ internal partial class ExportAssetDownloader
|
||||
o.PoolInitialFill = 1;
|
||||
});
|
||||
|
||||
private readonly string _workingDirPath;
|
||||
private readonly bool _reuse;
|
||||
|
||||
// File paths of the previously downloaded assets
|
||||
private readonly Dictionary<string, string> _previousPathsByUrl = new(StringComparer.Ordinal);
|
||||
|
||||
public ExportAssetDownloader(string workingDirPath, bool reuse)
|
||||
{
|
||||
_workingDirPath = workingDirPath;
|
||||
_reuse = reuse;
|
||||
}
|
||||
|
||||
public async ValueTask<string> DownloadAsync(
|
||||
string url,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
var fileName = GetFileNameFromUrl(url);
|
||||
var filePath = Path.Combine(_workingDirPath, fileName);
|
||||
var filePath = Path.Combine(workingDirPath, fileName);
|
||||
|
||||
using var _ = await Locker.LockAsync(filePath, cancellationToken);
|
||||
|
||||
@@ -49,10 +40,10 @@ internal partial class ExportAssetDownloader
|
||||
return cachedFilePath;
|
||||
|
||||
// Reuse existing files if we're allowed to
|
||||
if (_reuse && File.Exists(filePath))
|
||||
if (reuse && File.Exists(filePath))
|
||||
return _previousPathsByUrl[url] = filePath;
|
||||
|
||||
Directory.CreateDirectory(_workingDirPath);
|
||||
Directory.CreateDirectory(workingDirPath);
|
||||
|
||||
await Http.ResiliencePipeline.ExecuteAsync(
|
||||
async innerCancellationToken =>
|
||||
@@ -66,9 +57,7 @@ internal partial class ExportAssetDownloader
|
||||
try
|
||||
{
|
||||
var lastModified = response
|
||||
.Content
|
||||
.Headers
|
||||
.TryGetValue("Last-Modified")
|
||||
.Content.Headers.TryGetValue("Last-Modified")
|
||||
?.Pipe(
|
||||
s =>
|
||||
DateTimeOffset.TryParse(
|
||||
|
||||
@@ -12,27 +12,18 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal class ExportContext
|
||||
internal class ExportContext(DiscordClient discord, ExportRequest request)
|
||||
{
|
||||
private readonly Dictionary<Snowflake, Member?> _membersById = new();
|
||||
private readonly Dictionary<Snowflake, Channel> _channelsById = new();
|
||||
private readonly Dictionary<Snowflake, Role> _rolesById = new();
|
||||
private readonly ExportAssetDownloader _assetDownloader;
|
||||
|
||||
public DiscordClient Discord { get; }
|
||||
private readonly ExportAssetDownloader _assetDownloader =
|
||||
new(request.AssetsDirPath, request.ShouldReuseAssets);
|
||||
|
||||
public ExportRequest Request { get; }
|
||||
public DiscordClient Discord { get; } = discord;
|
||||
|
||||
public ExportContext(DiscordClient discord, ExportRequest request)
|
||||
{
|
||||
Discord = discord;
|
||||
Request = request;
|
||||
|
||||
_assetDownloader = new ExportAssetDownloader(
|
||||
request.AssetsDirPath,
|
||||
request.ShouldReuseAssets
|
||||
);
|
||||
}
|
||||
public ExportRequest Request { get; } = request;
|
||||
|
||||
public DateTimeOffset NormalizeDate(DateTimeOffset instant) =>
|
||||
Request.IsUtcNormalizationEnabled ? instant.ToUniversalTime() : instant.ToLocalTime();
|
||||
@@ -124,9 +115,9 @@ internal class ExportContext
|
||||
var filePath = await _assetDownloader.DownloadAsync(url, cancellationToken);
|
||||
var relativeFilePath = Path.GetRelativePath(Request.OutputDirPath, filePath);
|
||||
|
||||
// Prefer relative paths so that the output files can be copied around without breaking references.
|
||||
// If the asset directory is outside of the export directory, use an absolute path instead.
|
||||
var optimalFilePath =
|
||||
// Prefer the relative path so that the export package can be copied around without breaking references.
|
||||
// However, if the assets directory lies outside of the export directory, use the absolute path instead.
|
||||
var shouldUseAbsoluteFilePath =
|
||||
relativeFilePath.StartsWith(
|
||||
".." + Path.DirectorySeparatorChar,
|
||||
StringComparison.Ordinal
|
||||
@@ -134,15 +125,19 @@ internal class ExportContext
|
||||
|| relativeFilePath.StartsWith(
|
||||
".." + Path.AltDirectorySeparatorChar,
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
? filePath
|
||||
: relativeFilePath;
|
||||
);
|
||||
|
||||
var optimalFilePath = shouldUseAbsoluteFilePath ? filePath : relativeFilePath;
|
||||
|
||||
// For HTML, the path needs to be properly formatted
|
||||
if (Request.Format is ExportFormat.HtmlDark or ExportFormat.HtmlLight)
|
||||
{
|
||||
// Create a 'file:///' URI and then strip the 'file:///' prefix to allow for relative paths
|
||||
return new Uri(new Uri("file:///"), optimalFilePath).ToString()[8..];
|
||||
// Format the path into a valid file URI
|
||||
var href = new Uri(new Uri("file:///"), optimalFilePath).ToString();
|
||||
|
||||
// File schema does not support relative paths, so strip it if that's the case
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1155
|
||||
return shouldUseAbsoluteFilePath ? href : href[8..];
|
||||
}
|
||||
|
||||
return optimalFilePath;
|
||||
|
||||
@@ -8,6 +8,7 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
using DiscordChatExporter.Core.Exporting.Filtering;
|
||||
using DiscordChatExporter.Core.Exporting.Partitioning;
|
||||
using DiscordChatExporter.Core.Utils;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
@@ -39,9 +40,9 @@ public partial class ExportRequest
|
||||
|
||||
public bool ShouldReuseAssets { get; }
|
||||
|
||||
public string Locale { get; }
|
||||
public string? Locale { get; }
|
||||
|
||||
public CultureInfo CultureInfo { get; }
|
||||
public CultureInfo? CultureInfo { get; }
|
||||
|
||||
public bool IsUtcNormalizationEnabled { get; }
|
||||
|
||||
@@ -58,7 +59,7 @@ public partial class ExportRequest
|
||||
bool shouldFormatMarkdown,
|
||||
bool shouldDownloadAssets,
|
||||
bool shouldReuseAssets,
|
||||
string locale,
|
||||
string? locale,
|
||||
bool isUtcNormalizationEnabled
|
||||
)
|
||||
{
|
||||
@@ -83,7 +84,7 @@ public partial class ExportRequest
|
||||
? FormatPath(assetsDirPath, Guild, Channel, After, Before)
|
||||
: $"{OutputFilePath}_Files{Path.DirectorySeparatorChar}";
|
||||
|
||||
CultureInfo = CultureInfo.GetCultureInfo(Locale);
|
||||
CultureInfo = Locale?.Pipe(CultureInfo.GetCultureInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,9 +183,10 @@ public partial class ExportRequest
|
||||
=> before?.ToDate().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
|
||||
?? "",
|
||||
"%d"
|
||||
=> DateTimeOffset
|
||||
.Now
|
||||
.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture),
|
||||
=> DateTimeOffset.Now.ToString(
|
||||
"yyyy-MM-dd",
|
||||
CultureInfo.InvariantCulture
|
||||
),
|
||||
|
||||
"%%" => "%",
|
||||
_ => m.Value
|
||||
|
||||
@@ -3,28 +3,17 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering;
|
||||
|
||||
internal class BinaryExpressionMessageFilter : MessageFilter
|
||||
internal class BinaryExpressionMessageFilter(
|
||||
MessageFilter first,
|
||||
MessageFilter second,
|
||||
BinaryExpressionKind kind
|
||||
) : MessageFilter
|
||||
{
|
||||
private readonly MessageFilter _first;
|
||||
private readonly MessageFilter _second;
|
||||
private readonly BinaryExpressionKind _kind;
|
||||
|
||||
public BinaryExpressionMessageFilter(
|
||||
MessageFilter first,
|
||||
MessageFilter second,
|
||||
BinaryExpressionKind kind
|
||||
)
|
||||
{
|
||||
_first = first;
|
||||
_second = second;
|
||||
_kind = kind;
|
||||
}
|
||||
|
||||
public override bool IsMatch(Message message) =>
|
||||
_kind switch
|
||||
kind switch
|
||||
{
|
||||
BinaryExpressionKind.Or => _first.IsMatch(message) || _second.IsMatch(message),
|
||||
BinaryExpressionKind.And => _first.IsMatch(message) && _second.IsMatch(message),
|
||||
_ => throw new InvalidOperationException($"Unknown binary expression kind '{_kind}'.")
|
||||
BinaryExpressionKind.Or => first.IsMatch(message) || second.IsMatch(message),
|
||||
BinaryExpressionKind.And => first.IsMatch(message) && second.IsMatch(message),
|
||||
_ => throw new InvalidOperationException($"Unknown binary expression kind '{kind}'.")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,12 +4,8 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering;
|
||||
|
||||
internal class ContainsMessageFilter : MessageFilter
|
||||
internal class ContainsMessageFilter(string text) : MessageFilter
|
||||
{
|
||||
private readonly string _text;
|
||||
|
||||
public ContainsMessageFilter(string text) => _text = text;
|
||||
|
||||
// Match content within word boundaries, between spaces, or as the whole input.
|
||||
// For example, "max" shouldn't match on content "our maximum effort",
|
||||
// but should match on content "our max effort".
|
||||
@@ -20,20 +16,18 @@ internal class ContainsMessageFilter : MessageFilter
|
||||
!string.IsNullOrWhiteSpace(content)
|
||||
&& Regex.IsMatch(
|
||||
content,
|
||||
@"(?:\b|\s|^)" + Regex.Escape(_text) + @"(?:\b|\s|$)",
|
||||
@"(?:\b|\s|^)" + Regex.Escape(text) + @"(?:\b|\s|$)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant
|
||||
);
|
||||
|
||||
public override bool IsMatch(Message message) =>
|
||||
IsMatch(message.Content)
|
||||
|| message
|
||||
.Embeds
|
||||
.Any(
|
||||
e =>
|
||||
IsMatch(e.Title)
|
||||
|| IsMatch(e.Author?.Name)
|
||||
|| IsMatch(e.Description)
|
||||
|| IsMatch(e.Footer?.Text)
|
||||
|| e.Fields.Any(f => IsMatch(f.Name) || IsMatch(f.Value))
|
||||
);
|
||||
|| message.Embeds.Any(
|
||||
e =>
|
||||
IsMatch(e.Title)
|
||||
|| IsMatch(e.Author?.Name)
|
||||
|| IsMatch(e.Description)
|
||||
|| IsMatch(e.Footer?.Text)
|
||||
|| e.Fields.Any(f => IsMatch(f.Name) || IsMatch(f.Value))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,11 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering;
|
||||
|
||||
internal class FromMessageFilter : MessageFilter
|
||||
internal class FromMessageFilter(string value) : MessageFilter
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
public FromMessageFilter(string value) => _value = value;
|
||||
|
||||
public override bool IsMatch(Message message) =>
|
||||
string.Equals(_value, message.Author.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(_value, message.Author.DisplayName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(_value, message.Author.FullName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(_value, message.Author.Id.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
string.Equals(value, message.Author.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, message.Author.DisplayName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, message.Author.FullName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, message.Author.Id.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using DiscordChatExporter.Core.Discord.Data;
|
||||
using DiscordChatExporter.Core.Markdown.Parsing;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering;
|
||||
|
||||
internal class HasMessageFilter : MessageFilter
|
||||
internal class HasMessageFilter(MessageContentMatchKind kind) : MessageFilter
|
||||
{
|
||||
private readonly MessageContentMatchKind _kind;
|
||||
|
||||
public HasMessageFilter(MessageContentMatchKind kind) => _kind = kind;
|
||||
|
||||
public override bool IsMatch(Message message) =>
|
||||
_kind switch
|
||||
kind switch
|
||||
{
|
||||
MessageContentMatchKind.Link
|
||||
=> Regex.IsMatch(message.Content, "https?://\\S*[^\\.,:;\"\'\\s]"),
|
||||
MessageContentMatchKind.Link => MarkdownParser.ExtractLinks(message.Content).Any(),
|
||||
MessageContentMatchKind.Embed => message.Embeds.Any(),
|
||||
MessageContentMatchKind.File => message.Attachments.Any(),
|
||||
MessageContentMatchKind.Video => message.Attachments.Any(file => file.IsVideo),
|
||||
MessageContentMatchKind.Image => message.Attachments.Any(file => file.IsImage),
|
||||
MessageContentMatchKind.Sound => message.Attachments.Any(file => file.IsAudio),
|
||||
MessageContentMatchKind.Pin => message.IsPinned,
|
||||
MessageContentMatchKind.Invite
|
||||
=> MarkdownParser
|
||||
.ExtractLinks(message.Content)
|
||||
.Select(l => l.Url)
|
||||
.Select(Invite.TryGetCodeFromUrl)
|
||||
.Any(c => !string.IsNullOrWhiteSpace(c)),
|
||||
_
|
||||
=> throw new InvalidOperationException(
|
||||
$"Unknown message content match kind '{_kind}'."
|
||||
$"Unknown message content match kind '{kind}'."
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,20 +4,14 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering;
|
||||
|
||||
internal class MentionsMessageFilter : MessageFilter
|
||||
internal class MentionsMessageFilter(string value) : MessageFilter
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
public MentionsMessageFilter(string value) => _value = value;
|
||||
|
||||
public override bool IsMatch(Message message) =>
|
||||
message
|
||||
.MentionedUsers
|
||||
.Any(
|
||||
user =>
|
||||
string.Equals(_value, user.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(_value, user.DisplayName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(_value, user.FullName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(_value, user.Id.ToString(), StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
message.MentionedUsers.Any(
|
||||
user =>
|
||||
string.Equals(value, user.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, user.DisplayName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, user.FullName, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, user.Id.ToString(), StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,5 +8,6 @@ internal enum MessageContentMatchKind
|
||||
Video,
|
||||
Image,
|
||||
Sound,
|
||||
Pin
|
||||
Pin,
|
||||
Invite
|
||||
}
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering;
|
||||
|
||||
internal class NegatedMessageFilter : MessageFilter
|
||||
internal class NegatedMessageFilter(MessageFilter filter) : MessageFilter
|
||||
{
|
||||
private readonly MessageFilter _filter;
|
||||
|
||||
public NegatedMessageFilter(MessageFilter filter) => _filter = filter;
|
||||
|
||||
public override bool IsMatch(Message message) => !_filter.IsMatch(message);
|
||||
public override bool IsMatch(Message message) => !filter.IsMatch(message);
|
||||
}
|
||||
|
||||
@@ -61,18 +61,28 @@ internal static class FilterGrammar
|
||||
.IgnoreThen(
|
||||
Parse.OneOf(
|
||||
Span.EqualToIgnoreCase("link")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Link)),
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Link))
|
||||
.Try(),
|
||||
Span.EqualToIgnoreCase("embed")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Embed)),
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Embed))
|
||||
.Try(),
|
||||
Span.EqualToIgnoreCase("file")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.File)),
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.File))
|
||||
.Try(),
|
||||
Span.EqualToIgnoreCase("video")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Video)),
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Video))
|
||||
.Try(),
|
||||
Span.EqualToIgnoreCase("image")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Image)),
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Image))
|
||||
.Try(),
|
||||
Span.EqualToIgnoreCase("sound")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Sound)),
|
||||
Span.EqualToIgnoreCase("pin").IgnoreThen(Parse.Return(MessageContentMatchKind.Pin))
|
||||
Span.EqualToIgnoreCase("pin")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Pin))
|
||||
.Try(),
|
||||
Span.EqualToIgnoreCase("invite")
|
||||
.IgnoreThen(Parse.Return(MessageContentMatchKind.Invite))
|
||||
.Try()
|
||||
)
|
||||
)
|
||||
.Select(k => (MessageFilter)new HasMessageFilter(k))
|
||||
|
||||
@@ -4,23 +4,13 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering;
|
||||
|
||||
internal class ReactionMessageFilter : MessageFilter
|
||||
internal class ReactionMessageFilter(string value) : MessageFilter
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
public ReactionMessageFilter(string value) => _value = value;
|
||||
|
||||
public override bool IsMatch(Message message) =>
|
||||
message
|
||||
.Reactions
|
||||
.Any(
|
||||
r =>
|
||||
string.Equals(
|
||||
_value,
|
||||
r.Emoji.Id?.ToString(),
|
||||
StringComparison.OrdinalIgnoreCase
|
||||
)
|
||||
|| string.Equals(_value, r.Emoji.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(_value, r.Emoji.Code, StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
message.Reactions.Any(
|
||||
r =>
|
||||
string.Equals(value, r.Emoji.Id?.ToString(), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, r.Emoji.Name, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, r.Emoji.Code, StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,25 +12,18 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
internal partial class HtmlMarkdownVisitor(
|
||||
ExportContext context,
|
||||
StringBuilder buffer,
|
||||
bool isJumbo
|
||||
) : MarkdownVisitor
|
||||
{
|
||||
private readonly ExportContext _context;
|
||||
private readonly StringBuilder _buffer;
|
||||
private readonly bool _isJumbo;
|
||||
|
||||
public HtmlMarkdownVisitor(ExportContext context, StringBuilder buffer, bool isJumbo)
|
||||
{
|
||||
_context = context;
|
||||
_buffer = buffer;
|
||||
_isJumbo = isJumbo;
|
||||
}
|
||||
|
||||
protected override ValueTask VisitTextAsync(
|
||||
TextNode text,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(HtmlEncode(text.Text));
|
||||
buffer.Append(HtmlEncode(text.Text));
|
||||
return default;
|
||||
}
|
||||
|
||||
@@ -95,9 +88,9 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
)
|
||||
};
|
||||
|
||||
_buffer.Append(openingTag);
|
||||
buffer.Append(openingTag);
|
||||
await VisitAsync(formatting.Children, cancellationToken);
|
||||
_buffer.Append(closingTag);
|
||||
buffer.Append(closingTag);
|
||||
}
|
||||
|
||||
protected override async ValueTask VisitHeadingAsync(
|
||||
@@ -105,14 +98,14 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"<h{heading.Level}>"
|
||||
);
|
||||
|
||||
await VisitAsync(heading.Children, cancellationToken);
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"</h{heading.Level}>"
|
||||
);
|
||||
@@ -123,14 +116,14 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
"<ul>"
|
||||
);
|
||||
|
||||
await VisitAsync(list.Items, cancellationToken);
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
"</ul>"
|
||||
);
|
||||
@@ -141,14 +134,14 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
"<li>"
|
||||
);
|
||||
|
||||
await VisitAsync(listItem.Children, cancellationToken);
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
"</li>"
|
||||
);
|
||||
@@ -159,7 +152,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"""
|
||||
<code class="chatlog__markdown-pre chatlog__markdown-pre--inline">{HtmlEncode(inlineCodeBlock.Code)}</code>
|
||||
@@ -178,7 +171,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
? $"language-{multiLineCodeBlock.Language}"
|
||||
: "nohighlight";
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"""
|
||||
<code class="chatlog__markdown-pre chatlog__markdown-pre--multiline {highlightClass}">{HtmlEncode(multiLineCodeBlock.Code)}</code>
|
||||
@@ -199,7 +192,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
.Groups[1]
|
||||
.Value;
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
!string.IsNullOrWhiteSpace(linkedMessageId)
|
||||
// lang=html
|
||||
? $"""<a href="{HtmlEncode(link.Url)}" onclick="scrollToMessage(event, '{linkedMessageId}')">"""
|
||||
@@ -209,7 +202,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
|
||||
await VisitAsync(link.Children, cancellationToken);
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
"</a>"
|
||||
);
|
||||
@@ -221,9 +214,9 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
)
|
||||
{
|
||||
var emojiImageUrl = Emoji.GetImageUrl(emoji.Id, emoji.Name, emoji.IsAnimated);
|
||||
var jumboClass = _isJumbo ? "chatlog__emoji--large" : "";
|
||||
var jumboClass = isJumbo ? "chatlog__emoji--large" : "";
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"""
|
||||
<img
|
||||
@@ -231,7 +224,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
class="chatlog__emoji {jumboClass}"
|
||||
alt="{emoji.Name}"
|
||||
title="{emoji.Code}"
|
||||
src="{await _context.ResolveAssetUrlAsync(emojiImageUrl, cancellationToken)}">
|
||||
src="{await context.ResolveAssetUrlAsync(emojiImageUrl, cancellationToken)}">
|
||||
"""
|
||||
);
|
||||
}
|
||||
@@ -243,7 +236,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
{
|
||||
if (mention.Kind == MentionKind.Everyone)
|
||||
{
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
"""
|
||||
<span class="chatlog__markdown-mention">@everyone</span>
|
||||
@@ -252,7 +245,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
}
|
||||
else if (mention.Kind == MentionKind.Here)
|
||||
{
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
"""
|
||||
<span class="chatlog__markdown-mention">@here</span>
|
||||
@@ -265,13 +258,13 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
// which means they need to be populated on demand.
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/304
|
||||
if (mention.TargetId is not null)
|
||||
await _context.PopulateMemberAsync(mention.TargetId.Value, cancellationToken);
|
||||
await context.PopulateMemberAsync(mention.TargetId.Value, cancellationToken);
|
||||
|
||||
var member = mention.TargetId?.Pipe(_context.TryGetMember);
|
||||
var member = mention.TargetId?.Pipe(context.TryGetMember);
|
||||
var fullName = member?.User.FullName ?? "Unknown";
|
||||
var displayName = member?.DisplayName ?? member?.User.DisplayName ?? "Unknown";
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"""
|
||||
<span class="chatlog__markdown-mention" title="{HtmlEncode(fullName)}">@{HtmlEncode(displayName)}</span>
|
||||
@@ -280,11 +273,11 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
}
|
||||
else if (mention.Kind == MentionKind.Channel)
|
||||
{
|
||||
var channel = mention.TargetId?.Pipe(_context.TryGetChannel);
|
||||
var channel = mention.TargetId?.Pipe(context.TryGetChannel);
|
||||
var symbol = channel?.IsVoice == true ? "🔊" : "#";
|
||||
var name = channel?.Name ?? "deleted-channel";
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"""
|
||||
<span class="chatlog__markdown-mention">{symbol}{HtmlEncode(name)}</span>
|
||||
@@ -293,7 +286,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
}
|
||||
else if (mention.Kind == MentionKind.Role)
|
||||
{
|
||||
var role = mention.TargetId?.Pipe(_context.TryGetRole);
|
||||
var role = mention.TargetId?.Pipe(context.TryGetRole);
|
||||
var name = role?.Name ?? "deleted-role";
|
||||
var color = role?.Color;
|
||||
|
||||
@@ -303,7 +296,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
"""
|
||||
: null;
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"""
|
||||
<span class="chatlog__markdown-mention" style="{style}">@{HtmlEncode(name)}</span>
|
||||
@@ -318,14 +311,14 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||
)
|
||||
{
|
||||
var formatted = timestamp.Instant is not null
|
||||
? _context.FormatDate(timestamp.Instant.Value, timestamp.Format ?? "g")
|
||||
? context.FormatDate(timestamp.Instant.Value, timestamp.Format ?? "g")
|
||||
: "Invalid date";
|
||||
|
||||
var formattedLong = timestamp.Instant is not null
|
||||
? _context.FormatDate(timestamp.Instant.Value, "f")
|
||||
? context.FormatDate(timestamp.Instant.Value, "f")
|
||||
: "";
|
||||
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
// lang=html
|
||||
$"""
|
||||
<span class="chatlog__markdown-timestamp" title="{HtmlEncode(formattedLong)}">{HtmlEncode(formatted)}</span>
|
||||
|
||||
@@ -9,21 +9,14 @@ using WebMarkupMin.Core;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal class HtmlMessageWriter : MessageWriter
|
||||
internal class HtmlMessageWriter(Stream stream, ExportContext context, string themeName)
|
||||
: MessageWriter(stream, context)
|
||||
{
|
||||
private readonly TextWriter _writer;
|
||||
private readonly string _themeName;
|
||||
private readonly TextWriter _writer = new StreamWriter(stream);
|
||||
|
||||
private readonly HtmlMinifier _minifier = new();
|
||||
private readonly List<Message> _messageGroup = new();
|
||||
|
||||
public HtmlMessageWriter(Stream stream, ExportContext context, string themeName)
|
||||
: base(stream, context)
|
||||
{
|
||||
_writer = new StreamWriter(stream);
|
||||
_themeName = themeName;
|
||||
}
|
||||
|
||||
private bool CanJoinGroup(Message message)
|
||||
{
|
||||
// If the group is empty, any message can join it
|
||||
@@ -80,11 +73,9 @@ internal class HtmlMessageWriter : MessageWriter
|
||||
{
|
||||
await _writer.WriteLineAsync(
|
||||
Minify(
|
||||
await new PreambleTemplate
|
||||
{
|
||||
Context = Context,
|
||||
ThemeName = _themeName
|
||||
}.RenderAsync(cancellationToken)
|
||||
await new PreambleTemplate { Context = Context, ThemeName = themeName }.RenderAsync(
|
||||
cancellationToken
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,11 @@ using JsonExtensions.Writing;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal class JsonMessageWriter : MessageWriter
|
||||
internal class JsonMessageWriter(Stream stream, ExportContext context)
|
||||
: MessageWriter(stream, context)
|
||||
{
|
||||
private readonly Utf8JsonWriter _writer;
|
||||
|
||||
public JsonMessageWriter(Stream stream, ExportContext context)
|
||||
: base(stream, context)
|
||||
{
|
||||
_writer = new Utf8JsonWriter(
|
||||
private readonly Utf8JsonWriter _writer =
|
||||
new(
|
||||
stream,
|
||||
new JsonWriterOptions
|
||||
{
|
||||
@@ -31,7 +28,6 @@ internal class JsonMessageWriter : MessageWriter
|
||||
SkipValidation = true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private async ValueTask<string> FormatMarkdownAsync(
|
||||
string markdown,
|
||||
@@ -450,14 +446,12 @@ internal class JsonMessageWriter : MessageWriter
|
||||
|
||||
_writer.WriteStartArray("users");
|
||||
await foreach (
|
||||
var user in Context
|
||||
.Discord
|
||||
.GetMessageReactionsAsync(
|
||||
Context.Request.Channel.Id,
|
||||
message.Id,
|
||||
reaction.Emoji,
|
||||
cancellationToken
|
||||
)
|
||||
var user in Context.Discord.GetMessageReactionsAsync(
|
||||
Context.Request.Channel.Id,
|
||||
message.Id,
|
||||
reaction.Emoji,
|
||||
cancellationToken
|
||||
)
|
||||
)
|
||||
{
|
||||
_writer.WriteStartObject();
|
||||
|
||||
@@ -6,20 +6,13 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal partial class MessageExporter : IAsyncDisposable
|
||||
internal partial class MessageExporter(ExportContext context) : IAsyncDisposable
|
||||
{
|
||||
private readonly ExportContext _context;
|
||||
|
||||
private int _partitionIndex;
|
||||
private MessageWriter? _writer;
|
||||
|
||||
public long MessagesExported { get; private set; }
|
||||
|
||||
public MessageExporter(ExportContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
private async ValueTask ResetWriterAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_writer is not null)
|
||||
@@ -44,10 +37,10 @@ internal partial class MessageExporter : IAsyncDisposable
|
||||
// Ensure that the partition limit has not been reached
|
||||
if (
|
||||
_writer is not null
|
||||
&& _context
|
||||
.Request
|
||||
.PartitionLimit
|
||||
.IsReached(_writer.MessagesWritten, _writer.BytesWritten)
|
||||
&& context.Request.PartitionLimit.IsReached(
|
||||
_writer.MessagesWritten,
|
||||
_writer.BytesWritten
|
||||
)
|
||||
)
|
||||
{
|
||||
await ResetWriterAsync(cancellationToken);
|
||||
@@ -58,10 +51,10 @@ internal partial class MessageExporter : IAsyncDisposable
|
||||
if (_writer is not null)
|
||||
return _writer;
|
||||
|
||||
Directory.CreateDirectory(_context.Request.OutputDirPath);
|
||||
var filePath = GetPartitionFilePath(_context.Request.OutputFilePath, _partitionIndex);
|
||||
Directory.CreateDirectory(context.Request.OutputDirPath);
|
||||
var filePath = GetPartitionFilePath(context.Request.OutputFilePath, _partitionIndex);
|
||||
|
||||
var writer = CreateMessageWriter(filePath, _context.Request.Format, _context);
|
||||
var writer = CreateMessageWriter(filePath, context.Request.Format, context);
|
||||
await writer.WritePreambleAsync(cancellationToken);
|
||||
|
||||
return _writer = writer;
|
||||
|
||||
@@ -448,7 +448,10 @@
|
||||
</div>
|
||||
}
|
||||
// Generic video embed
|
||||
else if (embed.Kind == EmbedKind.Video && !string.IsNullOrWhiteSpace(embed.Url))
|
||||
else if (embed.Kind == EmbedKind.Video
|
||||
&& !string.IsNullOrWhiteSpace(embed.Url)
|
||||
// Twitch clips cannot be embedded in local HTML files
|
||||
&& embed.TryGetTwitchClip() is null)
|
||||
{
|
||||
var embedVideoUrl =
|
||||
embed.Video?.ProxyUrl ?? embed.Video?.Url ??
|
||||
@@ -634,7 +637,7 @@
|
||||
@foreach (var sticker in message.Stickers)
|
||||
{
|
||||
<div class="chatlog__sticker" title="@sticker.Name">
|
||||
@if (sticker.Format is StickerFormat.Png or StickerFormat.Apng)
|
||||
@if (sticker.IsImage)
|
||||
{
|
||||
<img class="chatlog__sticker--media" src="@await ResolveAssetUrlAsync(sticker.SourceUrl)" alt="Sticker">
|
||||
}
|
||||
|
||||
@@ -6,22 +6,16 @@ using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal abstract class MessageWriter : IAsyncDisposable
|
||||
internal abstract class MessageWriter(Stream stream, ExportContext context) : IAsyncDisposable
|
||||
{
|
||||
protected Stream Stream { get; }
|
||||
protected Stream Stream { get; } = stream;
|
||||
|
||||
protected ExportContext Context { get; }
|
||||
protected ExportContext Context { get; } = context;
|
||||
|
||||
public long MessagesWritten { get; private set; }
|
||||
|
||||
public long BytesWritten => Stream.Length;
|
||||
|
||||
protected MessageWriter(Stream stream, ExportContext context)
|
||||
{
|
||||
Stream = stream;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public virtual ValueTask WritePreambleAsync(CancellationToken cancellationToken = default) =>
|
||||
default;
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
namespace DiscordChatExporter.Core.Exporting.Partitioning;
|
||||
|
||||
internal class FileSizePartitionLimit : PartitionLimit
|
||||
internal class FileSizePartitionLimit(long limit) : PartitionLimit
|
||||
{
|
||||
private readonly long _limit;
|
||||
|
||||
public FileSizePartitionLimit(long limit) => _limit = limit;
|
||||
|
||||
public override bool IsReached(long messagesWritten, long bytesWritten) =>
|
||||
bytesWritten >= _limit;
|
||||
bytesWritten >= limit;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
namespace DiscordChatExporter.Core.Exporting.Partitioning;
|
||||
|
||||
internal class MessageCountPartitionLimit : PartitionLimit
|
||||
internal class MessageCountPartitionLimit(long limit) : PartitionLimit
|
||||
{
|
||||
private readonly long _limit;
|
||||
|
||||
public MessageCountPartitionLimit(long limit) => _limit = limit;
|
||||
|
||||
public override bool IsReached(long messagesWritten, long bytesWritten) =>
|
||||
messagesWritten >= _limit;
|
||||
messagesWritten >= limit;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,21 @@
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DiscordChatExporter.Core.Discord.Data;
|
||||
using DiscordChatExporter.Core.Markdown;
|
||||
using DiscordChatExporter.Core.Markdown.Parsing;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal partial class PlainTextMarkdownVisitor : MarkdownVisitor
|
||||
internal partial class PlainTextMarkdownVisitor(ExportContext context, StringBuilder buffer)
|
||||
: MarkdownVisitor
|
||||
{
|
||||
private readonly ExportContext _context;
|
||||
private readonly StringBuilder _buffer;
|
||||
|
||||
public PlainTextMarkdownVisitor(ExportContext context, StringBuilder buffer)
|
||||
{
|
||||
_context = context;
|
||||
_buffer = buffer;
|
||||
}
|
||||
|
||||
protected override ValueTask VisitTextAsync(
|
||||
TextNode text,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(text.Text);
|
||||
buffer.Append(text.Text);
|
||||
return default;
|
||||
}
|
||||
|
||||
@@ -33,7 +24,7 @@ internal partial class PlainTextMarkdownVisitor : MarkdownVisitor
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(emoji.IsCustomEmoji ? $":{emoji.Name}:" : emoji.Name);
|
||||
buffer.Append(emoji.IsCustomEmoji ? $":{emoji.Name}:" : emoji.Name);
|
||||
|
||||
return default;
|
||||
}
|
||||
@@ -45,11 +36,11 @@ internal partial class PlainTextMarkdownVisitor : MarkdownVisitor
|
||||
{
|
||||
if (mention.Kind == MentionKind.Everyone)
|
||||
{
|
||||
_buffer.Append("@everyone");
|
||||
buffer.Append("@everyone");
|
||||
}
|
||||
else if (mention.Kind == MentionKind.Here)
|
||||
{
|
||||
_buffer.Append("@here");
|
||||
buffer.Append("@here");
|
||||
}
|
||||
else if (mention.Kind == MentionKind.User)
|
||||
{
|
||||
@@ -57,30 +48,30 @@ internal partial class PlainTextMarkdownVisitor : MarkdownVisitor
|
||||
// which means they need to be populated on demand.
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/304
|
||||
if (mention.TargetId is not null)
|
||||
await _context.PopulateMemberAsync(mention.TargetId.Value, cancellationToken);
|
||||
await context.PopulateMemberAsync(mention.TargetId.Value, cancellationToken);
|
||||
|
||||
var member = mention.TargetId?.Pipe(_context.TryGetMember);
|
||||
var member = mention.TargetId?.Pipe(context.TryGetMember);
|
||||
var displayName = member?.DisplayName ?? member?.User.DisplayName ?? "Unknown";
|
||||
|
||||
_buffer.Append($"@{displayName}");
|
||||
buffer.Append($"@{displayName}");
|
||||
}
|
||||
else if (mention.Kind == MentionKind.Channel)
|
||||
{
|
||||
var channel = mention.TargetId?.Pipe(_context.TryGetChannel);
|
||||
var channel = mention.TargetId?.Pipe(context.TryGetChannel);
|
||||
var name = channel?.Name ?? "deleted-channel";
|
||||
|
||||
_buffer.Append($"#{name}");
|
||||
buffer.Append($"#{name}");
|
||||
|
||||
// Voice channel marker
|
||||
if (channel?.IsVoice == true)
|
||||
_buffer.Append(" [voice]");
|
||||
buffer.Append(" [voice]");
|
||||
}
|
||||
else if (mention.Kind == MentionKind.Role)
|
||||
{
|
||||
var role = mention.TargetId?.Pipe(_context.TryGetRole);
|
||||
var role = mention.TargetId?.Pipe(context.TryGetRole);
|
||||
var name = role?.Name ?? "deleted-role";
|
||||
|
||||
_buffer.Append($"@{name}");
|
||||
buffer.Append($"@{name}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,9 +80,9 @@ internal partial class PlainTextMarkdownVisitor : MarkdownVisitor
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
_buffer.Append(
|
||||
buffer.Append(
|
||||
timestamp.Instant is not null
|
||||
? _context.FormatDate(timestamp.Instant.Value, timestamp.Format ?? "g")
|
||||
? context.FormatDate(timestamp.Instant.Value, timestamp.Format ?? "g")
|
||||
: "Invalid date"
|
||||
);
|
||||
|
||||
|
||||
@@ -8,15 +8,10 @@ using DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting;
|
||||
|
||||
internal class PlainTextMessageWriter : MessageWriter
|
||||
internal class PlainTextMessageWriter(Stream stream, ExportContext context)
|
||||
: MessageWriter(stream, context)
|
||||
{
|
||||
private readonly TextWriter _writer;
|
||||
|
||||
public PlainTextMessageWriter(Stream stream, ExportContext context)
|
||||
: base(stream, context)
|
||||
{
|
||||
_writer = new StreamWriter(stream);
|
||||
}
|
||||
private readonly TextWriter _writer = new StreamWriter(stream);
|
||||
|
||||
private async ValueTask<string> FormatMarkdownAsync(
|
||||
string markdown,
|
||||
|
||||
@@ -702,6 +702,10 @@
|
||||
.chatlog__embed-spotify {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.chatlog__embed-twitch {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.chatlog__embed-youtube-container {
|
||||
margin-top: 0.6rem;
|
||||
|
||||
@@ -8,5 +8,5 @@ internal record LinkNode(string Url, IReadOnlyList<MarkdownNode> Children)
|
||||
IContainerNode
|
||||
{
|
||||
public LinkNode(string url)
|
||||
: this(url, new[] { new TextNode(url) }) { }
|
||||
: this(url, [new TextNode(url)]) { }
|
||||
}
|
||||
|
||||
@@ -2,15 +2,8 @@
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown.Parsing;
|
||||
|
||||
internal class AggregateMatcher<T> : IMatcher<T>
|
||||
internal class AggregateMatcher<T>(IReadOnlyList<IMatcher<T>> matchers) : IMatcher<T>
|
||||
{
|
||||
private readonly IReadOnlyList<IMatcher<T>> _matchers;
|
||||
|
||||
public AggregateMatcher(IReadOnlyList<IMatcher<T>> matchers)
|
||||
{
|
||||
_matchers = matchers;
|
||||
}
|
||||
|
||||
public AggregateMatcher(params IMatcher<T>[] matchers)
|
||||
: this((IReadOnlyList<IMatcher<T>>)matchers) { }
|
||||
|
||||
@@ -19,7 +12,7 @@ internal class AggregateMatcher<T> : IMatcher<T>
|
||||
ParsedMatch<T>? earliestMatch = null;
|
||||
|
||||
// Try to match the input with each matcher and get the match with the lowest start index
|
||||
foreach (var matcher in _matchers)
|
||||
foreach (var matcher in matchers)
|
||||
{
|
||||
// Try to match
|
||||
var match = matcher.TryMatch(segment);
|
||||
|
||||
@@ -340,13 +340,27 @@ internal static partial class MarkdownParser
|
||||
)
|
||||
);
|
||||
|
||||
// https://discord.com/developers/docs/reference#message-formatting-timestamp-styles
|
||||
var format = m.Groups[2].Value.NullIfWhiteSpace() switch
|
||||
{
|
||||
// Ignore the 'relative' format because it doesn't make sense in a static export
|
||||
// Known formats
|
||||
"t" => "t",
|
||||
"T" => "T",
|
||||
"d" => "d",
|
||||
"D" => "D",
|
||||
"f" => "f",
|
||||
"F" => "F",
|
||||
// Relative format: ignore because it doesn't make sense in a static export
|
||||
"r" => null,
|
||||
"R" => null,
|
||||
// Discord's date formats are (mostly) compatible with .NET's date formats
|
||||
var f => f
|
||||
// Unspecified format: will be mapped to the default format
|
||||
null => null,
|
||||
// Unknown format: throw an exception to consider this timestamp invalid
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1156
|
||||
var f
|
||||
=> throw new InvalidOperationException(
|
||||
$"Unknown timestamp format '{f}'."
|
||||
)
|
||||
};
|
||||
|
||||
return new TimestampNode(instant, format);
|
||||
@@ -354,7 +368,12 @@ internal static partial class MarkdownParser
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/681
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/766
|
||||
catch (Exception ex)
|
||||
when (ex is FormatException or ArgumentOutOfRangeException or OverflowException)
|
||||
when (ex
|
||||
is FormatException
|
||||
or ArgumentOutOfRangeException
|
||||
or OverflowException
|
||||
or InvalidOperationException
|
||||
)
|
||||
{
|
||||
// For invalid timestamps, Discord renders "Invalid Date" instead of ignoring the markdown
|
||||
return TimestampNode.Invalid;
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
namespace DiscordChatExporter.Core.Markdown.Parsing;
|
||||
|
||||
internal class ParsedMatch<T>
|
||||
internal class ParsedMatch<T>(StringSegment segment, T value)
|
||||
{
|
||||
public StringSegment Segment { get; }
|
||||
public StringSegment Segment { get; } = segment;
|
||||
|
||||
public T Value { get; }
|
||||
|
||||
public ParsedMatch(StringSegment segment, T value)
|
||||
{
|
||||
Segment = segment;
|
||||
Value = value;
|
||||
}
|
||||
public T Value { get; } = value;
|
||||
}
|
||||
|
||||
@@ -3,20 +3,11 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown.Parsing;
|
||||
|
||||
internal class RegexMatcher<T> : IMatcher<T>
|
||||
internal class RegexMatcher<T>(Regex regex, Func<StringSegment, Match, T?> transform) : IMatcher<T>
|
||||
{
|
||||
private readonly Regex _regex;
|
||||
private readonly Func<StringSegment, Match, T?> _transform;
|
||||
|
||||
public RegexMatcher(Regex regex, Func<StringSegment, Match, T?> transform)
|
||||
{
|
||||
_regex = regex;
|
||||
_transform = transform;
|
||||
}
|
||||
|
||||
public ParsedMatch<T>? TryMatch(StringSegment segment)
|
||||
{
|
||||
var match = _regex.Match(segment.Source, segment.StartIndex, segment.Length);
|
||||
var match = regex.Match(segment.Source, segment.StartIndex, segment.Length);
|
||||
if (!match.Success)
|
||||
return null;
|
||||
|
||||
@@ -25,11 +16,11 @@ internal class RegexMatcher<T> : IMatcher<T>
|
||||
// Which is super weird because regex.Match(string, int) takes the whole input in context.
|
||||
// So in order to properly account for ^/$ regex tokens, we need to make sure that
|
||||
// the expression also matches on the bigger part of the input.
|
||||
if (!_regex.IsMatch(segment.Source[..segment.EndIndex], segment.StartIndex))
|
||||
if (!regex.IsMatch(segment.Source[..segment.EndIndex], segment.StartIndex))
|
||||
return null;
|
||||
|
||||
var segmentMatch = segment.Relocate(match);
|
||||
var value = _transform(segmentMatch, match);
|
||||
var value = transform(segmentMatch, match);
|
||||
|
||||
return value is not null ? new ParsedMatch<T>(segmentMatch, value) : null;
|
||||
}
|
||||
|
||||
@@ -2,37 +2,24 @@
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown.Parsing;
|
||||
|
||||
internal class StringMatcher<T> : IMatcher<T>
|
||||
internal class StringMatcher<T>(
|
||||
string needle,
|
||||
StringComparison comparison,
|
||||
Func<StringSegment, T?> transform
|
||||
) : IMatcher<T>
|
||||
{
|
||||
private readonly string _needle;
|
||||
private readonly StringComparison _comparison;
|
||||
private readonly Func<StringSegment, T?> _transform;
|
||||
|
||||
public StringMatcher(
|
||||
string needle,
|
||||
StringComparison comparison,
|
||||
Func<StringSegment, T?> transform
|
||||
)
|
||||
{
|
||||
_needle = needle;
|
||||
_comparison = comparison;
|
||||
_transform = transform;
|
||||
}
|
||||
|
||||
public StringMatcher(string needle, Func<StringSegment, T> transform)
|
||||
: this(needle, StringComparison.Ordinal, transform) { }
|
||||
|
||||
public ParsedMatch<T>? TryMatch(StringSegment segment)
|
||||
{
|
||||
var index = segment
|
||||
.Source
|
||||
.IndexOf(_needle, segment.StartIndex, segment.Length, _comparison);
|
||||
var index = segment.Source.IndexOf(needle, segment.StartIndex, segment.Length, comparison);
|
||||
|
||||
if (index < 0)
|
||||
return null;
|
||||
|
||||
var segmentMatch = segment.Relocate(index, _needle.Length);
|
||||
var value = _transform(segmentMatch);
|
||||
var segmentMatch = segment.Relocate(index, needle.Length);
|
||||
var value = transform(segmentMatch);
|
||||
|
||||
return value is not null ? new ParsedMatch<T>(segmentMatch, value) : null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace DiscordChatExporter.Core.Utils;
|
||||
|
||||
public static class Docker
|
||||
{
|
||||
public static bool IsRunningInContainer { get; } =
|
||||
Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true";
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DiscordChatExporter.Core.Utils.Extensions;
|
||||
@@ -27,16 +26,6 @@ public static class StringExtensions
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public static IEnumerable<Rune> GetRunes(this string str)
|
||||
{
|
||||
var lastIndex = 0;
|
||||
while (lastIndex < str.Length && Rune.TryGetRuneAt(str, lastIndex, out var rune))
|
||||
{
|
||||
yield return rune;
|
||||
lastIndex += rune.Utf16SequenceLength;
|
||||
}
|
||||
}
|
||||
|
||||
public static T? ParseEnumOrNull<T>(this string str, bool ignoreCase = true)
|
||||
where T : struct, Enum => Enum.TryParse<T>(str, ignoreCase, out var result) ? result : null;
|
||||
|
||||
|
||||
@@ -27,7 +27,4 @@ public static class PathEx
|
||||
|
||||
return buffer.ToString();
|
||||
}
|
||||
|
||||
public static bool IsDirectoryPath(string path) =>
|
||||
path.EndsWith(Path.DirectorySeparatorChar) || path.EndsWith(Path.AltDirectorySeparatorChar);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ public partial class App
|
||||
|
||||
public static string ProjectUrl { get; } = "https://github.com/Tyrrrz/DiscordChatExporter";
|
||||
|
||||
public static string ChangelogUrl { get; } = ProjectUrl + "/blob/master/Changelog.md";
|
||||
public static string LatestReleaseUrl { get; } = ProjectUrl + "/releases/latest";
|
||||
|
||||
public static string DocumentationUrl { get; } = ProjectUrl + "/blob/master/.docs";
|
||||
public static string DocumentationUrl { get; } = ProjectUrl + "/tree/master/.docs";
|
||||
}
|
||||
|
||||
public partial class App
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
namespace DiscordChatExporter.Gui.Behaviors;
|
||||
|
||||
public class ChannelMultiSelectionListBoxBehavior : MultiSelectionListBoxBehavior<Channel> { }
|
||||
public class ChannelMultiSelectionListBoxBehavior : MultiSelectionListBoxBehavior<Channel>;
|
||||
|
||||
@@ -10,7 +10,12 @@ public class ChannelToGroupKeyConverter : IValueConverter
|
||||
{
|
||||
public static ChannelToGroupKeyConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) =>
|
||||
value switch
|
||||
{
|
||||
Channel { IsThread: true, Parent: not null } channel
|
||||
@@ -22,9 +27,9 @@ public class ChannelToGroupKeyConverter : IValueConverter
|
||||
};
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -9,15 +9,20 @@ public class DateTimeOffsetToDateTimeConverter : IValueConverter
|
||||
{
|
||||
public static DateTimeOffsetToDateTimeConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) =>
|
||||
value is DateTimeOffset dateTimeOffsetValue
|
||||
? dateTimeOffsetValue.DateTime
|
||||
: default(DateTime?);
|
||||
|
||||
public object? ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) =>
|
||||
value is DateTime dateTimeValue
|
||||
|
||||
@@ -10,13 +10,17 @@ public class ExportFormatToStringConverter : IValueConverter
|
||||
{
|
||||
public static ExportFormatToStringConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
value is ExportFormat exportFormatValue ? exportFormatValue.GetDisplayName() : default;
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is ExportFormat exportFormatValue ? exportFormatValue.GetDisplayName() : default;
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ public class InverseBoolConverter : IValueConverter
|
||||
{
|
||||
public static InverseBoolConverter Instance { get; } = new();
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
value is false;
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is false;
|
||||
}
|
||||
|
||||
@@ -9,13 +9,15 @@ public class LocaleToDisplayNameConverter : IValueConverter
|
||||
{
|
||||
public static LocaleToDisplayNameConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
value is string locale ? CultureInfo.GetCultureInfo(locale).DisplayName : null;
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
value is string locale && !string.IsNullOrWhiteSpace(locale)
|
||||
? CultureInfo.GetCultureInfo(locale).DisplayName
|
||||
: "System default";
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -10,13 +10,17 @@ public class SnowflakeToDateTimeOffsetConverter : IValueConverter
|
||||
{
|
||||
public static SnowflakeToDateTimeOffsetConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
value is Snowflake snowflake ? snowflake.ToDate() : null;
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is Snowflake snowflake ? snowflake.ToDate() : null;
|
||||
|
||||
public object ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,17 @@ public class TimeSpanToDateTimeConverter : IValueConverter
|
||||
{
|
||||
public static TimeSpanToDateTimeConverter Instance { get; } = new();
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
value is TimeSpan timeSpanValue ? DateTime.Today.Add(timeSpanValue) : default(DateTime?);
|
||||
public object? Convert(
|
||||
object? value,
|
||||
Type targetType,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is TimeSpan timeSpanValue ? DateTime.Today.Add(timeSpanValue) : default(DateTime?);
|
||||
|
||||
public object? ConvertBack(
|
||||
object value,
|
||||
object? value,
|
||||
Type targetType,
|
||||
object parameter,
|
||||
object? parameter,
|
||||
CultureInfo culture
|
||||
) => value is DateTime dateTimeValue ? dateTimeValue.TimeOfDay : default(TimeSpan?);
|
||||
}
|
||||
|
||||
@@ -14,14 +14,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Cogwheel" Version="2.0.4" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.1" PrivateAssets="all" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.7" PrivateAssets="all" />
|
||||
<PackageReference Include="Deorcify" Version="1.0.2" PrivateAssets="all" />
|
||||
<PackageReference Include="DotnetRuntimeBootstrapper" Version="2.5.1" PrivateAssets="all" />
|
||||
<PackageReference Include="DotnetRuntimeBootstrapper" Version="2.5.2" PrivateAssets="all" />
|
||||
<PackageReference Include="Gress" Version="2.1.1" />
|
||||
<PackageReference Include="MaterialDesignColors" Version="2.1.4" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="Onova" Version="2.6.10" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Stylet" Version="1.3.6" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Cogwheel;
|
||||
using DiscordChatExporter.Core.Exporting;
|
||||
@@ -8,7 +7,8 @@ using Microsoft.Win32;
|
||||
|
||||
namespace DiscordChatExporter.Gui.Services;
|
||||
|
||||
public partial class SettingsService : SettingsBase
|
||||
public partial class SettingsService()
|
||||
: SettingsBase(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.dat"))
|
||||
{
|
||||
public bool IsUkraineSupportMessageEnabled { get; set; } = true;
|
||||
|
||||
@@ -20,7 +20,7 @@ public partial class SettingsService : SettingsBase
|
||||
|
||||
public ThreadInclusionMode ThreadInclusionMode { get; set; } = ThreadInclusionMode.None;
|
||||
|
||||
public string Locale { get; set; } = CultureInfo.CurrentCulture.Name;
|
||||
public string? Locale { get; set; }
|
||||
|
||||
public bool IsUtcNormalizationEnabled { get; set; }
|
||||
|
||||
@@ -44,9 +44,6 @@ public partial class SettingsService : SettingsBase
|
||||
|
||||
public string? LastAssetsDirPath { get; set; }
|
||||
|
||||
public SettingsService()
|
||||
: base(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.dat")) { }
|
||||
|
||||
public override void Save()
|
||||
{
|
||||
// Clear the token if it's not supposed to be persisted
|
||||
@@ -67,8 +64,7 @@ public partial class SettingsService
|
||||
try
|
||||
{
|
||||
return Registry
|
||||
.CurrentUser
|
||||
.OpenSubKey(
|
||||
.CurrentUser.OpenSubKey(
|
||||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
|
||||
false
|
||||
)
|
||||
|
||||
@@ -6,27 +6,20 @@ using Onova.Services;
|
||||
|
||||
namespace DiscordChatExporter.Gui.Services;
|
||||
|
||||
public class UpdateService : IDisposable
|
||||
public class UpdateService(SettingsService settingsService) : IDisposable
|
||||
{
|
||||
private readonly IUpdateManager _updateManager = new UpdateManager(
|
||||
new GithubPackageResolver("Tyrrrz", "DiscordChatExporter", "DiscordChatExporter.zip"),
|
||||
new ZipPackageExtractor()
|
||||
);
|
||||
|
||||
private readonly SettingsService _settingsService;
|
||||
|
||||
private Version? _updateVersion;
|
||||
private bool _updatePrepared;
|
||||
private bool _updaterLaunched;
|
||||
|
||||
public UpdateService(SettingsService settingsService)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
}
|
||||
|
||||
public async ValueTask<Version?> CheckForUpdatesAsync()
|
||||
{
|
||||
if (!_settingsService.IsAutoUpdateEnabled)
|
||||
if (!settingsService.IsAutoUpdateEnabled)
|
||||
return null;
|
||||
|
||||
var check = await _updateManager.CheckForUpdatesAsync();
|
||||
@@ -35,7 +28,7 @@ public class UpdateService : IDisposable
|
||||
|
||||
public async ValueTask PrepareUpdateAsync(Version version)
|
||||
{
|
||||
if (!_settingsService.IsAutoUpdateEnabled)
|
||||
if (!settingsService.IsAutoUpdateEnabled)
|
||||
return;
|
||||
|
||||
try
|
||||
@@ -55,7 +48,7 @@ public class UpdateService : IDisposable
|
||||
|
||||
public void FinalizeUpdate(bool needRestart)
|
||||
{
|
||||
if (!_settingsService.IsAutoUpdateEnabled)
|
||||
if (!settingsService.IsAutoUpdateEnabled)
|
||||
return;
|
||||
|
||||
if (_updateVersion is null || !_updatePrepared || _updaterLaunched)
|
||||
|
||||
@@ -235,8 +235,7 @@ public class DashboardViewModel : PropertyChangedBase
|
||||
var exporter = new ChannelExporter(_discord);
|
||||
|
||||
var channelProgressPairs = dialog
|
||||
.Channels!
|
||||
.Select(c => new { Channel = c, Progress = _progressMuxer.CreateInput() })
|
||||
.Channels!.Select(c => new { Channel = c, Progress = _progressMuxer.CreateInput() })
|
||||
.ToArray();
|
||||
|
||||
var successfulExportCount = 0;
|
||||
@@ -277,9 +276,7 @@ public class DashboardViewModel : PropertyChangedBase
|
||||
}
|
||||
catch (DiscordChatExporterException ex) when (!ex.IsFatal)
|
||||
{
|
||||
_eventAggregator.Publish(
|
||||
new NotificationMessage(ex.Message.TrimEnd('.') + $" ({channel.Name})")
|
||||
);
|
||||
_eventAggregator.Publish(new NotificationMessage(ex.Message.TrimEnd('.')));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
using DiscordChatExporter.Gui.Models;
|
||||
using DiscordChatExporter.Gui.Services;
|
||||
using DiscordChatExporter.Gui.ViewModels.Framework;
|
||||
|
||||
namespace DiscordChatExporter.Gui.ViewModels.Dialogs;
|
||||
|
||||
public class SettingsViewModel : DialogScreen
|
||||
public class SettingsViewModel(SettingsService settingsService) : DialogScreen
|
||||
{
|
||||
private readonly SettingsService _settingsService;
|
||||
|
||||
public bool IsAutoUpdateEnabled
|
||||
{
|
||||
get => _settingsService.IsAutoUpdateEnabled;
|
||||
set => _settingsService.IsAutoUpdateEnabled = value;
|
||||
get => settingsService.IsAutoUpdateEnabled;
|
||||
set => settingsService.IsAutoUpdateEnabled = value;
|
||||
}
|
||||
|
||||
public bool IsDarkModeEnabled
|
||||
{
|
||||
get => _settingsService.IsDarkModeEnabled;
|
||||
set => _settingsService.IsDarkModeEnabled = value;
|
||||
get => settingsService.IsDarkModeEnabled;
|
||||
set => settingsService.IsDarkModeEnabled = value;
|
||||
}
|
||||
|
||||
public bool IsTokenPersisted
|
||||
{
|
||||
get => _settingsService.IsTokenPersisted;
|
||||
set => _settingsService.IsTokenPersisted = value;
|
||||
get => settingsService.IsTokenPersisted;
|
||||
set => settingsService.IsTokenPersisted = value;
|
||||
}
|
||||
|
||||
public IReadOnlyList<ThreadInclusionMode> AvailableThreadInclusions { get; } =
|
||||
@@ -35,14 +33,15 @@ public class SettingsViewModel : DialogScreen
|
||||
|
||||
public ThreadInclusionMode ThreadInclusionMode
|
||||
{
|
||||
get => _settingsService.ThreadInclusionMode;
|
||||
set => _settingsService.ThreadInclusionMode = value;
|
||||
get => settingsService.ThreadInclusionMode;
|
||||
set => settingsService.ThreadInclusionMode = value;
|
||||
}
|
||||
|
||||
// These items have to be non-nullable because WPF ComboBox doesn't allow a null value to be selected
|
||||
public IReadOnlyList<string> AvailableLocales { get; } = new[]
|
||||
{
|
||||
// Current locale
|
||||
CultureInfo.CurrentCulture.Name,
|
||||
// Current locale (maps to null downstream)
|
||||
"",
|
||||
// Locales supported by the Discord app
|
||||
"da-DK",
|
||||
"de-DE",
|
||||
@@ -75,23 +74,23 @@ public class SettingsViewModel : DialogScreen
|
||||
"ko-KR"
|
||||
}.Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
|
||||
// This has to be non-nullable because WPF ComboBox doesn't allow a null value to be selected
|
||||
public string Locale
|
||||
{
|
||||
get => _settingsService.Locale;
|
||||
set => _settingsService.Locale = value;
|
||||
get => settingsService.Locale ?? "";
|
||||
// Important to reduce empty strings to nulls, because empty strings don't correspond to valid cultures
|
||||
set => settingsService.Locale = value.NullIfWhiteSpace();
|
||||
}
|
||||
|
||||
public bool IsUtcNormalizationEnabled
|
||||
{
|
||||
get => _settingsService.IsUtcNormalizationEnabled;
|
||||
set => _settingsService.IsUtcNormalizationEnabled = value;
|
||||
get => settingsService.IsUtcNormalizationEnabled;
|
||||
set => settingsService.IsUtcNormalizationEnabled = value;
|
||||
}
|
||||
|
||||
public int ParallelLimit
|
||||
{
|
||||
get => _settingsService.ParallelLimit;
|
||||
set => _settingsService.ParallelLimit = Math.Clamp(value, 1, 10);
|
||||
get => settingsService.ParallelLimit;
|
||||
set => settingsService.ParallelLimit = Math.Clamp(value, 1, 10);
|
||||
}
|
||||
|
||||
public SettingsViewModel(SettingsService settingsService) => _settingsService = settingsService;
|
||||
}
|
||||
|
||||
@@ -4,24 +4,17 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Microsoft.Win32;
|
||||
using Ookii.Dialogs.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace DiscordChatExporter.Gui.ViewModels.Framework;
|
||||
|
||||
public class DialogManager : IDisposable
|
||||
public class DialogManager(IViewManager viewManager) : IDisposable
|
||||
{
|
||||
private readonly IViewManager _viewManager;
|
||||
private readonly SemaphoreSlim _dialogLock = new(1, 1);
|
||||
|
||||
public DialogManager(IViewManager viewManager)
|
||||
{
|
||||
_viewManager = viewManager;
|
||||
}
|
||||
|
||||
public async ValueTask<T?> ShowDialogAsync<T>(DialogScreen<T> dialogScreen)
|
||||
{
|
||||
var view = _viewManager.CreateAndBindViewForModelIfNecessary(dialogScreen);
|
||||
var view = viewManager.CreateAndBindViewForModelIfNecessary(dialogScreen);
|
||||
|
||||
void OnDialogOpened(object? openSender, DialogOpenedEventArgs openArgs)
|
||||
{
|
||||
@@ -68,9 +61,8 @@ public class DialogManager : IDisposable
|
||||
|
||||
public string? PromptDirectoryPath(string defaultDirPath = "")
|
||||
{
|
||||
var dialog = new VistaFolderBrowserDialog { SelectedPath = defaultDirPath };
|
||||
|
||||
return dialog.ShowDialog() == true ? dialog.SelectedPath : null;
|
||||
var dialog = new OpenFolderDialog { InitialDirectory = defaultDirPath };
|
||||
return dialog.ShowDialog() == true ? dialog.FolderName : null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user