/memelord

A Slack bot to automatically tally up reactions to posts in your meme channel and award a winner!

Primary LanguageTypeScriptMIT LicenseMIT

Meme Lord

Add to Slack

Meme Lord icon

Meme Lord is a Slack bot that can be used to automatically tally up reactions to posts in your meme channel and award a winner! It makes a great companion when doing meme reviews.

This project is part of #CreateWeekly, my attempt to create something new publicly every week in 2020.

Features

  • Create dividers to separate group of posts (for a weekly meme review for example)
  • Automatically tally up and sort unique user reactions to each post
  • Award up to three winners
  • View a leaderboard of previous winners

How to install

Add to Slack

  • Click the button above to install Meme Lord into your Slack workspace. During installation, give the app permission to access your meme channel (e.g. #random). The app should appear in the sidebar of your Slack workspace after successful installation.
  • Go to your meme channel on Slack and invite Meme Lord by typing /invite @memelord and confirming
  • You are now ready to use Meme Lord. See the commands below for how to use.

Commands

/divide

Create a divider for a new set of posts. This divider will be used when you run /tally without an argument.

/tally

Tally reactions to posts since the last divider, or if specified, the given start and end messages.

Format

  • /tally - counts all messages since the last divider
  • /tally [start message] - counts all messages since the given message link
  • /tally [start message] [end message] - counts all messages between the given message links

Arguments

  • [start message] - the link of a message to use as start divider. If specified, counts all messages since that message (excluding the message).
  • [end message] - the link of a message to use as end divider. If specified in addition to [start message], counts all messages between the start and end messages (excluding them).

/award

Award one or more users as winners, and add them to the leaderboard. Can automatically pick winners for first, second, and third place based on unique reaction count.

Format

  • /award - automatically picks winners by tallying messages since the last divider.
  • /award [start message] - automatically picks winners by tallying messages since the given message link.
  • /award [start message] [end message] - automatically picks winners by tallying messages between the given message links.
  • /award [@first] [@second] [@third] - manually specify winners by user name. See below for syntax.

Manual award syntax

  • <@first> (required) - the first place winner or winners. Up to three first place winners may be specified by separating with a comma: @firstA,@firstB,@firstC.
  • [@second] - the second place winner or winners. Up to three second place winners may be specified in the same manner as first place.
  • [@third] - the third place winner or winners. Up to three third place winners may be specified in the same manner as first and second places.

/leaderboard

Show the leaderboard of previous winners.

Privacy

If you use the Meme Lord app from the Slack directory, the following details are sent to and stored on our servers. They are necessary to run the app.

  • The name and identifier of the Slack workspace
  • The name and identifier of the channel the app was installed into, as well as the app's secret access token
  • The user identifier of the app in your workspace
  • The user identifiers (not names) of winners and the user running the command when you run /award. These are stored for the leaderboard.
  • The message identifier of the last divider when you run /divide

You can run the app on your own server (requires Node.js and MongoDB) if you don't wish to expose the above data. See below for how to do so.

Self hosting

You can make changes and host the app on your own server. You'll need Git, Node.js, and MongoDB on the server.

  • Create an app on Slack
    • On the Basic Information page of the app's settings, under Add features and functionality, enable incoming webhooks, slash commands and bots
    • On the OAuth & Permissions page, add the following scopes: app_mentions:read, channels:history, chat:write, commands, incoming-webhook, reactions:read
    • Add https://<app url on your server>/install/auth as the OAuth redirect URL
    • On the Slash Commands page, add the /divide, /tally, /award, and /leaderboard commands, and set them to post to https://<app url on your server>/api/messages
  • Clone this repository to your server and run yarn to install dependencies
  • Copy the .env.example file to .env and fill out the credentials from Slack
  • You may also set the RESTRICT_AWARD_TO variable to restrict who can run the /award command. See .env.example for an example.
  • Build the source code by running yarn build
  • Ensure that the Mongo daemon is running
  • Start the app by running yarn start. The app will listen on port 3000. Expose this port using a webserver proxy if you need to.
  • Install the app into your workspace by going to https://<app url on your server>/install
  • Go to your meme channel on Slack and invite Meme Lord by typing /invite @memelord
  • You are now ready to use Meme Lord. See the commands above for how to use.

Licence

MIT