GithubHelp home page GithubHelp logo

slack-meme's Introduction

slack-meme

Post memes to any of your Slack channels with a slash command.

Usage

Built-in Templates

/meme success; we have; a meme bot;

/meme templates shows you the available built-in templates:

Custom Templates

Use your own image by passing its URL as the template:

/meme https://nicolewhite.github.io/images/me.jpg hello; my name is nicole;

NOTE: There's no semicolon at the end of the URL when using a custom template

Preview

Hone your meme skills privately by practicing in the slackbot channel.

How It Works

The memes are posted under a bot in the same channel where /meme was called, where the bot's picture and username are replaced with your own. Because a bot is posting the meme and not you, you will not be able to delete memes once they are sent.

Setup

Slack App

  1. Create a new Slack App at the App creation page.

    Slack App creation

    Name your app with something easy to recognize, for example "Meme". If you are logged into more than one workspace, select one of them as the Development Slack Workspace.

  2. Find your verification token and store it in an environment variable. On the Basic Information page, scroll down to find the "App Credentials" section.

    App credentails

    Copy the value in the "Verification Token" field, and store this value in the environment variable named SLACK_VERIFICATION_TOKEN. If you are going to run this app on the command line, its easy to do in your shell:

    $ export SLACK_VERIFICATION_TOKEN="replace with your token"
    
  3. Add the necessary scopes to your app. On the OAuth & Permissions page, scroll down to find the "Scopes" section. Input users:read into the selection box. Confirm that the scope is listed in the table below, and click "Save Changes".

  4. Create an Incoming Webhook and store its URL in an environment variable. On the Incoming Webhooks page (under Features), slide the toggle to activate incoming webhooks. Click the button to add a new webhook.

    Enable incoming webhooks

    You'll be taken to a page to install your app in your workspace with the permissions required for the incoming webhook. Select a channel (it doesn't matter which one) and click Authorize.

    Authorize installation

    When you return to the Incoming Webhooks page, you'll find a new item in the table. Copy the Webhook URL and store it in another environment variable called SLACK_WEBHOOK_URL.

  5. Find your API token and store it in an enviornment variable. On the Install App page you'll find an Oauth Access Token. This value is used as your API token. Copy it and store it in another environment variable called SLACK_API_TOKEN. Leave the Slack App configuration open, you need to finish by adding the slash command below.

Deploy to Heroku

Heroku is the simplest platform to deploy your application onto. If you have your own hosting you can move onto the next section. If you're developing and running the application locally, at the very least you'll need a public URL where Slack can send requests and ngrok can be very useful for that.

If you don't aleady have an account with Heroku, sign up for free, then click the button:

Deploy

Paste your SLACK_API_TOKEN, SLACK_WEBHOOK_URL, and SLACK_VERIFICATION_TOKEN values into the appropriate config variables.

Configure Heroku app

Click Deploy app. Once finished, the App name field will now be populated if you didn't choose a name upfront.

Finish Slash Command Config

Go to the Slash Command configuration page (under Features). Create a new command and fill in the details.

Create slash command

The Request URL is the root URL for where you deployed the application. If you deployed to Heroku, the is https://you-app-name.herokuapp.com (replace with your own app name).

Save the Slash Command integration.

Update Your Heroku Deployment

To update your deployment with changes from this repository, visit your app's homepage on Heroku and navigate to the section on deploying with Heroku git at https://dashboard.heroku.com/apps/your-app-name/deploy/heroku-git, replacing your-app-name with the name of your app. Follow the instructions there to get the Heroku toolbelt set up. Then:

$ heroku login
$ heroku git:clone -a your-app-name
$ cd your-app-name

Replace your-app-name with the name of your app. Once you have this set up, you can update your app with changes from this repository with the following:

$ git remote add slack-meme https://github.com/nicolewhite/slack-meme
$ git pull --rebase slack-meme master
$ git push heroku master

Deploying with Docker

We've already got a Dockerfile ready to go. The quickest path would be to download this repo, replace the environment variable values in docker-compose.yml, and run docker-compose up.

Development

In order to run this project locally for development, you should first install Pipenv. Once you have the pipenv command line tool available, you don't need to worry about setting up in a virtualenv or managing the dependencies yourself.

