plugins/tell.lua

changeset 20
4f4d98345952
parent 16
ae69cea97598
parent 13
ff9790b827b7
child 21
be3b031b986d
equal deleted inserted replaced
19:a698d64fc929 20:4f4d98345952
19 if not found then 19 if not found then
20 if(tellings[nick] == nil) then 20 if(tellings[nick] == nil) then
21 tellings[nick] = {}; 21 tellings[nick] = {};
22 end 22 end
23 tellings[nick][#tellings[nick] + 1] = {from=command.sender.nick, msg=msg}; 23 tellings[nick][#tellings[nick] + 1] = {from=command.sender.nick, msg=msg};
24 return "Ok! Will tell " .. nick .. " what you have said!"; 24 return "Ok!";
25 else 25 else
26 if nick == command.sender.nick then 26 if nick == command.sender.nick then
27 return "Are you going crazy!? You are " .. nick .. "!"; 27 return ""Tell yourself.";
28 else 28 else
29 return "Aehm?! ... " .. nick .. " is currently online!"; 29 return "" .. nick .. " is currently online!";
30 end 30 end
31 end 31 end
32 else 32 else
33 return "Sorry, but this command only makes sense if you execute it in a groupchat."; 33 return "This command is only available in groupchats.";
34 end 34 end
35 end); 35 end);
36 36
37 bot:hook("groupchat/joined", function (room) 37 bot:hook("groupchat/joined", function (room)
38 room:hook("occupant-joined", function (occupant) 38 room:hook("occupant-joined", function (occupant)
39 if(tellings[occupant.nick] ~= nil) then 39 if(tellings[occupant.nick] ~= nil) then
40 for _,msg in ipairs(tellings[occupant.nick]) do 40 for _,msg in ipairs(tellings[occupant.nick]) do
41 room:send_message(occupant.nick .. ": Welcome back! " .. msg.from .. " told me, to tell you, \"" .. msg.msg .. "\"."); 41 room:send_message(occupant.nick .. ": Welcome back! " .. msg.from .. " told me, to tell you, \"" .. msg.msg .. "\".");
42 end 42 end
43 tellings[occupant.nick] = nil;
43 end 44 end
44 end); 45 end);
45 end); 46 end);
46 end 47 end
47 48

mercurial