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

These are old archives. They are kept for historic purposes only.
Post Reply
w00t
Posts: 1136
Joined: Thu Mar 25, 2004 3:31 am
Location: Nowra, Australia

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

Post 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?
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
Stealth
Head of Support
Posts: 2085
Joined: Tue Jun 15, 2004 8:50 pm
Location: Chino Hills, CA, US
Contact:

Post by Stealth »

Don't need to hook whois, just override it and pass it to the IRCd :P
aquanight
Official supporter
Posts: 862
Joined: Tue Mar 09, 2004 10:47 pm
Location: Boise, ID

Post 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.
w00t
Posts: 1136
Joined: Thu Mar 25, 2004 3:31 am
Location: Nowra, Australia

Post by w00t »

I plan on using a different usermode.
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
Syzop
UnrealIRCd head coder
Posts: 2117
Joined: Sat Mar 06, 2004 8:57 pm
Location: .nl
Contact:

Post 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]
w00t
Posts: 1136
Joined: Thu Mar 25, 2004 3:31 am
Location: Nowra, Australia

Post 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.
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
aquanight
Official supporter
Posts: 862
Joined: Tue Mar 09, 2004 10:47 pm
Location: Boise, ID

Post 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.
Post Reply