Last active
November 9, 2021 17:14
-
-
Save systemfreund/a35aea6a1f94015660fc to your computer and use it in GitHub Desktop.
Twitter stream integration for mattermost
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 | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
credentials=
->config=
at line 9.