plugins.commands: If a message with a [command] was directed at someone, remember their nickname.

Sat, 25 May 2013 21:35:27 +0200

author
Kim Alvefur <zash@zash.se>
date
Sat, 25 May 2013 21:35:27 +0200
changeset 102
b7c9a3707e68
parent 101
7d75d7f9d5ae
child 103
c0235605d6d5

plugins.commands: If a message with a [command] was directed at someone, remember their nickname.

plugins/commands.lua file | annotate | diff | comparison | revisions
--- a/plugins/commands.lua	Sat May 25 21:35:27 2013 +0200
+++ b/plugins/commands.lua	Sat May 25 21:35:27 2013 +0200
@@ -19,6 +19,12 @@
 	
 		if not command then
 			command, hasparam, param = body:match("%[([%a%-%_%d]+)(%s?)(.*)%]");
+			if event.room then
+				local direct_to = body:match"^(.-)[,:]"
+				if event.room.occupants[direct_to] then
+					event.reply_to = direct_to
+				end
+			end
 		end
 		
 		if hasparam ~= " " then param = nil; end

mercurial