Create a .env file in the top level directory of this project. Pipenv will automatically load the values defined into your environment for you. Use the following template and fill in the values with the ones you're using.

SLACK_WEBHOOK_URL=replace_me
SLACK_API_TOKEN=replace_me
SLACK_VERIFICATION_TOKEN=replace_me

Next, use Pipenv to install the project dependencies

$ pipenv install

Lastly, launch the project with the following command. Notice that we've passed the --log-level=debug flag, which will output useful information for development purposes. This shouldn't be used in production.

$ pipenv run gunicorn -b 0.0.0.0:8080 wsgi --log-level=debug

Credits

This uses memegen. Thanks memegen!

slack-meme's People

Contributors

aoberoi avatar coreymckrill avatar jacebrowning avatar jessmartin avatar julienc91 avatar mattbarrio avatar nicolewhite avatar paulbrandt avatar stewpoll avatar tyok avatar wjrogers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-meme's Issues

500 service error when creating a meme

I'm trying this little thing, using the Dockerfile, and I have all set and running.

When I send /meme help in slack, I got a reply, when I send /meme templates I see the list of templates, but when I'm using the command from the README.md : /meme success;we have;a meme bot I have an error :

Darn - that slash command didn't work (error message: `500_service_error`). Manage the command at Slack Meme.

And from docker-compose :

slack-meme_1   | 172.YY.Y.2 - - [19/Jun/2018 13:53:18] "POST / HTTP/1.1" 500 -
nginx          | sm.domain.com XX.XXX.XX.XX - - [19/Jun/2018:13:53:18 +0000] "POST / HTTP/1.1" 500 291 "-" "Slackbot 1.0 (+https://api.slack.com/robots)"

And I don't know where I can see the full error.

