summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-07-22 22:02:07 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-07-22 22:02:07 (GMT)
commit279cb1e98855e681e09e4215608083413454a0f6 (patch)
tree0a3b21d8603004724fe8c9372c476aa5160e8278 /Swiftob/scripts
parentc3c24fd8fb8f91696b4e38e0f212a35a8e1fe137 (diff)
downloadswift-contrib-279cb1e98855e681e09e4215608083413454a0f6.zip
swift-contrib-279cb1e98855e681e09e4215608083413454a0f6.tar.bz2
Start of a log script (for pisg) for Swiftob bots
Diffstat (limited to 'Swiftob/scripts')
-rw-r--r--Swiftob/scripts/irssiLogs.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/Swiftob/scripts/irssiLogs.lua b/Swiftob/scripts/irssiLogs.lua
new file mode 100644
index 0000000..3cecd9d
--- /dev/null
+++ b/Swiftob/scripts/irssiLogs.lua
@@ -0,0 +1,23 @@
+function irssi_log_to_file(muc, line)
+ filename = muc:gsub("@", "_at_")
+ filename = filename:gsub("%.%.", "_")
+ filename = filename:gsub("/", "_")
+ filename = filename:gsub("\\", "_")
+ file = io.open(filename, "a+")
+ if file == nil then
+ io.close()
+ else
+ file:write(line)
+ file:write("\n")
+ file:close()
+ end
+
+end
+
+function irssi_log_message(body, muc, nick, message)
+ time = os.date("%H:%M")
+ irssi_log_to_file(muc, time.." <"..nick.."> "..body)
+end
+
+swiftob_register_listener(irssi_log_message)
+