participle extensions are an easy way to add grouped, dynamically loadable commands to the bot. Syntax is simple:
class ClassName < Participle::Extension
match :testcommand, "command", :usage => "A test command for the bot."
| Started GET "/" for 127.0.0.1 at Wed Mar 02 23:19:59 -0500 2011 | |
| Memory usage: 83.5 KB | |
| Processing by NewsController#homepage as HTML | |
| Memory usage: 84.8 KB | |
| Map Load (4.6ms) SELECT `maps`.* FROM `maps` WHERE (featured = 1) ORDER BY maps.id DESC LIMIT 1 | |
| Memory usage: 98.8 KB | |
| News Load (0.4ms) SELECT `news`.* FROM `news` ORDER BY created_at DESC LIMIT 0, 4 |
| grammar Arithmetic | |
| rule sum_operand | |
| mdiv_operand (sumoperator mdiv_operand)* { | |
| def content | |
| expr_cont | |
| end | |
| } | |
| end | |
| rule mdiv_operand |
| 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000@00000000000000000000000000000000000000000000000000000000000000000000000000D00000000000000000000000;00000000000000000000000000000000000000000000000000000000000000000000:000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000|5^372,348!10^408,336!1^390,402!0^396,396!0^396,396!0^396,396!8^396,396,2!9^439,414,1,1,17,17,0,0,-1!8^480,330,1!9^504,372,0,0,21,15,0,-1,0!0^504,372!0^504,372!0^504,372!0^504,372!0^504,372!0^504,372!8^512,312,2!9^605,465,1,1,24,19,0,0,-1!9^620,440,0,1,25,18,0,-1,0!1^642,432!9^636,514,1,1,26,21,0,0,-1 |
| <script type="text/javascript">function count_tiles() { | |
| var str = prompt("Please enter your mapdata:"); | |
| if(str == null || str == "") { return; } | |
| var msg = ""; | |
| var tiles = {"1": '3|4|5|2', "2": 'G|H|I|F', "3": '\\?|@|A|>', "4": '7|8|9|6', "E": '1', "5": 'Q|N|O|P', "6": 'J|K|L|M', "7": 'C|D|E|B', "8": ';|<|=|:', "D": "0"} | |
| var counts = {} | |
| var total = 0 | |
| for (var key in tiles) { | |
| var count = str.split(new RegExp(tiles[key], "g")).length - 1 | |
| msg += ("There are " + count + " '" + key + "' tiles.\n") |
| table["map"] = function (tbl, func) | |
| local newtbl = {} | |
| for k, v in pairs(tbl) do | |
| local key, value = (func)(k, v) | |
| if not value then | |
| value = key | |
| key = #newtbl + 1 | |
| end | |
| newtbl[key] = value | |
| end |
| // | |
| // DDMessageController.h | |
| // dAmnDesktop | |
| // | |
| // Created by Joel on 4/24/11. | |
| // Copyright 2011 __MyCompanyName__. All rights reserved. | |
| // | |
| #import <Cocoa/Cocoa.h> | |
| #include "DDMessageView.h" |
| return { | |
| ["_internal"] = { | |
| ["owner"] = "PrairieEagle", | |
| ["authtoken"] = "leave blank", | |
| ["oauthtoken"] = "leave blank", | |
| ["trigger"] = "!", | |
| ["oauthkey"] = "leave blank", | |
| ["username"] = "username here", | |
| ["rooms"] = { | |
| ["room1"] = 1, |
| module(..., package.seeall) | |
| require("luarocks.require") | |
| local socket = require("socket") | |
| local https = require("ssl.https") | |
| local oauth = {} | |
| function oauth.spawn_server() | |
| oauth.serv = socket.bind("127.0.0.1", 12345) | |
| end |
| module(..., package.seeall) | |
| require("luarocks.require") | |
| local socket = require("socket") | |
| local https = require("ssl.https") | |
| local oauth = {} | |
| function oauth.spawn_server() | |
| oauth.serv = socket.bind("127.0.0.1", 12345) | |
| end |