I did a tail -f /var/log/**/* /var/log/* within the slack-meme container, but got nothing here.

Where can I see the full error? Is there a place in this app where a log file lives?

Is this memetizer.com?

We're using the Meme Bot for slack, which can be found on memetizer.
They have no link for a repo, or how to contribute... are you affiliated?

update README to reflect new Slack App creation process

this project is great! i'm hoping to use it as an example in a talk, so i'm very thankful for your open source work.

i suggest that we rework the README with updated instructions and screenshots of the Slack App creation process. some of the terminology could be improved as over time the API has changed.

if you're open to contributions, i can send a PR with what i have in mind

Cannot deploy the Heroku

I have tried to deploy the project to Heroku, but the following error appears:

-----> Python app detected
-----> Installing python-3.6.2
-----> Installing pip
-----> Noticed cffi. Bootstrapping libffi.
-----> Installing requirements with pip
       Collecting cryptography==1.7.1 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 1))
         Downloading cryptography-1.7.1.tar.gz (420kB)
       Collecting Flask==0.10.1 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 2))
         Downloading Flask-0.10.1.tar.gz (544kB)
       Collecting idna==2.2 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 3))
         Downloading idna-2.2-py2.py3-none-any.whl (55kB)
       Collecting itsdangerous==0.24 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 4))
         Downloading itsdangerous-0.24.tar.gz (46kB)
       Collecting Jinja2==2.7.3 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 5))
         Downloading Jinja2-2.7.3.tar.gz (378kB)
       Collecting MarkupSafe==0.23 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 6))
         Downloading MarkupSafe-0.23.tar.gz
       Collecting pyOpenSSL==16.2.0 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 7))
         Downloading pyOpenSSL-16.2.0-py2.py3-none-any.whl (43kB)
       Collecting requests==2.12.4 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 8))
         Downloading requests-2.12.4-py2.py3-none-any.whl (576kB)
       Collecting Werkzeug==0.10.4 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 9))
         Downloading Werkzeug-0.10.4-py2.py3-none-any.whl (293kB)
       Collecting wsgiref==0.1.2 (from -r /tmp/build_50dda189b96b1e19942325c9de8a3aa9/nicolewhite-slack-meme-b287f3b/requirements.txt (line 10))
         Downloading wsgiref-0.1.2.zip
           Complete output from command python setup.py egg_info:
           Traceback (most recent call last):
             File "<string>", line 1, in <module>
             File "/tmp/pip-build-skwl3ytb/wsgiref/setup.py", line 5, in <module>
               import ez_setup
             File "/tmp/pip-build-skwl3ytb/wsgiref/ez_setup/__init__.py", line 170
               print "Setuptools version",version,"or greater has been installed."
                                        ^
           SyntaxError: Missing parentheses in call to 'print'
           
           ----------------------------------------
       Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-skwl3ytb/wsgiref/
 !     Push rejected, failed to compile Python app.
 !     Push failed

built-in templates don't work

When I try to use one of the built-in templates, I get the message "that template doesn't exist," and the /meme templates command gives output like this:

`https://memegen.link/templates/aag` Ancient Aliens Guy
`https://memegen.link/templates/ackbar` It's A Trap!
`https://memegen.link/templates/afraid` Afraid to Ask Andy
`https://memegen.link/templates/alwaysonbeat` Drake Always On Beat
`https://memegen.link/templates/ants` Do You Want Ants?
...

Something seems amiss.

500 Internal Server Error

I ran through the setup on the readme page. The templates and preview subcommands work, but the actual /meme command gives me an error like this:

error

Any ideas?

/meme templates returns 500 error

Response when using /meme templates:

<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>

Looks like the memegen api is working alright
https://memegen.link/api/templates/

Custom Templates - Invalid template name

Calling /meme https://nicolewhite.github.io/images/me.jpg; hello; my name is nicole; or any other custom template gives me :

Invalid template name. Try /meme success, or type /meme-list to view all available meme templates.

Any idea what's wrong?

Can't delete memes

Once an image is posted, it is not possible for the regular user who posted it to delete it.

Non-heroku deployment

Hello,

I am happy to know your project. But I have a ubuntu server where I put my cloud services (like bots etc...)
How can I deploy your project on my ubuntu server ?

Thanks

Slackbot can't post memes?

So you can edit slackbot responses so that Slackbot automatically says something when a trigger word or phrase is posted to a channel by anyone else. Tried setting up a /meme command as a response but when slackbot responds, you just see the text. Any way to make it so that Slackbot can respond with memes?

Previewing pictures

If I forgot that success kid looks like, it might would be nice to be able to do /meme success; foo; bar; preview

Meme-list with links? (feature request)

LOVE this. It's just the best.

The only thing I would like to suggest is that, as I don't know ALL the memes (my bad), it'd be handy to have a link to the appropriate http://knowyourmeme.com page when calling up the /meme-list command - as I find myself copying the text, pasting in to Google to check them.

I suppose the best case scenario would be a tiny thumbnail or a grid of thumbnails with links, so at-a-glance you can find the one you're looking for. But either way - making it easier to check or preview the memes would be ace.

โค๏ธ

500 on empty `/meme` command

I just deployed a new app from 6524403.

Running /meme templates produces the expected list of templates.

Running /meme not-a-template produces the expected error:

That template doesn't exist. Type `/meme templates` to see valid templates or provide your own as a URL.

But but running /meme returns:

<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>

Should there be an error message for the empty command?

Custom URLs: Invalid template name

Hello, when I run your example to pull a custom URL: /meme https://nicolewhite.github.io/static/me.jpg; hello; my name is nicole; I get the following error:
Invalid template name. Try /meme success, or type /meme-list to view all available meme templates.

Any idea what happened?

Template error (Python 3 compatibility)

When I type /meme templates, I get a list of templates that looks like this:
memer2

Rather than like this:
memer1

Then, when I run a template (say /meme success;we have;a meme bot) I get the error "Template success doesn't exist. Type /meme templates to see valid templates or provide your own as a URL."

Any idea what's going on with the meme template names?

Thanks!

Getting an Internal Server Error?

First time testing this out in my private slack I received the following:
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN" 500 Internal Server Error Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Tried updating but after "git pull --rebase slack-meme master" I attempted to git push heroku master and I was told the following:

! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://git.heroku.com/cryptic-beyond-96990.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again.

Sorry I'm new at this so would appreciate any help you can give!

Custom Templates

I can't use "Custom Templates", I'm always getting "That template doesn't exist. Type /meme templates to see valid templates or provide your own as a URL." error message

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.