Mercurial > prosody-modules
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 25:ea59a8d98b03 | 26:1fb5b8c20004 |
|---|---|
| 3 -- | 3 -- |
| 4 -- This project is MIT/X11 licensed. Please see the | 4 -- This project is MIT/X11 licensed. Please see the |
| 5 -- COPYING file in the source package for more information. | 5 -- COPYING file in the source package for more information. |
| 6 -- | 6 -- |
| 7 local st = require "util.stanza"; | 7 local st = require "util.stanza"; |
| 8 | |
| 9 local trigger_string = config.get(module.host, "core", "swedishchef_trigger"); | |
| 10 trigger_string = (trigger_string and trigger_string .. " ") or ""; | |
| 8 | 11 |
| 9 local chef = { | 12 local chef = { |
| 10 { th = "t" }, | 13 { th = "t" }, |
| 11 | 14 |
| 12 { ow = "o"}, | 15 { ow = "o"}, |
| 59 end | 62 end |
| 60 | 63 |
| 61 if not body then return; end | 64 if not body then return; end |
| 62 body = body:get_text(); | 65 body = body:get_text(); |
| 63 | 66 |
| 64 if body then | 67 if body and (body:find(trigger_string, 1, true) == 1) then |
| 65 stanza[bodyindex][1] = swedish(body); | 68 module:log("debug", body:find(trigger_string, 1, true)); |
| 69 stanza[bodyindex][1] = swedish(body:gsub("^" .. trigger_string, "", 1)); | |
| 66 end | 70 end |
| 67 end | 71 end |
| 68 | 72 |
| 69 module:hook("message/bare", check_message); | 73 module:hook("message/bare", check_message); |
| 70 | 74 |
