Last active
September 4, 2018 16:14
-
-
Save gecko655/aa93ae94382dfbf38c06a1bfe9d06bfa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Slack team内で最近発言されたチャンネルだけをリストアップするやつ | |
# channels.listのページングは何も考えてない。1000くらいなら取れるっぽい。 | |
TOKEN='xoxp-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' #slack regacy|user|bot token | |
curl 'https://slack.com/api/channels.list?token='$TOKEN'&exclude_archived=true&exclude_members=true&limit=1000' > tmp | |
for row in `cat tmp | jq -r '.channels[] | .id +"," + .name'` | |
do | |
ch_id=`echo $row | cut -d',' -f 1` | |
date_raw=`curl 'https://slack.com/api/channels.history?token='$TOKEN'&channel='$ch_id'&count=100' | \ | |
jq -r '[.messages[] | select(.subtype == 'null')][0] | .ts' | \ # find the last HUMAN-made post | |
sed 's/\..*$//'` | |
if [[ "$date_raw" = 'null' ]]; then | |
continue #no one (human) posted in this channel | |
fi | |
date_readable=`date -r $date_raw` | |
echo "${date_raw},${date_readable},${row}" | |
done | sort -t',' -k1 -nr | cut -d',' -f'2,4' > result | |
rm tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment