Page 1 of 1

Trying to create a module, some help please? :p

Posted: Wed Feb 16, 2005 2:44 am
by w00t
I'm looking at dipping my feet into the Unreal modules scene, I've already had one request. To make +W available for all users. Now, I know this is a core module. So I think "sure, there's gonna be a hook for whois, right?"

Wrong.

Is there any other way I can do this rather than using hooks/modifying the core?

Posted: Wed Feb 16, 2005 7:06 am
by Stealth
Don't need to hook whois, just override it and pass it to the IRCd :P

Posted: Wed Feb 16, 2005 7:48 am
by aquanight
Small problem. User tries /mode me +W. Nothing happens. You actually need to override the usermode itself, not necessarily the command. Unfortunately, you cannot easily override a usermode.

Posted: Wed Feb 16, 2005 12:55 pm
by w00t
I plan on using a different usermode.

Posted: Wed Feb 16, 2005 5:06 pm
by Syzop
Someone submitted a module like this sometime earlier.. but he made a small mistake, so I mailed him back if he could correct that. Never heard anything from him again ;).

Oh and yes.. overriding the WHOIS cmd and using a different umode is the way to go I think :p.
[sure, adding a hook would be possible, but IMO if you can do something quite easily via cmd overrides then why add a hook :p]

Posted: Wed Feb 16, 2005 6:12 pm
by w00t
can...someone point me in the right direction as to overriding something

yes, i feel like a moron. but it is my first attempt.

Posted: Wed Feb 16, 2005 11:13 pm
by aquanight
w00t wrote:can...someone point me in the right direction as to overriding something

yes, i feel like a moron. but it is my first attempt.
CmdoverrideAdd would be your first step.

Naturally you'll need to save the module info in a static variable during MOD_INIT, you need that to get the handle to pass to CmdoverrideAdd. You also need to declare a function like this:

DLLFUNC[1] int my_whois_handler(Cmdoverride* ovr, aClient* cptr, aClient* sptr, int parc, char* parv[]);

Then pass your module handle (modinfo->handle), the command name (eg, "WHOIS") and the function (eg, my_whois_handler) to CmdoverrideAdd. Among the things you'll need to do in your own handler is call unreal's code to handle the normal whois replies. For this you use CallCmdoverride:

CallCmdoverride(ovr, cptr, sptr, parc, parv);

That'll call the next override if there is one, or the m_whois itself.

Actually you don't necessarily need DLLFUNC since you're just passing a pointer to the function - not its name. It's actually permissible to use static, and might even be better so that you don't pollute the dll symbol table with functions that don't need to be in it.