init.lua

Mon, 06 Dec 2021 11:27:16 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 06 Dec 2021 11:27:16 +0000
changeset 167
2073137bc943
parent 152
902544037000
child 170
eae589a33624
permissions
-rw-r--r--

rtbl_admin: Notify subscribers on item removal (requires verse 98dc1750584d)

0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local verse = require "verse";
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local st = require "util.stanza";
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 module("riddim", package.seeall);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 plugins = {};
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local riddim_mt = {};
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 riddim_mt.__index = riddim_mt;
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 function new(stream, config)
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 if not stream then
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 error("riddim.new(): Verse stream required as first parameter", 2);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end
3
d1a9fb6495c6 Don't allow loading the same plugin more than once
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
14 return setmetatable({ stream = stream, config = config or {}, plugins = {} }, riddim_mt);
0
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
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 -- self.conn is ready for stanzas
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 function riddim_mt:start()
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 self.stream:hook("stanza", function (stanza)
16
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
20 local body = stanza:get_child("body");
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
21 local event = {
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
22 sender = { jid = stanza.attr.from };
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
23 body = (body and body:get_text()) or nil;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
24 stanza = stanza;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
25 };
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
26 if stanza.name == "message" then
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
27 local replied;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
28 local bot = self;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
29 function event:reply(reply)
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
30 if replied then return false; end
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
31 replied = true;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
32 return bot:send_message(stanza.attr.from, stanza.attr.type, reply);
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 end
16
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
34 end
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
35 local ret;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
36 if stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
37 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
38 if xmlns then
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
39 event.xmlns = xmlns;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
40 ret = self:event("iq/"..xmlns, event);
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 end
16
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
42 end
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
43 if not ret then
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
44 ret = self:event(stanza.name, event);
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
45 end
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
46 if ret and type(ret) == "table" and ret.name then
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
47 self:send(ret);
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
48 end
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
49 return ret;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
50 end, 1);
17
9fe723988f3c Fire started event at the end of startup routine
Chris <jugg@hotmail.com>
parents: 16
diff changeset
51 self:event("started");
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 function riddim_mt:send(s)
28
d0d1d88ec0ef init.lua: Don't tostring() stanzas before passing to Verse, in case we ever support filters. Also add send_iq() to bot object.
Matthew Wild <mwild1@gmail.com>
parents: 24
diff changeset
55 return self.stream:send(s);
d0d1d88ec0ef init.lua: Don't tostring() stanzas before passing to Verse, in case we ever support filters. Also add send_iq() to bot object.
Matthew Wild <mwild1@gmail.com>
parents: 24
diff changeset
56 end
d0d1d88ec0ef init.lua: Don't tostring() stanzas before passing to Verse, in case we ever support filters. Also add send_iq() to bot object.
Matthew Wild <mwild1@gmail.com>
parents: 24
diff changeset
57
d0d1d88ec0ef init.lua: Don't tostring() stanzas before passing to Verse, in case we ever support filters. Also add send_iq() to bot object.
Matthew Wild <mwild1@gmail.com>
parents: 24
diff changeset
58 function riddim_mt:send_iq(s, callback, errback)
d0d1d88ec0ef init.lua: Don't tostring() stanzas before passing to Verse, in case we ever support filters. Also add send_iq() to bot object.
Matthew Wild <mwild1@gmail.com>
parents: 24
diff changeset
59 return self.stream:send_iq(s, callback, errback);
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 function riddim_mt:event(name, ...)
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 return self.stream:event("bot/"..name, ...);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 function riddim_mt:hook(name, ...)
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 return self.stream:hook("bot/"..name, ...);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69
15
22e6c003a83a Reply to messages with the same (the incoming) message type
Chris <jugg@hotmail.com>
parents: 14
diff changeset
70 function riddim_mt:send_message(to, type, text)
22e6c003a83a Reply to messages with the same (the incoming) message type
Chris <jugg@hotmail.com>
parents: 14
diff changeset
71 self:send(st.message({ to = to, type = type }):tag("body"):text(text));
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73
18
d7cd7ce93132 Rudimentary presence plugin to auto-accept subscription requests
Chris <jugg@hotmail.com>
parents: 17
diff changeset
74 function riddim_mt:send_presence(to, type)
d7cd7ce93132 Rudimentary presence plugin to auto-accept subscription requests
Chris <jugg@hotmail.com>
parents: 17
diff changeset
75 self:send(st.presence({ to = to, type = type }));
d7cd7ce93132 Rudimentary presence plugin to auto-accept subscription requests
Chris <jugg@hotmail.com>
parents: 17
diff changeset
76 end
d7cd7ce93132 Rudimentary presence plugin to auto-accept subscription requests
Chris <jugg@hotmail.com>
parents: 17
diff changeset
77
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 function riddim_mt:add_plugin(name)
3
d1a9fb6495c6 Don't allow loading the same plugin more than once
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
79 if not self.plugins[name] then
d1a9fb6495c6 Don't allow loading the same plugin more than once
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
80 self.plugins[name] = require("riddim.plugins."..name);
d1a9fb6495c6 Don't allow loading the same plugin more than once
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
81 return riddim.plugins[name](self);
d1a9fb6495c6 Don't allow loading the same plugin more than once
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
82 end
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 -- Built-in bot starter
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 if not (... and package.loaded[...] ~= nil) then
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 require "verse.client";
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 -- Config loading
148
9245b1d8a818 init.lua: Update for Lua 5.2 (only)
Matthew Wild <mwild1@gmail.com>
parents: 96
diff changeset
90 local config = setmetatable({}, { __index = _G });
149
de10599d1ed4 init.lua: Allow override of default config path
Matthew Wild <mwild1@gmail.com>
parents: 148
diff changeset
91 local chunk, err = loadfile(arg[1] or "config.lua", "t", config);
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 if not chunk then
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 print("File or syntax error:", err);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 return 1;
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 local ok, err = pcall(chunk);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 if not ok then
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 print("Error while processing config:", err);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 return 1;
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 setmetatable(config, nil);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 if not config.jid then
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 io.write("Enter the bot's JID: ");
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 config.jid = io.read("*l");
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 if not config.password then
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 io.write("Enter the password for "..config.jid..": ");
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 config.password = io.read("*l");
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 end
152
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
113
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
114 -- Initialize the HTTP client
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
115 local http = require "net.http";
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
116 http.default.options.sslctx = {
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
117 mode = "client";
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
118 protocol = "sslv23";
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
119 capath = config.capath or "/etc/ssl/certs";
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
120 cafile = config.cafile;
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
121 verify = "peer";
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
122 };
902544037000 init.lua: Initialize net.http with an SSL configuration
Matthew Wild <mwild1@gmail.com>
parents: 149
diff changeset
123
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 -- Create the stream object and bot object
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 local c = verse.new();
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 local b = riddim.new(c, config);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 if config.debug then
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 c:hook("incoming-raw", print);
95
6b3ee06d5837 init.lua: Print outgoing stanzas and all log messages when debug logging enabled
Kim Alvefur <zash@zash.se>
parents: 74
diff changeset
130 c:hook("outgoing-raw", print);
6b3ee06d5837 init.lua: Print outgoing stanzas and all log messages when debug logging enabled
Kim Alvefur <zash@zash.se>
parents: 74
diff changeset
131 verse.set_log_handler(print);
96
c2c30f94e619 init.lua: Print 'info', 'warn', and 'error' loglevels by default.
Kim Alvefur <zash@zash.se>
parents: 95
diff changeset
132 else
c2c30f94e619 init.lua: Print 'info', 'warn', and 'error' loglevels by default.
Kim Alvefur <zash@zash.se>
parents: 95
diff changeset
133 verse.set_log_handler(print, {"info","warn","error"});
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135
14
3df63aaba9e3 Decouple plugins from base implementation (in particular no plugins are now loaded by default)
Chris <jugg@hotmail.com>
parents: 11
diff changeset
136 for _, plugin in ipairs(config.plugins or {}) do
2
6b31cc678fd7 Add configured plugins to the bot instead of the stream
Matthew Wild <mwild1@gmail.com>
parents: 1
diff changeset
137 b:add_plugin(plugin);
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139
74
65be10a5db6d init.lua: Add config option to load verse plugins directly
Kim Alvefur <zash@zash.se>
parents: 28
diff changeset
140 for _, plugin in ipairs(config.stream_plugins or {}) do
65be10a5db6d init.lua: Add config option to load verse plugins directly
Kim Alvefur <zash@zash.se>
parents: 28
diff changeset
141 c:add_plugin(plugin);
65be10a5db6d init.lua: Add config option to load verse plugins directly
Kim Alvefur <zash@zash.se>
parents: 28
diff changeset
142 end
65be10a5db6d init.lua: Add config option to load verse plugins directly
Kim Alvefur <zash@zash.se>
parents: 28
diff changeset
143
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 b:hook("started", function ()
6
b0fec41e695b initial implementation of disco responses (XEP-0030) and entity caps sending (XEP-0115)
Hubert Chathi <hubert@uhoreg.ca>
parents: 5
diff changeset
145 local presence = verse.presence()
b0fec41e695b initial implementation of disco responses (XEP-0030) and entity caps sending (XEP-0115)
Hubert Chathi <hubert@uhoreg.ca>
parents: 5
diff changeset
146 if b.caps then
b0fec41e695b initial implementation of disco responses (XEP-0030) and entity caps sending (XEP-0115)
Hubert Chathi <hubert@uhoreg.ca>
parents: 5
diff changeset
147 presence:add_child(b:caps())
b0fec41e695b initial implementation of disco responses (XEP-0030) and entity caps sending (XEP-0115)
Hubert Chathi <hubert@uhoreg.ca>
parents: 5
diff changeset
148 end
11
7bb53dcf93d4 Fix to send initial presence again
Hubert Chathi <hubert@uhoreg.ca>
parents: 8
diff changeset
149 b:send(presence);
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 end);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151
24
330643a82a1d riddim: Hook Verse's new 'ready' event instead of 'binding-success'
Matthew Wild <mwild1@gmail.com>
parents: 18
diff changeset
152 c:hook("ready", function () b:start(); end);
5
d9ed6e7d9936 allow specifying connect host and port in config file
Hubert Chathi <hubert@uhoreg.ca>
parents: 3
diff changeset
153
16
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
154 if config.connect_host then
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
155 c.connect_host = config.connect_host;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
156 end
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
157 if config.connect_port then
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
158 c.connect_port = config.connect_port;
ae69cea97598 Formatting, indentation and cleanup
Chris <jugg@hotmail.com>
parents: 15
diff changeset
159 end
0
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 c:connect_client(config.jid, config.password);
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 verse.loop();
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 end
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165
7d84f4403d67 Initial commit, hello world!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 return _M;

mercurial