# HG changeset patch # User Kim Alvefur # Date 1298247762 -3600 # Node ID aca019044c5181613aeb54945c0f2823d43bb882 # Parent 87ecc63241554490c2cacc6fedfd1253435a8349 plugins.slap: Remove special handling for actions diff -r 87ecc6324155 -r aca019044c51 plugins/slap.lua --- a/plugins/slap.lua Mon Feb 21 01:22:08 2011 +0100 +++ b/plugins/slap.lua Mon Feb 21 01:22:42 2011 +0100 @@ -8,20 +8,6 @@ bot.config.weapons = {'large trout'} end - -- reply to message (but don't prepend the sender's nick like groupchat's - -- event:reply does) - local function bare_reply(command, reply) - if command.stanza.attr.type == 'groupchat' then - local r = st.reply(command.stanza) - local room_jid = jid.bare(command.sender.jid); - if bot.rooms[room_jid] then - bot.rooms[room_jid]:send(r:tag("body"):text(reply)); - end - else - return command:reply(reply); - end - end - -- slap someone local function slap(command) local who, weapon @@ -29,29 +15,29 @@ who = command.param else -- slap the sender if they don't specify a target - if bot.rooms[jid.bare(command.sender.jid)] then - who = select(3, jid.split(command.sender.jid)) + if command.sender.nick then + who = command.sender.nick else who = (jid.split(command.sender.jid)) end end weapon = bot.config.weapons[math.random(#bot.config.weapons)] - bare_reply(command, string.format('/me slaps %s with %s', who, weapon)) + return string.format('/me slaps %s with %s', who, weapon) end -- pick up a weapon for slapping local function weapon(command) if command.param then if command.param:lower() == 'excalibur' then - command:reply 'Listen -- strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony.' + return 'Listen -- strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony.' elseif command.param:lower() == 'paper' then - bare_reply(command, '"Reverse primary thrust, Marvin." That\'s what they say to me. "Open airlock number 3, Marvin." "Marvin, can you pick up that piece of paper?" Here I am, brain the size of a planet, and they ask me to pick up a piece of paper.') + return '"Reverse primary thrust, Marvin." That\'s what they say to me. "Open airlock number 3, Marvin." "Marvin, can you pick up that piece of paper?" Here I am, brain the size of a planet, and they ask me to pick up a piece of paper.' else table.insert(bot.config.weapons, command.param) - bare_reply(command, '/me picks up '..command.param) + return '/me picks up '..command.param end else - command:reply 'Tell me what weapon to pick up' + return 'Tell me what weapon to pick up' end end @@ -63,7 +49,7 @@ local weapons = bot.config.weapons if v == command.param then if #weapons == 1 then - bare_reply(command, '/me refuses to drop his last weapon') + return '/me refuses to drop his last weapon' else weapons[i] = weapons[#weapons] table.remove(weapons) @@ -73,12 +59,12 @@ end end if found then - bare_reply(command, '/me drops '..command.param) + return '/me drops '..command.param else - bare_reply(command, "/me doesn't have "..command.param) + return "/me doesn't have "..command.param end else - command:reply 'Tell me what to drop' + return 'Tell me what to drop' end end