1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
kiss.parseCommand = function(cmd)
	local ret = {}
	local col = ""
	local quote = false
	
	for i = 1, #cmd do
		local c = cmd:sub(i, i)	
		if c == "\"" and (i == 1 or cmd:sub(i-1, i-1) ~= "\\") then
			if col ~= "" then
				table.insert(ret, col)
				col = ""
			end
			quote = not quote
		elseif c == " " and not quote then
			if col ~= "" then
				table.insert(ret, col)
				col = ""
			end
		elseif c ~= "\\" or i == #cmd or cmd:sub(i+1, i+1) ~= "\"" then
			col = col .. c
			if i == #cmd then
				table.insert(ret, col)
			end
		end
	end
	
	return ret
end
1
2
3
4
5
6
7
kiss.say = function(id, message)
	local cmd = kiss.parseCommand(message)
	msg("printing parsed message:")
	for k in ipairs(cmd) do msg(cmd[k]) end
end
addhook("say", "kiss.say")