rjchee / spongemock

Spongemock as a Service (SMaaS)
MIT License
6 stars 3 forks source link

Spongemock

Spongemock is a collection of services that add Spongebob mocking functionality to a variety of platforms. Currently, only Slack and Twitter are supported.

Table of Contents

Setup

The Spongemock server can be hosted on Heroku by clicking the button below.

Deploy

Of course, you can always choose to host it somewhere else. You can run the app with

go run cmd/spongemock/main.go&
go run cmd/worker/main.go&

Spongemock requires the following environmental variables to run:

For setup instructions for the other components, refer to the Setup instructions below:

Slack Integration

The Spongemock Slack integration adds a slash command /spongemock which will have Spongebob mock the last person who sent a message in the channel.

Example

alt text

Slack Setup

First, create a Slack App and add a slash command. The request URL will be of the form $APP_URL/slack. You also want to escape channels, users, and links sent to your app.

To run the Slack plugin, the following environmental variables are required:

After adding those variables, you want to complete your setup of the Slack app. Install your app from the Basic Information page, and distribute it by completing the instructions. For the OAuth Redirect URL, you will need to use $APP_URL/slack/oauth2.

Twitter Integration

The spongemock Twitter bot has an official account at https://twitter.com/spongemock_bot. This bot will respond to all mentions by mocking the appropriate person's text. It does its best to strip out extraneous text like beginning @'s and ending image links. Currently it does not check the tweet length, and it may attempt to send tweets that are too long.

Example

https://twitter.com/spongemock_bot/status/866809266790912002

Bot Reply Rules

If person A mentions the bot in a reply to person B, then the bot will mock person A, unless person B is the bot itself, in which case it will mock person A. Otherwise, if person A mentions the bot in a quote retweet of person B, the bot will mock person B. If there is no person B, the bot will mock person A.

Twitter Setup

You need a Twitter account for the bot. Go to https://apps.twitter.com and create a new app for your bot. Create an Access Token.

To run the Twitter bot, the following environmental variables are required:

If you are running the bot on a Heroku, you may need to run heroku ps:scale worker=1 since the Twitter bot runs on a worker dyno. Additionally, if you have the web dyno running on a free tier, you may need to add the Heroku Scheduler add-on and schedule the command wakeup every 30 minutes to prevent the web and worker dynos from idling.

TODO