bash script to recopile viewers on a twitch chat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
870 B

  1. #!/bin/bash
  2. login="56knews"
  3. tmpFile="/tmp/.viewers.tmp"
  4. viewersFile="/tmp/viewers.txt"
  5. rm -rf $tmpFile $viewersFile
  6. function main(){
  7. while :
  8. do
  9. getViewers
  10. getModerators
  11. getBroadcaster
  12. sleep 60
  13. done
  14. }
  15. function getViewers(){
  16. curl -s -X GET "https://tmi.twitch.tv/group/user/$login/chatters" | jq .chatters | jq .viewers | grep -i "\"" | cut -d "\"" -f 2 >> $tmpFile
  17. cat $tmpFile | sort -u > $viewersFile
  18. }
  19. function getModerators(){
  20. curl -s -X GET "https://tmi.twitch.tv/group/user/$login/chatters" | jq .chatters | jq .moderators | grep -i "\"" | cut -d "\"" -f 2 >> $tmpFile
  21. cat $tmpFile | sort -u > $viewersFile
  22. }
  23. function getBroadcaster(){
  24. curl -s -X GET "https://tmi.twitch.tv/group/user/$login/chatters" | jq .chatters | jq .broadcaster | grep -i "\"" | cut -d "\"" -f 2 >> $tmpFile
  25. cat $tmpFile | sort -u > $viewersFile
  26. }
  27. main