Last active
August 2, 2019 17:16
-
-
Save Nazgolze/c7e31bd1b224c959766350ad9fd0526a to your computer and use it in GitHub Desktop.
minimal rocket chat export through api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
echo '-----------------------------' | |
echo '-- Get my rocket chat data --' | |
echo '-----------------------------'; echo | |
echo 'Enter your username or e-mail address' | |
read user | |
echo | |
echo 'Now enter your password' | |
read -s password | |
login_credentials=$(curl -s https://lisk.chat/api/v1/login -d "user=$user&password=$password") | |
login_status=$(echo $login_credentials | jq -r .status) | |
if [ $login_status != "success" ] ; then | |
echo $login_credentials | |
exit | |
fi | |
echo "Retrieving data..." | |
user_id=$(echo $login_credentials | jq -r .data.userId) | |
auth_token=$(echo $login_credentials | jq -r .data.authToken) | |
channel_info=$(curl -s -H "X-Auth-Token: $auth_token" -H "X-User-Id: $user_id" https://lisk.chat/api/v1/channels.list) | |
channel_names=$(echo $channel_info | jq -r '.channels[].name') | |
group_info=$(curl -s -H "X-Auth-Token: $auth_token" -H "X-User-Id: $user_id" https://lisk.chat/api/v1/groups.list) | |
group_names=$(echo $group_info | jq -r '.groups[].name') | |
im_info=$(curl -s -H "X-Auth-Token: $auth_token" -H "X-User-Id: $user_id" https://lisk.chat/api/v1/im.list) | |
im_names=$(echo $im_info | jq -r '.ims[]._id') | |
mkdir channels groups messages || true | |
for c in ${channel_names[@]} | |
do | |
curl -s -H "X-Auth-Token: $auth_token" -H "X-User-Id: $user_id" "https://lisk.chat/api/v1/channels.messages?roomName=$c&count=500000" > channels/$c | |
done | |
for g in ${group_names[@]} | |
do | |
curl -s -H "X-Auth-Token: $auth_token" -H "X-User-Id: $user_id" "https://lisk.chat/api/v1/groups.messages?roomName=$g&count=500000" > groups/$g | |
done | |
for i in ${im_names[@]} | |
do | |
curl -s -H "X-Auth-Token: $auth_token" -H "X-User-Id: $user_id" "https://lisk.chat/api/v1/im.messages?roomId=$i&count=500000" > messages/$i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment