serverless-twitter-image-slack
search tweet with image and post it to Slack channel, powered by AWS Lambda.
Download serverless-twitter-image-slack by command below.
$ git clone https://github.com/evalphobia/serverless-twitter-image-slack
$ cd serverless-twitter-image-slack
$ npm install
Change environment variables below,
$ cp serverless.yml.example serverless.yml
$ vim serverless.yml
------------
functions:
# Change function name, if you don't collect kitten images.
tweet_cat:
handler: handler.handler
memorySize: 128
timeout: 60
environment:
######### Change here! ########
TWEET_SEARCH_USERS: "@Number10cat,@catsofinstagram"
TWEET_SEARCH_SINCE_MIN: 5
SLACK_USERNAME: twitter-image-bot
SLACK_CHANNEL: general
SLACK_WEBHOOK_URL: https://hooks.slack.com/services/XXX/YYY/ZZZ
events:
- schedule: cron(*/5 * * * ? *) # exec every 5min
Name | Description | Default |
---|---|---|
TWEET_SEARCH_USERS |
The Twitter username. Put multiple user with comma. | - |
TWEET_SEARCH_HASHTAGS |
The Twitter hashtags. Put multiple hashtags with comma. | - |
TWEET_SEARCH_IGNORE_WORDS |
The words to remove it from search result. Put multiple words with comma. | - |
TWEET_SEARCH_SINCE_MIN |
The threshold time of tweets. | 5 (5min) |
SLACK_USERNAME |
Slack webhook username | (Optional) |
SLACK_CHANNEL |
Slack webhook channel | (Optional) |
SLACK_WEBHOOK_URL |
Slack webhook URL | - |
# To use `sls` command, install first.
# $ npm install -g serverless
$ AWS_ACCESS_KEY_ID=<...> AWS_SECRET_ACCESS_KEY=<...> sls deploy -v
$ AWS_ACCESS_KEY_ID=<...> AWS_SECRET_ACCESS_KEY=<...> sls logs -f sls-twitter-image-slack -t
The codebase to get data from Twitter is from Jefferson-Henrique's GetOldTweets-python. Many thanks!