Thu, 09 Jul 2015 14:38:17 +0200
plugins.xkcd2: Allow negative numbers in pattern
0 | 1 | local st = require "util.stanza"; |
2 | ||
3 | local xmlns_version = "jabber:iq:version"; | |
4 | ||
5 | function riddim.plugins.version(bot) | |
6 | bot.stream:add_plugin("version"); | |
7 | bot.stream.version:set{ | |
76 | 8 | name = bot.config.bot_name or "Riddim"; |
9 | version = bot.config.bot_version or "alpha"; | |
10 | platform = bot.config.bot_platform or _VERSION; | |
0 | 11 | }; |
12 | ||
105
4234c8789cc6
plugins.{ping,version,resolvejid}: Break nickname/jid resolving into a common plugin
Kim Alvefur <zash@zash.se>
parents:
76
diff
changeset
|
13 | bot:add_plugin("resolvejid"); |
0 | 14 | bot:hook("commands/version", function (command) |
37
85b3f2a96edb
plugins.version: Report own version in first person, and don't crash if it's not in a room
Kim Alvefur <zash@zash.se>
parents:
33
diff
changeset
|
15 | local who, param = bot.stream.jid, command.param; |
0 | 16 | if param then |
105
4234c8789cc6
plugins.{ping,version,resolvejid}: Break nickname/jid resolving into a common plugin
Kim Alvefur <zash@zash.se>
parents:
76
diff
changeset
|
17 | who = bot:resolvejid(param, command.room); |
0 | 18 | end |
19 | ||
16 | 20 | bot.stream:query_version(who, function (reply) |
21 | if not reply.error then | |
37
85b3f2a96edb
plugins.version: Report own version in first person, and don't crash if it's not in a room
Kim Alvefur <zash@zash.se>
parents:
33
diff
changeset
|
22 | local saywho = (who == command.sender.jid and "You are") or (param and param.." is" or "I am"); |
16 | 23 | command:reply(saywho.." running "..(reply.name or "something") |
24 | .." version "..(reply.version or "unknown") | |
25 | .." on "..(reply.platform or "an unknown platform")); | |
26 | else | |
27 | local type, condition, text = reply.type, reply.condition, reply.text; | |
28 | local r = "There was an error requesting "..param.."'s version"; | |
29 | if condition == "service-unavailable" then | |
30 | r = param.." doesn't reply to version requests"; | |
31 | elseif condition == "feature-not-implemented" then | |
113
5f2418fb8b19
plugins.version: example.com doesn't support *version* requests, not feature requests
Kim Alvefur <zash@zash.se>
parents:
105
diff
changeset
|
32 | r = param.." doesn't support version requests"; |
16 | 33 | elseif condition == "remote-server-not-found" then |
34 | r = param.." can't be reached via XMPP"; | |
35 | elseif condition and not text then | |
36 | r = r..": "..condition; | |
0 | 37 | end |
16 | 38 | if text then |
39 | r = r .. " ("..text..")"; | |
40 | end | |
41 | command:reply(r); | |
42 | end | |
43 | end); | |
0 | 44 | return true; |
45 | end); | |
46 | end |