# HG changeset patch # User Thilo Cestonaro # Date 1273843103 -3600 # Node ID 77753bce939a622ca355c9113a2db96a2b961273 # Parent 8c3bec93087bd0f41dc32cc61c676c96c372b36a tell.lua: prevent executing the command in a non-groupchat environment. diff -r 8c3bec93087b -r 77753bce939a plugins/tell.lua --- a/plugins/tell.lua Thu Mar 18 14:16:05 2010 +0100 +++ b/plugins/tell.lua Fri May 14 14:18:23 2010 +0100 @@ -3,30 +3,34 @@ function riddim.plugins.tell(bot) bot:hook("commands/tell", function (command) - local s, e = command.param:find(" "); - local nick = command.param:sub(0, s - 1); - local msg = command.param:sub(s + 1); - local found = false; - - for tmp,_ in pairs(command.room.occupants) do - if tmp == nick then - found = true; - break; + if command.room then + local s, e = command.param:find(" "); + local nick = command.param:sub(0, s - 1); + local msg = command.param:sub(s + 1); + local found = false; + + for tmp,_ in pairs(command.room.occupants) do + if tmp == nick then + found = true; + break; + end end - end - if not found then - if(tellings[nick] == nil) then - tellings[nick] = {}; + if not found then + if(tellings[nick] == nil) then + tellings[nick] = {}; + end + tellings[nick][#tellings[nick] + 1] = {from=command.sender.nick, msg=msg}; + return "Ok! Will tell " .. nick .. " what you have said!"; + else + if nick == command.sender.nick then + return "Are you going crazy!? You are " .. nick .. "!"; + else + return "Aehm?! ... " .. nick .. " is currently online!"; + end end - tellings[nick][#tellings[nick] + 1] = {from=command.sender.nick, msg=msg}; - return "Ok! Will tell " .. nick .. " what you have said!"; else - if nick == command.sender.nick then - return "Are you going crazy!? You are " .. nick .. "!"; - else - return "Aehm?! ... " .. nick .. " is currently online!"; - end + return "Sorry, but this command only makes sense if you execute it in a groupchat."; end end);