diff --git a/README.md b/README.md index 8dc3f05..9d93a64 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@

Repository for Redbot cogs developed by the Galaxy Discord Management team. + ## ExportChannels **(WIP)**[^incomplete] +This cog allows you to easily export channels using Discord Chat Exporter. **THIS COG IS NOT INTENDED FOR EXTERNAL USE. YOU WILL LIKELY HAVE TO RUN THIS COG LOCALLY AND MODIFY CODE SHOULD YOU WISH TO USE IT.** +**Credit to Tyrrrz for the bundled version of Discord Chat Exporter within this cog. The original repository can be found [here](https://github.com/Tyrrrz/DiscordChatExporter).** + ## Galaxy Utility cog designed specifically for use on the Galaxy Discord server. diff --git a/exportchannels/__init__.py b/exportchannels/__init__.py new file mode 100644 index 0000000..405ae28 --- /dev/null +++ b/exportchannels/__init__.py @@ -0,0 +1,4 @@ +from .exportchannels import ExportChannels + +def setup(bot): + bot.add_cog(ExportChannels(bot)) \ No newline at end of file diff --git a/exportchannels/data/AdvancedStringBuilder.dll b/exportchannels/data/AdvancedStringBuilder.dll new file mode 100644 index 0000000..1e6e5a5 Binary files /dev/null and b/exportchannels/data/AdvancedStringBuilder.dll differ diff --git a/exportchannels/data/AsyncKeyedLock.dll b/exportchannels/data/AsyncKeyedLock.dll new file mode 100644 index 0000000..37ea210 Binary files /dev/null and b/exportchannels/data/AsyncKeyedLock.dll differ diff --git a/exportchannels/data/CliFx.dll b/exportchannels/data/CliFx.dll new file mode 100644 index 0000000..49643a8 Binary files /dev/null and b/exportchannels/data/CliFx.dll differ diff --git a/exportchannels/data/DiscordChatExporter.Cli.deps.json b/exportchannels/data/DiscordChatExporter.Cli.deps.json new file mode 100644 index 0000000..90f5d07 --- /dev/null +++ b/exportchannels/data/DiscordChatExporter.Cli.deps.json @@ -0,0 +1,230 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v7.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v7.0": { + "DiscordChatExporter.Cli/2.39.1": { + "dependencies": { + "CliFx": "2.3.1", + "DiscordChatExporter.Core": "2.39.1", + "DotnetRuntimeBootstrapper": "2.4.0", + "FuckRussia": "1.0.1", + "Gress": "2.0.1", + "Spectre.Console": "0.46.0" + }, + "runtime": { + "DiscordChatExporter.Cli.dll": {} + } + }, + "AdvancedStringBuilder/0.1.0": { + "runtime": { + "lib/netstandard2.0/AdvancedStringBuilder.dll": { + "assemblyVersion": "0.1.0.0", + "fileVersion": "0.1.0.0" + } + } + }, + "AsyncKeyedLock/6.2.0": { + "runtime": { + "lib/net5.0/AsyncKeyedLock.dll": { + "assemblyVersion": "6.2.0.0", + "fileVersion": "6.2.0.0" + } + } + }, + "CliFx/2.3.1": { + "runtime": { + "lib/netstandard2.1/CliFx.dll": { + "assemblyVersion": "2.3.1.0", + "fileVersion": "2.3.1.0" + } + } + }, + "DotnetRuntimeBootstrapper/2.4.0": {}, + "FuckRussia/1.0.1": {}, + "Gress/2.0.1": { + "runtime": { + "lib/netstandard2.0/Gress.dll": { + "assemblyVersion": "2.0.1.0", + "fileVersion": "2.0.1.0" + } + } + }, + "JsonExtensions/1.2.0": { + "runtime": { + "lib/net5.0/JsonExtensions.dll": { + "assemblyVersion": "1.2.0.0", + "fileVersion": "1.2.0.0" + } + } + }, + "Polly/7.2.3": { + "runtime": { + "lib/netstandard2.0/Polly.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.2.3.0" + } + } + }, + "RazorBlade/0.4.2": { + "runtime": { + "lib/net6.0/RazorBlade.dll": { + "assemblyVersion": "0.4.2.0", + "fileVersion": "0.4.2.0" + } + } + }, + "Spectre.Console/0.46.0": { + "dependencies": { + "System.Memory": "4.5.5" + }, + "runtime": { + "lib/net7.0/Spectre.Console.dll": { + "assemblyVersion": "0.0.0.0", + "fileVersion": "0.46.0.0" + } + } + }, + "Superpower/3.0.0": { + "runtime": { + "lib/net5.0/Superpower.dll": { + "assemblyVersion": "1.0.0.0", + "fileVersion": "3.0.0.0" + } + } + }, + "System.Memory/4.5.5": {}, + "WebMarkupMin.Core/2.13.8": { + "dependencies": { + "AdvancedStringBuilder": "0.1.0" + }, + "runtime": { + "lib/netstandard2.1/WebMarkupMin.Core.dll": { + "assemblyVersion": "2.13.8.0", + "fileVersion": "2.13.8.0" + } + } + }, + "DiscordChatExporter.Core/2.39.1": { + "dependencies": { + "AsyncKeyedLock": "6.2.0", + "Gress": "2.0.1", + "JsonExtensions": "1.2.0", + "Polly": "7.2.3", + "RazorBlade": "0.4.2", + "Superpower": "3.0.0", + "WebMarkupMin.Core": "2.13.8" + }, + "runtime": { + "DiscordChatExporter.Core.dll": {} + } + } + } + }, + "libraries": { + "DiscordChatExporter.Cli/2.39.1": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "AdvancedStringBuilder/0.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-IbN3r5whlJvi8MhCDPVpIb+NVScyUcKSdcJZrnoXFDyzPDISl3AbWouNBYIHRdZdfGuzqCQEhM1vkxbIKqQVaQ==", + "path": "advancedstringbuilder/0.1.0", + "hashPath": "advancedstringbuilder.0.1.0.nupkg.sha512" + }, + "AsyncKeyedLock/6.2.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-FJqEME0eyM1EHVymnG32vmqKEFZ9X7/LX0NOuHyAeQqpncJFt+ODvzfx0SAlmF6m5NtL6xyPfvt9uTckbSWLhQ==", + "path": "asynckeyedlock/6.2.0", + "hashPath": "asynckeyedlock.6.2.0.nupkg.sha512" + }, + "CliFx/2.3.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-erOn8SLCHt3p+pj8nIKmzqDyXV6hwQr1wHmyVuFujnLJRKP1ovuswPBNKUNXv9Le7/HhNawln/Upc5v6Nhn3zA==", + "path": "clifx/2.3.1", + "hashPath": "clifx.2.3.1.nupkg.sha512" + }, + "DotnetRuntimeBootstrapper/2.4.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-CuNwd8O1trpAaPlhcP4ourZH4onf6FqBDWQzzmKqqgF3TZCKkFuL5xDZNvbWWdDQI2dx3z/XBRxwBQghVKSD7Q==", + "path": "dotnetruntimebootstrapper/2.4.0", + "hashPath": "dotnetruntimebootstrapper.2.4.0.nupkg.sha512" + }, + "FuckRussia/1.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-mdo3UfOIrRfi05m6qN+rJt3yKkM5Bq9hC3b/NYe5c0orhF6TGsIoJBo+OqX6P2LLouSeFNE01UjR9bbvXbT9+A==", + "path": "fuckrussia/1.0.1", + "hashPath": "fuckrussia.1.0.1.nupkg.sha512" + }, + "Gress/2.0.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Ky68Wbb3WUkFw5g92tcTRNf5IVMV5AyLB8+uw4pCpXmfS2gkIzWV9BnTGNu+aTaklYqvSZlQL6BnH+9I7HG5tg==", + "path": "gress/2.0.1", + "hashPath": "gress.2.0.1.nupkg.sha512" + }, + "JsonExtensions/1.2.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-ujtrK6m5BQVQLEteLfl54upN7Z59c1ZqEKmU3OlYriqnV74dIgIlNM2vkcgn2AuZEItQDNORD/2H1biI/asOdg==", + "path": "jsonextensions/1.2.0", + "hashPath": "jsonextensions.1.2.0.nupkg.sha512" + }, + "Polly/7.2.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ==", + "path": "polly/7.2.3", + "hashPath": "polly.7.2.3.nupkg.sha512" + }, + "RazorBlade/0.4.2": { + "type": "package", + "serviceable": true, + "sha512": "sha512-uLNIoO35t+gOEWT7EdofyN0tFsbrntoHX5a19CgjwheDhrDSgGY3ubF9zsp4hQnkGhBLAQaQ4K2yyxDHbuC3GQ==", + "path": "razorblade/0.4.2", + "hashPath": "razorblade.0.4.2.nupkg.sha512" + }, + "Spectre.Console/0.46.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-qd2OMEGxfQW1KLuQj56KKHkIK6eB/IUF/AET5CRl/efROHGsvBehx9shfkL0HgJEHLCwRiR7foWi4/LkdPk18g==", + "path": "spectre.console/0.46.0", + "hashPath": "spectre.console.0.46.0.nupkg.sha512" + }, + "Superpower/3.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-bjKbAYWePooCAvPxQq+3KnmcLfRggMyRoXmtBMlmCG71bdwBHrO6rmRJ2DRIodg5aztNcxeZXBUVWT+H+MZUhw==", + "path": "superpower/3.0.0", + "hashPath": "superpower.3.0.0.nupkg.sha512" + }, + "System.Memory/4.5.5": { + "type": "package", + "serviceable": true, + "sha512": "sha512-XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", + "path": "system.memory/4.5.5", + "hashPath": "system.memory.4.5.5.nupkg.sha512" + }, + "WebMarkupMin.Core/2.13.8": { + "type": "package", + "serviceable": true, + "sha512": "sha512-dXAyg/mMmkOBGSzhjOv5dJIvT+u8mBhEPG+QGp+UW4et/lGucSas055tb1793UT+gV5BOAp+v0FqufLyC7Urjw==", + "path": "webmarkupmin.core/2.13.8", + "hashPath": "webmarkupmin.core.2.13.8.nupkg.sha512" + }, + "DiscordChatExporter.Core/2.39.1": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/exportchannels/data/DiscordChatExporter.Cli.dll b/exportchannels/data/DiscordChatExporter.Cli.dll new file mode 100644 index 0000000..1fd55d6 Binary files /dev/null and b/exportchannels/data/DiscordChatExporter.Cli.dll differ diff --git a/exportchannels/data/DiscordChatExporter.Cli.exe b/exportchannels/data/DiscordChatExporter.Cli.exe new file mode 100644 index 0000000..5ef3d00 Binary files /dev/null and b/exportchannels/data/DiscordChatExporter.Cli.exe differ diff --git a/exportchannels/data/DiscordChatExporter.Cli.exe.config b/exportchannels/data/DiscordChatExporter.Cli.exe.config new file mode 100644 index 0000000..cd72180 --- /dev/null +++ b/exportchannels/data/DiscordChatExporter.Cli.exe.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/exportchannels/data/DiscordChatExporter.Cli.pdb b/exportchannels/data/DiscordChatExporter.Cli.pdb new file mode 100644 index 0000000..7a1cdd8 Binary files /dev/null and b/exportchannels/data/DiscordChatExporter.Cli.pdb differ diff --git a/exportchannels/data/DiscordChatExporter.Cli.runtimeconfig.json b/exportchannels/data/DiscordChatExporter.Cli.runtimeconfig.json new file mode 100644 index 0000000..398903e --- /dev/null +++ b/exportchannels/data/DiscordChatExporter.Cli.runtimeconfig.json @@ -0,0 +1,12 @@ +{ + "runtimeOptions": { + "tfm": "net7.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "7.0.0" + }, + "configProperties": { + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false + } + } +} \ No newline at end of file diff --git a/exportchannels/data/DiscordChatExporter.Core.dll b/exportchannels/data/DiscordChatExporter.Core.dll new file mode 100644 index 0000000..fe969d7 Binary files /dev/null and b/exportchannels/data/DiscordChatExporter.Core.dll differ diff --git a/exportchannels/data/DiscordChatExporter.Core.pdb b/exportchannels/data/DiscordChatExporter.Core.pdb new file mode 100644 index 0000000..2855033 Binary files /dev/null and b/exportchannels/data/DiscordChatExporter.Core.pdb differ diff --git a/exportchannels/data/Gress.dll b/exportchannels/data/Gress.dll new file mode 100644 index 0000000..406165c Binary files /dev/null and b/exportchannels/data/Gress.dll differ diff --git a/exportchannels/data/JsonExtensions.dll b/exportchannels/data/JsonExtensions.dll new file mode 100644 index 0000000..178ec47 Binary files /dev/null and b/exportchannels/data/JsonExtensions.dll differ diff --git a/exportchannels/data/Polly.dll b/exportchannels/data/Polly.dll new file mode 100644 index 0000000..6443e71 Binary files /dev/null and b/exportchannels/data/Polly.dll differ diff --git a/exportchannels/data/README.txt b/exportchannels/data/README.txt new file mode 100644 index 0000000..5acd9ca --- /dev/null +++ b/exportchannels/data/README.txt @@ -0,0 +1,2 @@ +This bundled version of Discord Chat Exporter can be found here: https://github.com/Tyrrrz/DiscordChatExporter/releases/tag/2.39.1 +I DID NOT MAKE THIS PROGRAM. This program is developed by Tyrrrz, NOT me. \ No newline at end of file diff --git a/exportchannels/data/RazorBlade.dll b/exportchannels/data/RazorBlade.dll new file mode 100644 index 0000000..0b39107 Binary files /dev/null and b/exportchannels/data/RazorBlade.dll differ diff --git a/exportchannels/data/Spectre.Console.dll b/exportchannels/data/Spectre.Console.dll new file mode 100644 index 0000000..8f7980d Binary files /dev/null and b/exportchannels/data/Spectre.Console.dll differ diff --git a/exportchannels/data/Superpower.dll b/exportchannels/data/Superpower.dll new file mode 100644 index 0000000..ae94040 Binary files /dev/null and b/exportchannels/data/Superpower.dll differ diff --git a/exportchannels/data/WebMarkupMin.Core.dll b/exportchannels/data/WebMarkupMin.Core.dll new file mode 100644 index 0000000..7c1859a Binary files /dev/null and b/exportchannels/data/WebMarkupMin.Core.dll differ diff --git a/exportchannels/exportchannels.py b/exportchannels/exportchannels.py new file mode 100644 index 0000000..b072c6c --- /dev/null +++ b/exportchannels/exportchannels.py @@ -0,0 +1,88 @@ +import discord +import subprocess +import os +from redbot.core import Config, checks, commands, bot, data_manager + +class ExportChannels(commands.Cog): + """Custom cog to export channels to Json and HTML formats using Discord Chat Exporter. + Developed by SeaswimmerTheFsh and yname.""" + + def __init__(self, bot): + self.bot = bot + self.config = Config.get_conf(self, identifier=48258471944753312) + self.config.register_global( + bot_token = "0" + ) + + + def export(self, ctx, channel, token): + self.data_path = data_manager.cog_data_path(self) + self.bundled_data_path = data_manager.bundled_data_path(self) + out = f'{self.data_path}/Exported Channels' + try: + os.mkdir(out) + except FileExistsError: + pass + args = [ + 'dotnet', + 'DiscordChatExporter.Cli.dll', + 'export', + '--format', 'HtmlDark', + '--output', f'/{out}/%G (%g)/%C (%c)/Export.html', + '--token', f'{token}', + '--channel', {channel}, + '--media', + '--fuck_russia', 'true', + ] + if bot: + args += '--bot' + os.chdir(self.bundled_data_path) + subprocess.call(args) + args = [ + 'dotnet', + 'DiscordChatExporter.Cli.dll', + 'export', + '--format', 'Json', + '--output', f'/{out}/%G (%g)/%C (%c)/DCE-f.json', + '--token', f'{token}', + '--channel', {channel}, + '--reuse_media', + '--media', + '--fuck_russia', 'true', + ] + if bot: + args += '--bot' + os.chdir(self.bundled_data_path) + subprocess.call(args) + + @commands.group() + @checks.is_owner() + async def exportset(self, ctx): + """Configuration options for the ExportChannels cog.""" + + @exportset.command() + @checks.is_owner() + async def token(self, ctx, token: str): + """Sets the bot token used for Discord Chat Exporter.""" + await self.config.bot_token.set({token}) + await ctx.send(content="Token set!") + await ctx.delete() + + @exportset.command() + @checks.is_owner() + async def checkoutputpath(self, ctx): + """Checks what file path DCE is outputting to.""" + self.data_path = data_manager.cog_data_path(self) + await ctx.send(content=f"{self.data_path}") + + @commands.command() + @commands.admin() + async def exportchannel(self, ctx, channel: discord.Channel): + """Exports a channel using Discord Chat Exporter.""" + token = await self.config.bot_token + dce_install = data_manager.bundled_data_path(self) + if token == 0: + await ctx.send(content="Please set your token with the ``exportset token`` command!") + return + else: + await self.export(channel.id, token)