comparison mod_swedishchef/mod_swedishchef.lua @ 1343:7dbde05b48a9

all the things: Remove trailing whitespace
author Florian Zeitz <florob@babelmonkeys.de>
date Tue, 11 Mar 2014 18:44:01 +0100
parents 93ef813dfd06
children 2615facc461b
comparison
equal deleted inserted replaced
1342:0ae065453dc9 1343:7dbde05b48a9
1 -- Copyright (C) 2009 Florian Zeitz 1 -- Copyright (C) 2009 Florian Zeitz
2 -- Copyright (C) 2009 Matthew Wild 2 -- Copyright (C) 2009 Matthew Wild
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 7
8 local trigger_string = module:get_option_string("swedishchef_trigger"); 8 local trigger_string = module:get_option_string("swedishchef_trigger");
9 trigger_string = (trigger_string and trigger_string .. " ") or ""; 9 trigger_string = (trigger_string and trigger_string .. " ") or "";
10 10
11 local chef = { 11 local chef = {
12 { th = "t" }, 12 { th = "t" },
13 13
14 { ow = "o"}, 14 { ow = "o"},
15 {["([^%w])o"] = "%1oo", 15 {["([^%w])o"] = "%1oo",
16 O = "Oo"}, 16 O = "Oo"},
17 17
27 { i = function () return select(math.random(2), "i", "ee"); end }, 27 { i = function () return select(math.random(2), "i", "ee"); end },
28 28
29 {a = "e", A = "E"}, 29 {a = "e", A = "E"},
30 30
31 {["e([^%w])"] = "e-a%1"}, 31 {["e([^%w])"] = "e-a%1"},
32 {f = "ff"}, 32 {f = "ff"},
33 33
34 {v = "f", V = "F"}, 34 {v = "f", V = "F"},
35 {w = "v", W = "V"} }; 35 {w = "v", W = "V"} };
36 36
37 function swedish(english) 37 function swedish(english)
38 local eng, url = english:match("(.*)(http://.*)$"); 38 local eng, url = english:match("(.*)(http://.*)$");
39 if eng then english = eng; end 39 if eng then english = eng; end
40 40
41 for _,v in ipairs(chef) do 41 for _,v in ipairs(chef) do
50 return tostring(english..((url and url) or "")); 50 return tostring(english..((url and url) or ""));
51 end 51 end
52 52
53 function check_message(data) 53 function check_message(data)
54 local origin, stanza = data.origin, data.stanza; 54 local origin, stanza = data.origin, data.stanza;
55 55
56 local body, bodyindex; 56 local body, bodyindex;
57 for k,v in ipairs(stanza) do 57 for k,v in ipairs(stanza) do
58 if v.name == "body" then 58 if v.name == "body" then
59 body, bodyindex = v, k; 59 body, bodyindex = v, k;
60 end 60 end
61 end 61 end
62 62
63 if not body then return; end 63 if not body then return; end
64 body = body:get_text(); 64 body = body:get_text();
65 65
66 if body and (body:find(trigger_string, 1, true) == 1) then 66 if body and (body:find(trigger_string, 1, true) == 1) then
67 module:log("debug", body:find(trigger_string, 1, true)); 67 module:log("debug", body:find(trigger_string, 1, true));
68 stanza[bodyindex][1] = swedish(body:gsub("^" .. trigger_string, "", 1)); 68 stanza[bodyindex][1] = swedish(body:gsub("^" .. trigger_string, "", 1));
69 end 69 end
70 end 70 end