Mercurial > prosody-modules
diff mod_swedishchef/mod_swedishchef.lua @ 26:1fb5b8c20004
mod_swedishchef: Added configurable trigger
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Tue, 06 Oct 2009 22:00:05 +0200 |
parents | 8d49732cf7dc |
children | 93ef813dfd06 |
line wrap: on
line diff
--- a/mod_swedishchef/mod_swedishchef.lua Fri Oct 02 22:16:19 2009 +0100 +++ b/mod_swedishchef/mod_swedishchef.lua Tue Oct 06 22:00:05 2009 +0200 @@ -6,6 +6,9 @@ -- local st = require "util.stanza"; +local trigger_string = config.get(module.host, "core", "swedishchef_trigger"); +trigger_string = (trigger_string and trigger_string .. " ") or ""; + local chef = { { th = "t" }, @@ -61,8 +64,9 @@ if not body then return; end body = body:get_text(); - if body then - stanza[bodyindex][1] = swedish(body); + if body and (body:find(trigger_string, 1, true) == 1) then + module:log("debug", body:find(trigger_string, 1, true)); + stanza[bodyindex][1] = swedish(body:gsub("^" .. trigger_string, "", 1)); end end