plugins/ping.lua

Thu, 18 Mar 2010 14:16:05 +0100

author
Thilo Cestonaro <thilo@cestona.ro>
date
Thu, 18 Mar 2010 14:16:05 +0100
changeset 9
8c3bec93087b
parent 4
1eaa469140e9
child 16
ae69cea97598
permissions
-rw-r--r--

groupchat.lua: make the occupant-left event work
tell.lua: double check the room and clear told tellings.

0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 function riddim.plugins.ping(bot)
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 bot.stream:add_plugin("ping");
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 bot:hook("commands/ping", function (command)
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local jid = command.param;
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 if jid then
4
1eaa469140e9 plugins.ping: Update to handle errors passed from Verse
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
7 bot.stream:ping(jid, function (time, jid, error)
1eaa469140e9 plugins.ping: Update to handle errors passed from Verse
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
8 if time then
1eaa469140e9 plugins.ping: Update to handle errors passed from Verse
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
9 command:reply(string.format("Pong from %s in %0.3f seconds", jid, time));
1eaa469140e9 plugins.ping: Update to handle errors passed from Verse
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
10 else
1eaa469140e9 plugins.ping: Update to handle errors passed from Verse
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
11 command:reply("Ping failed ("..(error.condition or "unknown reason")..")"..(error.text and (": "..error.text) or ""));
1eaa469140e9 plugins.ping: Update to handle errors passed from Verse
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
12 end
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 return true;
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 return "pong";
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 end);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 end

mercurial