int handlejoinmsg(void *source, int cargc, char **cargv) {
char *pos,*nextchan;
nick *np;
- void *harg[2];
+ void *harg[3];
channel *cp,**ch;
long timestamp=0;
int i;
/* Find out who we are talking about here */
np=getnickbynumericstr(source);
if (np==NULL) {
- Error("channel",ERR_WARNING,"Channel join from non existent user %s",source);
+ Error("channel",ERR_WARNING,"Channel join from non existent user %s",(char *)source);
return CMD_OK;
}
/* Send hook */
harg[0]=ch[i];
harg[1]=np;
+ harg[2]=NULL;
triggerhook(HOOK_CHANNEL_PART,harg);
delnickfromchannel(ch[i],np->numeric,0);
}
if (newchan) {
delchannel(cp);
}
- } else {
+ } else {
+ chanindex *cip=cp->index;
+
/* If we just created a channel, flag it */
if (newchan) {
triggerhook(HOOK_CHANNEL_NEWCHANNEL,cp);
}
-
- /* send hook */
- harg[0]=cp;
- harg[1]=np;
- triggerhook(HOOK_CHANNEL_JOIN,harg);
+
+ /* Don't send HOOK_CHANNEL_JOIN if the channel doesn't exist any
+ * more (can happen if something destroys it in response to
+ * HOOK_CHANNEL_NEWCHANNEL) */
+ if (cp == cip->channel) {
+ /* send hook */
+ harg[0]=cp;
+ harg[1]=np;
+ triggerhook(HOOK_CHANNEL_JOIN,harg);
+ }
}
}
nextchan=pos;
/* Find out who we are talking about here */
np=getnickbynumericstr(source);
if (np==NULL) {
- Error("channel",ERR_WARNING,"Channel create from non existent user %s",source);
+ Error("channel",ERR_WARNING,"Channel create from non existent user %s",(char *)source);
return CMD_OK;
}
if (newchan) {
delchannel(cp);
}
- } else {
+ } else {
+ chanindex *cip = cp->index;
+
/* Flag the channel as new if necessary */
if (newchan) {
triggerhook(HOOK_CHANNEL_NEWCHANNEL,cp);
}
- /* Trigger hook */
- harg[0]=cp;
- harg[1]=np;
- triggerhook(HOOK_CHANNEL_CREATE,harg);
+ /* If HOOK_CHANNEL_NEWCHANNEL has caused the channel to be deleted,
+ * don't trigger the CREATE hook. */
+ if (cip->channel == cp) {
+ /* Trigger hook */
+ harg[0]=cp;
+ harg[1]=np;
+ triggerhook(HOOK_CHANNEL_CREATE,harg);
+ }
}
nextchan=pos;
}
/* Find out who we are talking about here */
np=getnickbynumericstr(source);
if (np==NULL) {
- Error("channel",ERR_WARNING,"PART from non existent numeric %s",source);
+ Error("channel",ERR_WARNING,"PART from non existent numeric %s",(char *)source);
return CMD_OK;
}
/* Find out who we are talking about here */
if ((np=getnickbynumericstr(cargv[1]))==NULL) {
- Error("channel",ERR_DEBUG,"Non-existant numeric %s kicked from channel %s",source,cargv[0]);
+ Error("channel",ERR_DEBUG,"Non-existant numeric %s kicked from channel %s",(char *)source,cargv[0]);
return CMD_OK;
}
if (cargc>3)
timestamp=strtol(cargv[cargc-3], NULL, 10);
- if ((np=getnickbynumericstr((char *)source))==NULL) {
+ np=getnickbynumericstr((char *)source);
+
+ /* The following check removed because servers can set topics.. */
+#if 0
+ if (np==NULL) {
/* We should check the sender exists, but we still change the topic even if it doesn't */
Error("channel",ERR_WARNING,"Topic change by non-existent user %s",(char *)source);
}
+#endif
/* Grab channel pointer */
if ((cp=findchannel(cargv[0]))==NULL) {