Wed, 23 Dec 2009 01:00:13 +0000
plugins.ping: Update to handle errors passed from Verse
0 | 1 | |
2 | function riddim.plugins.ping(bot) | |
3 | bot.stream:add_plugin("ping"); | |
4 | bot:hook("commands/ping", function (command) | |
5 | local jid = command.param; | |
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 | 13 | end); |
14 | return true; | |
15 | end | |
16 | return "pong"; | |
17 | end); | |
18 | end |