2023年から、以下のようなことを試しています。
「コミュニティの Discord サーバのログをHTMLで取得する」
https://qiita.com/nanbuwks/items/3f7ddf369bd0ddbd5cc5
「GitHub Pages でコミュニティサイトを作り、DiscordLog を公開してみる」
https://qiita.com/nanbuwks/items/063c375a26153512fd5d
目下の問題点として、
ログの画像が一気に読み込まれてしまいます。
月ごとのスレッド分けをしたりする工夫が必要でしょう。今後の課題です。
というのがありました。
今回は、実用に向けてスレッドを分けます。
環境
- Ubuntu 22.04 LTS
- GitHub に登録
- GitHub.io で公開
パーティーション設定
Discord のチャンネルは整理して以下の構成になっています。
これを公開することにしました。
当初は月ごとにスレッドを分けようと思ったのですが・・・
各チャンネルは、書き込みがあるところ、ほとんど書き込みがないところがあります。
ほとんど書き込みがないところを月で分けるとさびしいことになってしまうので、書き込み100メッセージごとに分けることにします。
https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md
を見ると、
Messages per partition (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.
ということで、 --partition
オプションをつけることで実現できるようです。
100ごとに操作
$ dotnet DiscordChatExporter.Cli.dll export --partition 100 --channel 997293495687585839 --token <(トークン)> -f "HtmlDark" -o test
とすると、以下のようになりました。
$ ls test
'OpenHardTerrace - テキストチャンネル - 雑談 [997293495687585839] [part 2].html'
'OpenHardTerrace - テキストチャンネル - 雑談 [997293495687585839] [part 3].html'
'OpenHardTerrace - テキストチャンネル - 雑談 [997293495687585839] [part 4].html'
'OpenHardTerrace - テキストチャンネル - 雑談 [997293495687585839] [part 5].html'
'OpenHardTerrace - テキストチャンネル - 雑談 [997293495687585839] [part 6].html'
'OpenHardTerrace - テキストチャンネル - 雑談 [997293495687585839].html'
うーん、名前を工夫したいですね。
ファイル名を工夫する
によると、
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.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.htmlHere is the full list of supported template tokens:
%g - guild ID
%G - guild name
%t - category ID
%T - category name
%c - channel ID
%C - channel name
%p - channel position
%P - category position
%a - the "after" date
%b - the "before" date
%% - escapes %
ということで、
試してみたら以下のような出力が得られました。
- %G → "OpenHardTerrace"
- %T → "テキストチャンネル"
- %C → "雑談"
%a,%b は --after, --before オプションをつけないと出てこない感じです。
なので、以下のようにしてみました。
$ dotnet DiscordChatExporter.Cli.dll export --partition 100 --channel 997293495687585839 --token <(トークン)> -f "HtmlDark" -o test/%G%C.html
そのようにして得られたのは以下のようになります。
DiscordLog/OpenHardTerracegeneral.html 'DiscordLog/OpenHardTerrace雑談 [part 6].html' 'DiscordLog/OpenHardTerrace中国調達 [part 5].html'
'DiscordLog/OpenHardTerrace雑談 [part 2].html' DiscordLog/OpenHardTerrace雑談.html 'DiscordLog/OpenHardTerrace中国調達 [part 6].html'
'DiscordLog/OpenHardTerrace雑談 [part 3].html' 'DiscordLog/OpenHardTerrace中国調達 [part 2].html' 'DiscordLog/OpenHardTerrace中国調達 [part 7].html'
'DiscordLog/OpenHardTerrace雑談 [part 4].html' 'DiscordLog/OpenHardTerrace中国調達 [part 3].html' DiscordLog/OpenHardTerrace中国調達.html
'DiscordLog/OpenHardTerrace雑談 [part 5].html' 'DiscordLog/OpenHardTerrace中国調達 [part 4].html'
これを使って公開しました。
おまけ
2/19に公開したこのページが、Google 検索にかかるかな? と思いましたが検索に引っ借りませんでした。
要改善。