-
Posted by dru83 on Thu, 17 Feb 2011 07:23:00
Hello,
I'm making a chat addon (my first addon), and I have found the functions:
ChatFrame_AddMessageEventFilter("event", filterFunc)
ChatFrame_RemoveMessageEventFilter("event", filterFunc)
filterFuncList = ChatFrame_GetMessageEventFilters("event")
However these appear to modify what you see and not what is sent to propagate to other players listening.
So 2 questions: 1. Is it possible to alter the outgoing message? 2. If so, what's the function or what is an example of how to change what someones says to someone else prior to sending the message to another player.
Example of what I want to happen:
/whisper someotherguy hello, would you like to group for a random?
(now pretend your are someotherguy)
[playername]: hello, would you like to group for a dungeon?
^^^ notice how i changed the word random to dungeon. I understand string find/gsub etc.. as they are listed in wowwiki wow api function lists. But how do i change the message before it gets sent without replacing the chat frame?
-
Posted by jnwhiteh on Thu, 17 Feb 2011 14:07:51
Hello,
I'm making a chat addon (my first addon), and I have found the functions:
ChatFrame_AddMessageEventFilter("event", filterFunc)
ChatFrame_RemoveMessageEventFilter("event", filterFunc)
filterFuncList = ChatFrame_GetMessageEventFilters("event")
However these appear to modify what you see and not what is sent to propagate to other players listening.
So 2 questions: 1. Is it possible to alter the outgoing message?
Universally.. not really. You'd need to hook the SendChatMessage() function.
- If so, what's the function or what is an example of how to change what someones says to someone else prior to sending the message to another player.
Example of what I want to happen:
/whisper someotherguy hello, would you like to group for a random?
(now pretend your are someotherguy)
[playername]: hello, would you like to group for a dungeon?
^^^ notice how i changed the word random to dungeon. I understand string find/gsub etc.. as they are listed in wowwiki wow api function lists. But how do i change the message before it gets sent without replacing the chat frame?
You'd need to hook the SendChatMessage function.. not for the light hearted.
-
Posted by dru83 on Thu, 17 Feb 2011 19:08:43
It didn't even hit me to look for "hooking" as this is a term commonly used in other programming environments as well. Here's an example for anyone interested that i found on wowace.com, I also ran across some old blizzard forums about people doing approximately the same thing and they all did the following:
--First backup the blizzard send chat function into another var so you can use it later if you want. wowSendChatMessage = SendChatMessage --Then redo the function, be sure to include the ..., i would assume if you overload the arguments you won't get the desired effect. function SendChatMessage(msg, chatType, ...) wowSendChatMessage (msg, chatType, ...) end
Anyway, i haven't tried this yet as i am at work. But if you have anymore thoughts, please post.
Thanks
-
Posted by jnwhiteh on Fri, 18 Feb 2011 20:17:27
No, that's how you would do it =)