GitXplorerGitXplorer
b

LazySusan

public
3 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
b2718cd12c0de5b0da2e23c4f7ef4b78daa34c45

Merge pull request #4 from mpirnat/theme-plugin

bbboe committed 12 years ago
Unverified
0e4209f9a7091ea5afff2047806bd24f92f111fe

Small tweaks to make flake8 happy

mmpirnat committed 12 years ago
Unverified
6f28923d80d23477c6d3082fd84299b82d6c07e8

Adds a plugin for managing a room's theme

mmpirnat committed 12 years ago
Unverified
3af8ade133e51c678968e9ab5a5aa645a2aed995

Fix lint issues with the dynamic_generator code.

bbboe committed 12 years ago
Unverified
6136c3e15873151732ca9d650d2f4eabaa70c89e

Create initial dynamic_permissions command decorator.

bbboe committed 12 years ago
Unverified
6aaf57ab6eb9566dfab435b6664f967a0fde00b0

Add additional docstrings to botdj plugin.

bbboe committed 12 years ago

README

The README file for this repository.

LazySusan is a pluginable bot for turntable.fm.

Setup

  1. Install the package

     pip install lazysusan
    
  2. Copy lazysusan-sample.ini to lazysusan.ini.

  3. Update lazysusan.ini to include your connection information as per these instructions.

  4. Launch lazysusan

     lazysusan
    

Specifying Additional Configuration Sections

In your lazysusan.ini you can add additional configuration sections and select one of those selections when you start lazysusan. Say for example you want to only load the echo plugin. You might define the following section:

[echo_only]
plugins: simple.Echo

Then launch lazysusan via:

lazysusan -c echo_only

Writing Your Own Plugins

Here we will describe how to write the plugins sample.Sample and sample.CommandSample.

Create the file sample.py.

You can save this file in any directory, just remember the path to the file.

Copy the following contents into the file:

from lazysusan.plugins import CommandPlugin, Plugin


class Sample(Plugin):
    """A plugin that outputs information about the songs that begin playing."""
    def __init__(self, *args, **kwargs):
        super(Sample, self).__init__(*args, **kwargs)
        print('Sample loaded!')
        self.register('newsong', self.handle_newsong)

    def handle_newsong(self, data):
        song_info = data['room']['metadata']['current_song']
        print('{0} started playing playing "{1}" by {2}'
              .format(song_info['djname'], song_info['metadata']['song'],
                      song_info['metadata']['artist']))


class CommandSample(CommandPlugin):
    """A plugin to demonstrate how to create commands."""
    COMMANDS = {'/test': 'test'}

    def __init__(self, *args, **kwargs):
        super(CommandSample, self).__init__(*args, **kwargs)
        print('CommandSample loaded!')

    def test(self, message, data):
        """The help message for the command /test."""
        print('The test command was called')

Update your lazysusan.ini to indicate you want to load your new plugins:

plugins: sample.Sample
         sample.CommandSample

Run lazysusan and specify the directory containing your plugins:

lazysusan -p /path/to/plugin/directory

Join the room the bot is running in and verify the plugins work:

First send the message /commands to the bot via pm (or room chat) and verify that /test is included in the list.

Then send /test and notice that the message The test command was called should appear in your terminal.

Finally you should see messages in your terminal when new songs start playing.