Code Monkey home page Code Monkey logo

bomberman's Introduction

bomberman

๐Ÿ’ฃ A slack bot that gets images and post them

Sending a Slash Command like this:

bomberman-slack-slash-command

Results in this:

command-response

This project is heavly inspired by hubot's pugme, for more info look here.

How to install bomberman into your Slack workspace

See the tutorial here.

How to use it on your workspace

Just send a /bomberman [breed/race] [quantity] Slash command message on to the channel you've configured bomberman, to receive the cute animals pictures ๐Ÿ˜‰

Some examples:

/bomberman pug 2
/bomberman shiba 5

For now this project only works for dogs, and the list of the accepted breeds is here.

Technology and inner workings

This project is using Clojure with http-kit to create a HTTP server that runs on port 8080.

It doesn't have a database, the only external thing it has is where it requests animal images.

There is only one possible route, which is POST /, it accepts form-encoded, data which is the format sent by Slack.

It reads from the request the Slack username, the animal breed/race and the quantity of images.

If the quantity is greater than 5, it will send a message warning that there is a limit.

Get's the data on the https://dog.ceo API and sends the images to Slack.

After everything, it just sends a 200 status code to Slack, so it knows nothing is wrong.

Running the project

Before everything, you will need to create a .env file containing a line with the Slack URL bomberman will use to actually send messages to a channel. On this repository there is a file called .env.example to show how this file should be. To actually get the Slack URL look at this part of the INSTALLATION.md tutorial.

To run the project you will need either leiningen or Docker.

Leiningen

lein run

Docker

docker build -t bomberman .
docker run -it --rm -p 8080:8080 bomberman

License

You can check out the full license here

This project is licensed under the terms of the WTFPL license. You just DO WHAT THE FUCK YOU WANT TO.

bomberman's People

Contributors

evaporei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bomberman's Issues

Add validation layer

Every field passed to bomberman should be validated with something like schema or spec.

Add quantity limit

If an user puts quantity of 1000, the bot will post 1000 messages on the Slack channel, that is way too much. A quantity like 20 is probably enough.

Make messages mark people

Nowadays the messages posted to Slack just post a plain text @username, however it doesn't notify who's being marked.

Refactor code to make it more understandable

The code is very spaghetti ๐Ÿ .
It should be more organized. Doing stuff like:

  • Setting all variables like quantity, race, username before hand on the request-handler and do all operations needed, like posting the first message, doing the loop to post stuff;
  • Move all SNI HTTP client related code to another file;
  • Move request handler to another file, and let only the server startup on core.clj;

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.