Highlighting misspellings of Tucson, AZ, one embarrassing tweet at a time.
Simple bot which uses the Twitter Search API to find occurrences of Tucson
being misspelled as Tuscon
. Uses a scheduled Firebase Function to run the search at regular intervals and then retweets any matches. The id
of the most recently retweeted match is persisted to the RealTime database to prevent duplicate tweets.
Further reading:
See file functions/index.js for the code.
The dependencies are listed in functions/package.json.
- Clone or download this repo and open the
itstucson-bot
directory.
- Create a Firebase Project using the Firebase Developer Console
- Enable billing on your project by switching to the Blaze or Flame plan. See pricing for more details. This is required to allow requests to non-Google services within the Function.
- Install Firebase CLI Tools if you have not already, and log in with
firebase login
. - Configure this sample to use your project using
firebase use --add
and select your project.
- Install dependencies locally by running:
cd functions; npm i; cd -
- Add your Twitter API credentials to the Firebase config:
firebase functions:config:set \ twitter.consumer_key=<YOUR TWITTER CONSUMER KEY> \ twitter.consumer_secret=<YOUR TWITTER CONSUMER SECRET> \ twitter.access_token=<YOUR TWITTER ACCESS TOKEN> \ twitter.access_token_secret=<YOUR TWITTER ACCESS TOKEN SECRET> \
There are a number of variables which can be customized within the function:
keyword
- set thecorrect
andincorrect
spellings of your target keywordquery
- any additional search filters you would like to include in the queryinterjections
- an array of interjections that are randomly used when retweeting matches
The function will also look for an ignore
object in the RealTime database containing an array of terms which, if matched, will cause the tweet to be ignored.
- Deploy your function using
firebase deploy --only functions
- By default, the function will be run every 15 minutes