From 6fec1265c14124ceda8d45a736fdd0132f84ad9f Mon Sep 17 00:00:00 2001 From: equa Date: Sat, 27 Aug 2022 04:25:16 +0000 Subject: fix SIGPIPE and silly typo with overlong line protection --- bot.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bot.lua b/bot.lua index 18faea1..66e3d12 100644 --- a/bot.lua +++ b/bot.lua @@ -1,5 +1,6 @@ local cqueues = require("cqueues") local socket = require("cqueues.socket") +local signal = require("cqueues.signal") local fs = require("fs") @@ -77,7 +78,7 @@ end local function irc_dump(fifo, socket) for data in fifo:iter() do data = emit_message(data) - if not string.match(data, "[\r\n]") and #string <= 510 then + if not string.match(data, "[\r\n]") and #data <= 510 then socket:write(data .. "\r\n") end end @@ -238,7 +239,15 @@ local function irc_connect(loop, config) local command = (tonumber(line.command) and "_" or "") .. line.command if irc_handlers[command] then - irc_handlers[command](state, line) + local ok, err = pcall( + irc_handlers[command], + state, + line + ) + + if not ok then + print(err) + end end end @@ -303,6 +312,7 @@ local function validate_config(c) end do + signal.ignore(signal.SIGPIPE) local main = cqueues.new() if not arg[1] then print("usage: edbot [CONFIG]") -- cgit 1.3.0-6-gf8a5