Skip to content

Instantly share code, notes, and snippets.

@systemfreund
Last active November 9, 2021 17:14
Show Gist options
  • Save systemfreund/a35aea6a1f94015660fc to your computer and use it in GitHub Desktop.
Save systemfreund/a35aea6a1f94015660fc to your computer and use it in GitHub Desktop.
Twitter stream integration for mattermost
#!/bin/bash
# dependencies:
# curl
# culicue - curl wrapper to make oauthv1 requests (https://github.com/decklin/curlicue/blob/master/curlicue)
# jq - filter json from twitter api and transform to a structure mattermost is expecting
# credentials file can be created with the curlicue-setup script
credentials=/home/me/credentials.conf
webhook='https://yourmattermost.server/hooks/1mjxx6amd52q8doxzy16o75adh'
curlicue -f $config -- -N -s https://userstream.twitter.com/1.1/user.json \
| jq --unbuffered -a -c 'select(.text != null) | {"text": .text, "username": "\(.user.screen_name) via twitter", "icon_url": .user.profile_image_url_https}' | \
while read tweet ;
do
echo "new tweet: $tweet"
curl -XPOST -H 'Content-Type: application/json' -d "$tweet" $webhook
done
@gokceneraslan
Copy link

credentials= -> config= at line 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment