Code Monkey home page Code Monkey logo

pancake-hipchat-bot's Introduction

Pancake HipChat bot

Simple bot created for fun. There is also the unsupported version for Campfire

Install and run

pip install -r requirements.txt
./pancake.py -c example.conf

Also you need to create an API key in HipChat administration panel and paste it in Pancake config file. Please note: it must be HipChat API version 1 key.

Plugins:

There are some builtin plugins enabled by default:

  • get random cat gif (thank you thecatapi.com)
  • get random Chuck's geek phrase (thanks api.icndb.com)
  • get random pony picture (thanks ponyfac.es)
  • play Rock-Paper-Scissors-Lizard-Spock
  • blame somebody
  • roll number from 0 to 100
  • get random Arnold Schwarzenegger's phrase
  • get random XKCD comics
  • get random gif by keyword (thank you giphy)
  • get random LEGO Movie quotes
  • ask bot a question
  • generate a meme (thanks memecaptain.com and sassy bot)

Type /help to see all available commands and detailed description

Plugins development

To create a plugin simply create python file in /plugins directory like awesome.py or create a subfolder there with __init__.py file like /awesome/__init__.py. This will be a main file for your plugin.

Then you will need to create a plugin class in the main plugin file. The plugin class must have two attributes: command and help and method response.

The command attribute will be used to bind the plugin. Each time Pancake will see /<command> in chat room, it will execute response method of your plugin.

If you want to add any configuration parameters you will need to create a constructor for your class with conf argument like def __init__(self, conf). Plugin loader will inject the configuration from the .conf file specified during Pancake launch. For example you can have a look on plugins/geckoboard.py.

response method

Your plugin must have response method which can be static or not. Message which contains the command you specified as an argument for your plugin class will trigger execution of response method.

Plugin loader will inject arguments you specified for this method. The list of arguments that can be injected:

  • room - room name where triggered action appeared
  • author_id - the id of author who posted message which triggered the action
  • author - message author’s name
  • message - the message itself that triggered the action
  • random_user - random user in the room (@username)
  • mentioned_user - the first mentioned user in the message that triggered the action

response method must return value. It can be a string (single message) or list (array of message to post). This value will be posted to HipChat room by Pancake bot.

Example:

def response(message, author):
    formattedMessage = self.doSomethingWithMessage(message)
    ...
    if somethingWrong:
        return author + ‘, something wrong!’
	
	return formattedMessage

License

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pancake-hipchat-bot's People

Contributors

idooo 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.