Use aliases
authorMikael Berthe <mikael@lilotux.net>
Thu, 15 Apr 2010 20:28:34 +0200
changeset 20 d6c602aaa231
parent 19 96e08713cb6a
child 21 bc5d611e6d6f
Use aliases
mcbot/cmds/mcabber_bts.lua
mcbot/cmds/misc.lua
--- a/mcbot/cmds/mcabber_bts.lua	Thu Apr 15 20:22:36 2010 +0200
+++ b/mcbot/cmds/mcabber_bts.lua	Thu Apr 15 20:28:34 2010 +0200
@@ -1,7 +1,9 @@
 
 require "libs.shcmd"
 
-local mcabber_bts = { ["desc"] = "Query mcabber (crew) BTS" }
+local mcabber_bts = { ["desc"] = "Query mcabber (crew) BTS",
+                      ["aliases"] = { "bug", "issue" }
+                    }
 
 local function get_issue_details (num)
     local item
@@ -53,5 +55,3 @@
 end
 
 mcbot_register_command("bts", mcabber_bts)
-mcbot_register_command("bug", mcabber_bts)
-mcbot_register_command("issue", mcabber_bts)
--- a/mcbot/cmds/misc.lua	Thu Apr 15 20:22:36 2010 +0200
+++ b/mcbot/cmds/misc.lua	Thu Apr 15 20:28:34 2010 +0200
@@ -1,10 +1,10 @@
 
 local hello = { ["hidden"] = true,
+                ["aliases"] = { "hi" },
                 ["cmd"] = function (args) return "Hello!" end
               }
 
 mcbot_register_command("hello", hello)
-mcbot_register_command("hi", hello)
 
 
 local thanks = { ["hidden"] = true,
@@ -14,7 +14,12 @@
 mcbot_register_command("thanks", thanks)
 
 
-local ping = { ["cmd"] = function (args) return "pong" end }
+local ping = {}
+ping.aliases = { "ding" }
+ping.cmd = function (args, botdata, cmd)
+    if cmd:lower() == "ding" then return "dong" end
+    return "pong"
+end
 
 mcbot_register_command("ping", ping)