Compare commits
4 commits
8c7af61ef7
...
f72ed78b60
Author | SHA1 | Date | |
---|---|---|---|
f72ed78b60 | |||
16e74356d4 | |||
98d0033b19 | |||
75a40f7178 |
1 changed files with 20 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
||||||
import discord
|
import discord
|
||||||
import subprocess
|
import asyncio
|
||||||
import os
|
import os
|
||||||
from redbot.core import Config, checks, commands, bot, data_manager
|
from redbot.core import Config, checks, commands, data_manager
|
||||||
|
|
||||||
class ExportChannels(commands.Cog):
|
class ExportChannels(commands.Cog):
|
||||||
"""Custom cog to export channels to JSON and HTML formats using Discord Chat Exporter.
|
"""Custom cog to export channels to JSON and HTML formats using Discord Chat Exporter.
|
||||||
|
@ -21,6 +21,8 @@ class ExportChannels(commands.Cog):
|
||||||
self.bundled_data_path = data_manager.bundled_data_path(self)
|
self.bundled_data_path = data_manager.bundled_data_path(self)
|
||||||
out = f'{self.data_path}{os.sep}Exported Channels'
|
out = f'{self.data_path}{os.sep}Exported Channels'
|
||||||
channel = channels[0]
|
channel = channels[0]
|
||||||
|
file_location_html = f'{os.sep}{out}{os.sep}%g{os.sep}%c{os.sep}Export.html'
|
||||||
|
file_location_json = f'{os.sep}{out}{os.sep}%g{os.sep}%c{os.sep}DCE-f.json'
|
||||||
try:
|
try:
|
||||||
os.mkdir(out)
|
os.mkdir(out)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
|
@ -30,28 +32,36 @@ class ExportChannels(commands.Cog):
|
||||||
'DiscordChatExporter.Cli.dll',
|
'DiscordChatExporter.Cli.dll',
|
||||||
'export',
|
'export',
|
||||||
'--format', 'HtmlDark',
|
'--format', 'HtmlDark',
|
||||||
'--output', f'{os.sep}{out}{os.sep}%G (%g){os.sep}%C (%c){os.sep}Export.html',
|
'--output', file_location_html,
|
||||||
'--token', f'{token}',
|
'--token', token,
|
||||||
'--channel', {channel},
|
'--channel', channel,
|
||||||
'--media',
|
'--media',
|
||||||
'--fuck_russia', 'true',
|
'--fuck_russia', 'true',
|
||||||
]
|
]
|
||||||
os.chdir(self.bundled_data_path)
|
os.chdir(self.bundled_data_path)
|
||||||
subprocess.call(args)
|
process_1 = await asyncio.create_subprocess_exec(*args)
|
||||||
|
while True:
|
||||||
|
return_code_1 = process_1.poll()
|
||||||
|
if return_code_1 is not None:
|
||||||
|
break
|
||||||
args = [
|
args = [
|
||||||
'dotnet',
|
'dotnet',
|
||||||
'DiscordChatExporter.Cli.dll',
|
'DiscordChatExporter.Cli.dll',
|
||||||
'export',
|
'export',
|
||||||
'--format', 'Json',
|
'--format', 'Json',
|
||||||
'--output', f'{os.sep}{out}{os.sep}%G (%g){os.sep}%C (%c){os.sep}DCE-f.json',
|
'--output', file_location_json,
|
||||||
'--token', f'{token}',
|
'--token', token,
|
||||||
'--channel', {channels},
|
'--channel', channels,
|
||||||
'--reuse_media',
|
'--reuse_media',
|
||||||
'--media',
|
'--media',
|
||||||
'--fuck_russia', 'true',
|
'--fuck_russia', 'true',
|
||||||
]
|
]
|
||||||
os.chdir(self.bundled_data_path)
|
os.chdir(self.bundled_data_path)
|
||||||
subprocess.call(args)
|
process_2 = await asyncio.create_subprocess_exec(*args)
|
||||||
|
while True:
|
||||||
|
return_code_2 = process_2.poll()
|
||||||
|
if return_code_2 is not None:
|
||||||
|
break
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
|
|
Loading…
Reference in a new issue