37 io.write(data, patt == "*l" and "\n" or ""); |
37 io.write(data, patt == "*l" and "\n" or ""); |
38 end |
38 end |
39 return data; |
39 return data; |
40 end |
40 end |
41 }; |
41 }; |
|
42 local stwrap; |
|
43 do |
|
44 local f_mt, r_mt = {}, {}; |
|
45 function f_mt:__call(...) if ... and type(...) == "string" then return self{ to=... } end return self._f(...) end |
|
46 function f_mt:__index(k) return setmetatable({_st = self._f{ type = k }}, r_mt); end |
|
47 function r_mt:__call(to) self._st.attr.to = to; return self._st end |
|
48 function stwrap(f) return setmetatable({_f=f},f_mt) end |
|
49 end |
42 local env = setmetatable({}, { __index = { |
50 local env = setmetatable({}, { __index = { |
43 s = verse.stanza, |
51 s = verse.stanza, |
44 m = verse.message, |
52 m = stwrap(verse.message), |
45 p = verse.presence, |
53 p = stwrap(verse.presence), |
46 iq = verse.iq, |
54 iq = stwrap(verse.iq), |
47 ping = function(host) |
55 ping = function(host) |
48 return verse.iq{ type="get", to=host}:tag("ping", {xmlns="urn:xmpp:ping"}); |
56 return verse.iq{ type="get", to=host}:tag("ping", {xmlns="urn:xmpp:ping"}); |
49 end, |
57 end, |
50 }}); |
58 }}); |
51 local function on_incoming(stdin, data) |
59 local function on_incoming(stdin, data) |