From 94db2f9ee94d59c8cefff3733f6fcb3bbc13f8b6 Mon Sep 17 00:00:00 2001 From: shlagevuk Date: Tue, 4 Dec 2018 10:34:24 +0100 Subject: [PATCH] adding more docker usage examples with bot, small script to gather everything and list of options for the Cli --- Docker-usage-instructions.md | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Docker-usage-instructions.md b/Docker-usage-instructions.md index 4cf9bef..f9e00bf 100644 --- a/Docker-usage-instructions.md +++ b/Docker-usage-instructions.md @@ -1,3 +1,5 @@ +### Usage with session token and ID of channel + To pull the latest version: $ docker pull tyrrrz/discordchatexporter @@ -6,5 +8,66 @@ To export: $ docker run tyrrrz/discordchatexporter export -t TOKEN -c CHANNEL +## + +### Usage with a bot instead of a session token + +To get list of guilds available to a bot: + + $ docker run tyrrrz/discordchatexporter guilds -t TOKEN -b + +To get list of channel available to a bot on a given guild: + + $ docker run tyrrrz/discordchatexporter channels -t TOKEN -b -g GUILD_ID + +To get content of channel: + + $ docker run tyrrrz/discordchatexporter export -t TOKEN -b -c CHANNEL + +Export path is in /a in docker image, so if you need to bring the file on the host use the following command: + + $ docker run -v $PWD:/a tyrrrz/discordchatexporter export -t TOKEN -b -c CHANNEL + +And finally a small script to gather every channel your bot is on: + +```bash +MY_TOKEN_ID= + +# get list of guilds +guilds=$(docker run --rm -v $PWD:/a tyrrrz/discordchatexporter guilds -t $MY_TOKEN_ID -b | tr -d '[:blank:]') + +for guild in $guilds; do + guild_id=$(echo $guild | cut -d '|' -f 1) + guild_name=$(echo $guild | cut -d '|' -f 2) + echo processing $guild_name with id $guild_id + + channels=$(docker run --rm -v $PWD:/a tyrrrz/discordchatexporter channels -t $MY_TOKEN_ID -b -g $guild_id | tr -d '[:blank:]') + for channel in $channels; do + channel_id=$(echo $channel | cut -d '|' -f 1) + channel_name=$(echo $channel | cut -d '|' -f 2) + + echo processing $channel_name in guild $guild_name with channel id: $channel_id + result=$(docker run --rm -v $PWD:/a tyrrrz/discordchatexporter export -t $MY_TOKEN_ID -b -c $channel_id -o /a/${guild_name}_${channel_name}.html) + if [ ! $? ]; then + echo an error happenned: $result + exit 1 + else + echo channel saved as ${guild_name}_${channel_name}.html + fi + done +done +``` + +List of options for cli call from [ExportChatOption.cs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/DiscordChatExporter.Cli/Verbs/Options/ExportChatOptions.cs): + + -c|--channel + [-f|--format] + [-o|--ouptput] + [--after] + [--before] + [-p|--partition] + [--dateformat] + [--grouplimit] + ## Credits to [@simnalamburt](https://github.com/simnalamburt) \ No newline at end of file