To prevent the infinite loop when testing, hook SendChatMessage, save every message you send in a table, then bail out of processing when the event gets those messages. There's a simple trick to figure out if you're the one that used a hooked function with an "unused" argument.
Lua Code:
--the tracking table
PriceAnswerSentMessages={}
--the hook
hooksecurefunc("SendChatMessage",function(message,_,_,_,_,_,_,mine)
if mine then
PriceAnswerSentMessages[message]=1
end
end)
--then put this in PriceAnswer:CHAT_MSG_WHISPER()
if PriceAnswerSentMessages[incomingMessage] then return end
--finally, add some nils and a true to SendChatMessage
if outgoingMessageOne ~= "" then
SendChatMessage(outgoingMessageOne, "WHISPER", nil, senderName, nil, nil, nil, true)
end
if outgoingMessageTwo ~= "" then
SendChatMessage(outgoingMessageTwo, "WHISPER", nil, senderName, nil, nil, nil, true)
end
if outgoingMessageOne == "" and outgoingMessageTwo == "" then
SendChatMessage(format(L["Syntax: '%s N item' without quotes, N is an optional quantity, default 1, item is an item link or itemID"], L[db.trigger]), "WHISPER", nil, senderName, nil, nil, nil, true)
end
As for the control characters, there's an obscure function in the UI code that I believe strips them:
message = SubstituteChatMessageBeforeSend(message)
There's no documentation for it though.