#include "../nick/nick.h"
#include "../channel/channel.h"
#include "../irc/irc.h"
+#include "../lib/version.h"
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
+#include <string.h>
+
+MODULE_VERSION("$Id: localuserchannel.c 663 2006-05-16 17:27:36Z newserv $")
int handlechannelmsgcmd(void *source, int cargc, char **cargv);
+int handlechannelnoticecmd(void *source, int cargc, char **cargv);
int handleinvitecmd(void *source, int cargc, char **cargv);
void luc_handlekick(int hooknum, void *arg);
void _init() {
registerserverhandler("P",&handlechannelmsgcmd,2);
+ registerserverhandler("O",&handlechannelnoticecmd,2);
registerserverhandler("I",&handleinvitecmd,2);
registerhook(HOOK_CHANNEL_KICK, luc_handlekick);
}
void _fini() {
deregisterserverhandler("P",&handlechannelmsgcmd);
+ deregisterserverhandler("O",&handlechannelnoticecmd);
deregisterserverhandler("I",&handleinvitecmd);
deregisterhook(HOOK_CHANNEL_KICK, luc_handlekick);
}
return CMD_OK;
}
+/*
+ * Added by Cruicky so S2 can receive channel notices
+ * Shameless rip of the above with s/privmsg/notice
+ */
+int handlechannelnoticecmd(void *source, int cargc, char **cargv) {
+ void *nargs[3];
+ nick *sender;
+ channel *target;
+ nick *np;
+ unsigned long numeric;
+ int i;
+ int found=0;
+
+ if (cargc<2) {
+ return CMD_OK;
+ }
+
+ if (cargv[0][0]!='#' && cargv[0][0]!='+') {
+ /* Not a channel notice */
+ return CMD_OK;
+ }
+
+ if ((sender=getnickbynumericstr((char *)source))==NULL) {
+ Error("localuserchannel",ERR_DEBUG,"NOTICE from non existant user %s",(char *)source);
+ return CMD_OK;
+ }
+
+ if ((target=findchannel(cargv[0]))==NULL) {
+ Error("localuserchannel",ERR_DEBUG,"NOTICE to non existant channel %s",cargv[0]);
+ return CMD_OK;
+ }
+
+ /* OK, we have a valid channel the notice was sent to. Let's look to see
+ * if we have any local users on there. Set up the arguments first as they are
+ * always going to be the same. */
+
+ nargs[0]=(void *)sender;
+ nargs[1]=(void *)target;
+ nargs[2]=(void *)cargv[1];
+
+ for (found=0,i=0;i<target->users->hashsize;i++) {
+ numeric=target->users->content[i];
+ if (numeric!=nouser && homeserver(numeric&CU_NUMERICMASK)==mylongnum) {
+ /* OK, it's one of our users.. we need to deal with it */
+ found++;
+ if (umhandlers[numeric&MAXLOCALUSER]) {
+ if ((np=getnickbynumeric(numeric))==NULL) {
+ Error("localuserchannel",ERR_ERROR,"NOTICE to channel user who doesn't exist (?) on %s",cargv[0]);
+ continue;
+ }
+ if (!IsDeaf(np)) {
+ (umhandlers[numeric&MAXLOCALUSER])(np,LU_CHANNOTICE,nargs);
+ } else {
+ found--;
+ }
+ }
+ }
+ }
+
+ if (!found) {
+ Error("localuserchannel",ERR_DEBUG,"Couldn't find any local targets for NOTICE to %s",cargv[0]);
+ }
+
+ return CMD_OK;
+}
+
int localjoinchannel(nick *np, channel *cp) {
void *harg[2];