Getting Started with Plugin Writing

A basic plugin - text manipulation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from api import command, message, plugin

def onInit(plugin_in):
    tolower_command = command.command(plugin_in,
        'tolower',
        shortdesc='Convert text to lower case')

    toupper_command = command.command(plugin_in,
        'toupper',
        shortdesc='Convert text to upper case')

    return plugin.Plugin(plugin_in, 'texttools', [tolower_command])

def onCommand(message_in):
    if message_in.command == 'tolower':
        msg = message_in.body.lower()
        return message.Message(body=msg)

    elif message_in.command == 'toupper':
        msg = message_in.body.upper()
        return message.Message(body=msg)