this should works maybe unless i made a glareing error
Code:
local Send=SendChatMessage;
function SendChatMessage(msg,chan,...);
chan=chan:upper();-- Convert to make checks easier (channel is case-insensitive)
if chan=="SAY" then
local pieces={strsplit("*",msg:gsub("%s*%*%s*","%*"))};
-- Iterate through pieces
for i,j in ipairs(pieces) do
if #j>0 then-- Don't do anything if string is empty
if i%2>0 then-- Evaluates to 1 if say, 0 if emote
Send(j,chan);
else
-- Try to separate command and args
j=strsplit("*", j)
local cmd,arg=j:match("(%S+) (.+)");
if not cmd then cmd=j; end
-- This is tricky, we need to check if the emote slash command exists
local token;
local tokencheck,tokenid=EMOTE1_TOKEN,1;
while tokencheck do
local cmdcheck,cmdid=_G["EMOTE"..tokenid.."_CMD1"],1;
while cmdcheck do
local slashcmd=cmdcheck:sub(2):lower();-- Skip the slash for the emote command
if slashcmd==cmd:lower() then-- Command matches, token found
token=tokencheck;
break;
end
-- Increment command
cmdcheck,cmdid=_G["EMOTE"..tokenid.."_CMD"..(cmdid+1)],cmdid+1;
end
-- Break if token found
if token then break; end
-- Increment token
tokencheck,tokenid=_G["EMOTE"..(tokenid+1).."_TOKEN"],tokenid+1;
end
if token then
DoEmote(token,arg);-- Performs the same emote operation as supported by chat
else
Send(j,"EMOTE");
end
end
end
end
else
Send(msg,chan,...);
end
end