Giter Club home page Giter Club logo

two-bot's Introduction

Two-bot

Two-bot is a slack bot that counts the number of times a keyword is sent in any channel to witch the bot has been invited.

It's only practical application is to be a game. The game is to call people out for leaving their keyboard unattended, by sending the keyword from their account. Two-bot can show a leaderboard-of-shame with a list of the top victims. It can also tell you the current count for a given user.

Installation

  • Clone the repo
git clone [email protected]:danieljabailey/two-bot.git
  • Initialise the venv
cd two-bot
./initvenv.sh
source venv/bin/activate # or similar, for your shell (e.g. activate.fish)

(This will create a venv and install the dependencies in the venv)

  • Get a bot api key for testing (and optionally another for production)

This is done by going to the new bot page for your slack workspace https://<workspace-name>.slack.com/services/new/bot Pick a username and create the bot user, then copy the api key...

cp config_example.yaml config.yaml
editor config.yaml # paste your api key in the obvious place, and choose a keyword and command
  • Run the bot

Running ./run.sh will activate the venv and run the bot.

REST API

You can get real-time access to the current two statistics via the provided REST API. It runs on 0.0.0.0:2222 by default, but you can change this in the config (or disable it entirely). Below are the methods you can use:

GET /ids

Returns JSON array of user IDs for all the users tracked by two-bot (any user that has been two'd). User IDs are Slack usernames unless they are forwarded from IRC, in which case they are I-<irc nick> (IRC).

GET /leaderboard

Returns a JSON array of objects, in descending order of two's (first element is the object with the most two's). Objects include:

  • id: user ID as per GET /ids.
  • name: Slack username or IRC nick
  • twos: number of times two'd
  • last: timestamp of last two

GET /info/

Returns in-deptth information about the user with id <id>, as JSON object:

  • id: <id> as in URL
  • name: username or IRC nick
  • real_name: Real name from Slack or <irc nick> (IRC).
  • is_bot: True if either this user is an IRC user passed through the IRC bridge or a Slack bot that's been two'd.

GET /twos/

Returns information about when this user was last two'd, as JSON object:

  • id: <id> as in URL
  • twos: number of times two'd
  • last: timestamp of last two

Will fail with 404 not found if an ID is passed that doesn't match a user (Even if that user is in Slack).

GET /uptime

Returns information about how long the application has been running, as JSON object:

  • starttime: timestamp of when the application was started (UTC, in floating-point seconds)
  • starttime_s: ISO representation of starttime
  • duration: Seconds since starttime (floating-point)

Licence

published under the MIT licence, see LICENSE (with an "S")

two-bot's People

Contributors

lexbailey avatar lukemoll avatar

Watchers

 avatar  avatar

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.