Skip to content

Search image from Tweet, Post it to Slack. Running on AWS Lambda.

License

Notifications You must be signed in to change notification settings

evalphobia/serverless-twitter-image-slack

Repository files navigation

serverless-twitter-image-slack

License: MIT Release Build Status Code Climate BCH compliance

serverless-twitter-image-slack search tweet with image and post it to Slack channel, powered by AWS Lambda.

Download

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

Config

serverless.yml

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

Environment variables

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 -

Deploy

# To use `sls` command, install first.
# $ npm install -g serverless

$ AWS_ACCESS_KEY_ID=<...> AWS_SECRET_ACCESS_KEY=<...> sls deploy -v

Check Log

$ AWS_ACCESS_KEY_ID=<...> AWS_SECRET_ACCESS_KEY=<...> sls logs -f sls-twitter-image-slack -t

Credit

The codebase to get data from Twitter is from Jefferson-Henrique's GetOldTweets-python. Many thanks!

About

Search image from Tweet, Post it to Slack. Running on AWS Lambda.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages