From 8f8feb00d7ea892115f76df86d8ce1e71d8e536f Mon Sep 17 00:00:00 2001 From: Jakob Ovrum Date: Sat, 17 Jul 2010 11:43:17 +0900 Subject: [PATCH] added topic hooks --- init.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 66736d0..fb706ac 100644 --- a/init.lua +++ b/init.lua @@ -7,8 +7,7 @@ local unpack = unpack local pairs = pairs local assert = assert local require = require - -local print = print +local tonumber = tonumber module "irc" @@ -217,8 +216,23 @@ handlers["366"] = function(o, prefix, me, channel, msg) end end +--no topic +handlers["331"] = function(o, prefix, me, channel) + o:invoke("OnTopic", channel, nil) +end + +--new topic handlers["TOPIC"] = function(o, prefix, channel, topic) - o:invoke("TopicChange", channel, topic) + o:invoke("OnTopic", channel, topic) +end + +handlers["332"] = function(o, prefix, me, channel, topic) + o:invoke("OnTopic", channel, topic) +end + +--topic creation info +handlers["333"] = function(o, prefix, me, channel, nick, time) + o:invoke("OnTopicInfo", channel, nick, tonumber(time)) end handlers["ERROR"] = function(o, prefix, message) @@ -272,3 +286,7 @@ function meta:whois(nick) return result end +function meta:topic(channel) + self:send("TOPIC %s", channel) +end +