about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--TODO16
-rw-r--r--bot.lua36
2 files changed, 38 insertions, 14 deletions
diff --git a/TODO b/TODO
index 3ebad64..673b2fa 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,15 @@
 have the shell cd for us (we can do this by running sh -c, but making it cd would be better)
 support joining irc channels with keys
-===
-signify what kind of commands we need (we can use b as a prefix?)
-find a name (bed? multihEaD? googlEDocs?)
+support empty lines
+throttle really long messages
+- barring real absurd cases i think the best way to do this would
+- be to cut off any more than N (say ten) messages sent to a channel
+  within any timespan (say, a second)
+  commands with a lot of output (1000 lines, say) will probably be processed
+  by the queue fast enough to just get rid of them
+  this isn't the best possible system but it will work
+support irc auth (configurable USER and also password auth)
+reasonable interop between unicode and non-unicode
+- we can just send bytes as-is, but i think this is unwise. we can
+  *accept* bytes as is, which is fine i think, and then make non-
+  unicode bytes turn into their unicode counterparts
diff --git a/bot.lua b/bot.lua
index 7014eda..db01ba8 100644
--- a/bot.lua
+++ b/bot.lua
@@ -182,7 +182,9 @@ local function handle_ed_rx(state)
 	end
 end
 
-local function irc_connect(loop, host, config)
+local function irc_connect(loop, config)
+	local host = config.host
+
 	local state = {
 		-- IRC output queue (message objects)
 		queue = fifo.new(),
@@ -203,8 +205,10 @@ local function irc_connect(loop, host, config)
 		channels = {},
 	}
 
-	local sock = assert(socket.connect(host))
-	sock:starttls()
+	local sock = assert(socket.connect(host.host, host.port))
+	if host.tls then
+		sock:starttls()
+	end
 
 	loop:wrap(function () irc_dump(state.queue, sock) end)
 	loop:wrap(function ()
@@ -236,14 +240,24 @@ local function irc_connect(loop, host, config)
 
 	loop:wrap(function () handle_ed_rx(state) end)
 	fifo.put(state.queue, { command = "NICK", params = { config.nick } })
-	fifo.put(state.queue, { command = "USER", params = { "ed1bot", "0", "*", ":)" } })
+	-- TODO: config
+	fifo.put(state.queue, {
+		command = "USER",
+		params = { "ed1bot", "0", "*", ":)" },
+	})
 end
 
-local main = cqueues.new()
-if not arg[1] then
-	print("usage: edbot [CONFIG]")
-	os.exit(1)
+do
+	local main = cqueues.new()
+	if not arg[1] then
+		print("usage: edbot [CONFIG]")
+		os.exit(1)
+	end
+
+	local config = assert(dofile(arg[1]))
+
+	main:wrap(function ()
+		irc_connect(main, config)
+	end)
+	assert(main:loop())
 end
-main:wrap(function () irc_connect(main, { host = "localhost", port = 6697 }, dofile(arg[1])) end)
-assert(main:loop())
-return { parse_message = parse_message }