Apart from the channel mode +S and +c, there's already an Unreal module available that will strip out colors in private messages (called nocolorumode.c). But I wanted a usermode to allow stripping all colors/codes that are being sent to the client.
I needed to dig into the available hooks for this (since there is no manual available for them).
HOOKTYPE_PRIVMSG (aClient *cptr, aClient *sptr, aChannel *acptr, char *text, int notice) HOOKTYPE_CHANMSG (aClient *cptr, aClient *sptr, aChannel *acptr, char *text, int notice) HOOKTYPE_PACKET (aClient *from, aClient *to, char **msg, int *len)
Nocolorumode.c used HOOKTYPE_PRIVMSG for stripping out colors in PMs. You'd think that HOOKTYPE_CHANMSG would be the logical choice to strip out colors in channel messages.
I've come to understand however that that aproach won't work when using prefixes in PRIVMSG's (like PRIVMSG %#chan :text). When hooking into HOOKTYPE_CHANMSG, it's not possible to know about the prefix it's being sent to.
You could get it by overriding the command, but that's pretty ugly, and in this particular case would mean you end up rewriting the entire m_message function, which is just silly.
It's not possible to modify the text on a per-user basis. I need some users to receive the message with the colors stripped out, while others must receive the message in its untouched form.
There should be a hook that gets executed for every message that is soon to be received by the client, but there is none. The only option left is to strip the colors on the outgoing packet, using HOOKTYPE_PACKET.