m
Move page script moved page Hooking outgoing chat messages to WoW:Hooking outgoing chat messages without leaving a redirect
No edit summary |
m (Move page script moved page Hooking outgoing chat messages to WoW:Hooking outgoing chat messages without leaving a redirect) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
To modify outgoing chat messages we are going to hook the ChatEdit_ParseText function. However, this function also handles macros; so to avoid tainting we must use [[API_hooksecurefunc|hooksecurefunc]]() to hook the function properly. Otherwise, your macros will no longer work. | |||
-- Place this code in the OnLoad function of your addon | |||
hooksecurefunc('ChatEdit_ParseText',MyAddon_ParseText); | |||
MyAddon_ParseText will now be called after ChatEdit_ParseText has had a chance to handle macros and slash commands. | |||
function MyAddon_ParseText(chatEntry, send) | |||
-- This function actually gets called every time the user hits a key. But the | -- This function actually gets called every time the user hits a key. But the | ||
-- send flag will only be set when he hits return to send the message. | -- send flag will only be set when he hits return to send the message. | ||