GithubHelp home page GithubHelp logo

eizzek's Introduction

Eizzek Bot

Eizzek is a simple g-talk bot built on top of Twisted and Wokkel.

To start just execute the command:

make start

To run tests use:

make unit
make functional

Dependencies

  • Twisted
  • Wokkel
  • PyOpenSSL
  • py.test
  • lxml
  • redis

config.py

You need to create a config.py file with some variables:

JID = '[email protected]/fun'
PASSWORD = 'secret'
SERVER = 'talk.google.com'
PORT = 5222

Plugins

A plugin is a way to make the bot do something.

Simple Plugins

A simple plugin is just a regex associated with a callabe that returs a defer.Deferred object. There are examples in eizzek/plugins. The first parameter is a dict with connection data (currenty just the message object).

When a message arrives first regex that matches is called.

Session Plugin

A session plugin works a bit different, the client starts a session using the plugin name:

client: math
eizzek: Wellcome to Math plugin

from now on, all the messages are handled by the plugin:

client: 3 + 4
eizzek: 7
client: 4 * 3 - 10 / 2
eizzek: 7
client: end
eizzek: The Math plugin says goodbye

The API is shown below:

@session_plugin
class TranslateSessionPlugin(object):
    name = "translate"
    regex = "^translate (?P<from_language>\w+) (?P<to_language>\w+)$"
    
    def begin(self, connection, from_language, to_language):
        # called when the user types the plugin name
        # returns defer.Deferred()

    def handle(self, connection, message):
        # called for every new message, after begin() was called
        # returns defer.Deferred()
    
    def end(self, connection):
        # called when the user types "end"
        # returns defer.Deferred()

eizzek's People

Contributors

igorsobreira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

andrewsmedina

eizzek's Issues

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.