]>
jfr.im git - irc/quakenet/newserv.git/blob - localuser/localuserchannel.c
1 /* Functions for manipulating local users on channels */
4 #include "localuserchannel.h"
5 #include "../nick/nick.h"
6 #include "../channel/channel.h"
7 #include "../irc/irc.h"
14 int handlechannelmsgcmd(void *source
, int cargc
, char **cargv
);
15 int handlechannelnoticecmd(void *source
, int cargc
, char **cargv
);
16 int handleinvitecmd(void *source
, int cargc
, char **cargv
);
17 void luc_handlekick(int hooknum
, void *arg
);
20 registerserverhandler("P",&handlechannelmsgcmd
,2);
21 registerserverhandler("O",&handlechannelnoticecmd
,2);
22 registerserverhandler("I",&handleinvitecmd
,2);
23 registerhook(HOOK_CHANNEL_KICK
, luc_handlekick
);
27 deregisterserverhandler("P",&handlechannelmsgcmd
);
28 deregisterserverhandler("O",&handlechannelnoticecmd
);
29 deregisterserverhandler("I",&handleinvitecmd
);
30 deregisterhook(HOOK_CHANNEL_KICK
, luc_handlekick
);
33 void luc_handlekick(int hooknum
, void *arg
) {
38 if (homeserver(target
->numeric
)!=mylongnum
)
41 if (umhandlers
[target
->numeric
& MAXLOCALUSER
]) {
46 (umhandlers
[target
->numeric
& MAXLOCALUSER
])(target
, LU_KICKED
, myargs
);
50 /* invites look something like:
51 * XXyyy I TargetNick :#channel
54 int handleinvitecmd(void *source
, int cargc
, char **cargv
) {
64 if (!(sender
=getnickbynumericstr(source
))) {
65 Error("localuserchannel",ERR_WARNING
,"Got invite from unknown numeric %s.",source
);
69 if (!(target
=getnickbynick(cargv
[0]))) {
70 Error("localuserchannel",ERR_WARNING
,"Got invite for unknown local user %s.",cargv
[0]);
74 if (!(cp
=findchannel(cargv
[1]))) {
75 Error("localuserchannel",ERR_WARNING
,"Got invite for non-existent channel %s.",cargv
[1]);
79 if (homeserver(target
->numeric
) != mylongnum
) {
80 Error("localuserchannel",ERR_WARNING
,"Got invite for non-local user %s.",target
->nick
);
84 /* This is a valid race condition.. */
85 if (getnumerichandlefromchanhash(cp
->users
, target
->numeric
)) {
86 Error("localuserchannel",ERR_DEBUG
,"Got invite for user %s already on %s.",target
->nick
, cp
->index
->name
->content
);
90 nargs
[0]=(void *)sender
;
93 if (umhandlers
[target
->numeric
&MAXLOCALUSER
]) {
94 (umhandlers
[target
->numeric
&MAXLOCALUSER
])(target
, LU_INVITE
, nargs
);
100 int handlechannelmsgcmd(void *source
, int cargc
, char **cargv
) {
105 unsigned long numeric
;
113 if (cargv
[0][0]!='#' && cargv
[0][0]!='+') {
114 /* Not a channel message */
118 if ((sender
=getnickbynumericstr((char *)source
))==NULL
) {
119 Error("localuserchannel",ERR_DEBUG
,"PRIVMSG from non existant user %s",(char *)source
);
123 if ((target
=findchannel(cargv
[0]))==NULL
) {
124 Error("localuserchannel",ERR_DEBUG
,"PRIVMSG to non existant channel %s",cargv
[0]);
128 /* OK, we have a valid channel the message was sent to. Let's look to see
129 * if we have any local users on there. Set up the arguments first as they are
130 * always going to be the same. */
132 nargs
[0]=(void *)sender
;
133 nargs
[1]=(void *)target
;
134 nargs
[2]=(void *)cargv
[1];
136 for (found
=0,i
=0;i
<target
->users
->hashsize
;i
++) {
137 numeric
=target
->users
->content
[i
];
138 if (numeric
!=nouser
&& homeserver(numeric
&CU_NUMERICMASK
)==mylongnum
) {
139 /* OK, it's one of our users.. we need to deal with it */
141 if (umhandlers
[numeric
&MAXLOCALUSER
]) {
142 if ((np
=getnickbynumeric(numeric
))==NULL
) {
143 Error("localuserchannel",ERR_ERROR
,"PRIVMSG to channel user who doesn't exist (?) on %s",cargv
[0]);
147 (umhandlers
[numeric
&MAXLOCALUSER
])(np
,LU_CHANMSG
,nargs
);
156 Error("localuserchannel",ERR_DEBUG
,"Couldn't find any local targets for PRIVMSG to %s",cargv
[0]);
163 * Added by Cruicky so S2 can receive channel notices
164 * Shameless rip of the above with s/privmsg/notice
166 int handlechannelnoticecmd(void *source
, int cargc
, char **cargv
) {
171 unsigned long numeric
;
179 if (cargv
[0][0]!='#' && cargv
[0][0]!='+') {
180 /* Not a channel notice */
184 if ((sender
=getnickbynumericstr((char *)source
))==NULL
) {
185 Error("localuserchannel",ERR_DEBUG
,"NOTICE from non existant user %s",(char *)source
);
189 if ((target
=findchannel(cargv
[0]))==NULL
) {
190 Error("localuserchannel",ERR_DEBUG
,"NOTICE to non existant channel %s",cargv
[0]);
194 /* OK, we have a valid channel the notice was sent to. Let's look to see
195 * if we have any local users on there. Set up the arguments first as they are
196 * always going to be the same. */
198 nargs
[0]=(void *)sender
;
199 nargs
[1]=(void *)target
;
200 nargs
[2]=(void *)cargv
[1];
202 for (found
=0,i
=0;i
<target
->users
->hashsize
;i
++) {
203 numeric
=target
->users
->content
[i
];
204 if (numeric
!=nouser
&& homeserver(numeric
&CU_NUMERICMASK
)==mylongnum
) {
205 /* OK, it's one of our users.. we need to deal with it */
207 if (umhandlers
[numeric
&MAXLOCALUSER
]) {
208 if ((np
=getnickbynumeric(numeric
))==NULL
) {
209 Error("localuserchannel",ERR_ERROR
,"NOTICE to channel user who doesn't exist (?) on %s",cargv
[0]);
213 (umhandlers
[numeric
&MAXLOCALUSER
])(np
,LU_CHANNOTICE
,nargs
);
222 Error("localuserchannel",ERR_DEBUG
,"Couldn't find any local targets for NOTICE to %s",cargv
[0]);
228 int localjoinchannel(nick
*np
, channel
*cp
) {
231 if (cp
==NULL
|| np
==NULL
) {
235 /* Check that the user _is_ a local one.. */
236 if (homeserver(np
->numeric
)!=mylongnum
) {
240 /* Check that the user isn't on the channel already */
241 if ((getnumerichandlefromchanhash(cp
->users
,np
->numeric
))!=NULL
) {
245 /* OK, join the channel.. */
246 addnicktochannel(cp
,np
->numeric
);
248 /* Trigger the event */
252 triggerhook(HOOK_CHANNEL_JOIN
, harg
);
255 irc_send("%s J %s %lu",longtonumeric(np
->numeric
,5),cp
->index
->name
->content
,cp
->timestamp
);
260 int localpartchannel(nick
*np
, channel
*cp
) {
263 /* Check pointers are valid.. */
264 if (cp
==NULL
|| np
==NULL
) {
265 Error("localuserchannel",ERR_WARNING
,"Trying to part NULL channel or NULL nick (cp=%x,np=%x)",cp
,np
);
269 /* And that user is local.. */
270 if (homeserver(np
->numeric
)!=mylongnum
) {
271 Error("localuserchannel",ERR_WARNING
,"Trying to part remote user %s",np
->nick
);
275 /* Check that user is on channel */
276 if (getnumerichandlefromchanhash(cp
->users
,np
->numeric
)==NULL
) {
277 Error("localuserchannel",ERR_WARNING
,"Trying to part user %s from channel %s it is not on",np
->nick
,cp
->index
->name
->content
);
282 irc_send("%s L %s",longtonumeric(np
->numeric
,5),cp
->index
->name
->content
);
288 triggerhook(HOOK_CHANNEL_PART
,harg
);
290 /* Now leave the channel */
291 delnickfromchannel(cp
,np
->numeric
,1);
296 int localcreatechannel(nick
*np
, char *channame
) {
299 /* Check that the user _is_ a local one.. */
300 if (homeserver(np
->numeric
)!=mylongnum
) {
304 if ((cp
=findchannel(channame
))!=NULL
) {
309 cp
=createchannel(channame
);
310 cp
->timestamp
=getnettime();
312 /* Add the local user to the channel, preopped */
313 addnicktochannel(cp
,(np
->numeric
)|CUMODE_OP
);
316 irc_send("%s C %s %ld",longtonumeric(np
->numeric
,5),cp
->index
->name
->content
,cp
->timestamp
);
319 triggerhook(HOOK_CHANNEL_NEWCHANNEL
,(void *)cp
);
323 int localgetops(nick
*np
, channel
*cp
) {
326 /* Check that the user _is_ a local one.. */
327 if (homeserver(np
->numeric
)!=mylongnum
) {
331 if ((lp
=getnumerichandlefromchanhash(cp
->users
,np
->numeric
))==NULL
) {
335 if (*lp
& CUMODE_OP
) {
344 irc_send("%s M %s +o %s",mynumeric
->content
,cp
->index
->name
->content
,longtonumeric(np
->numeric
,5));
350 int localgetvoice(nick
*np
, channel
*cp
) {
353 /* Check that the user _is_ a local one.. */
354 if (homeserver(np
->numeric
)!=mylongnum
) {
358 if ((lp
=getnumerichandlefromchanhash(cp
->users
,np
->numeric
))==NULL
) {
362 if (*lp
& CUMODE_VOICE
) {
371 irc_send("%s M %s +v %s",mynumeric
->content
,cp
->index
->name
->content
,longtonumeric(np
->numeric
,5));
379 * Initialises the modechanges structure.
382 void localsetmodeinit (modechanges
*changes
, channel
*cp
, nick
*np
) {
385 changes
->changecount
=0;
391 * localdosetmode_ban:
392 * Set or clear a ban on the channel
395 void localdosetmode_ban (modechanges
*changes
, const char *ban
, short dir
) {
396 sstring
*bansstr
=getsstring(ban
,HOSTLEN
+NICKLEN
+USERLEN
+5);
398 /* If we're told to clear a ban that isn't here, do nothing. */
399 if (dir
==MCB_DEL
&& !clearban(changes
->cp
, bansstr
->content
, 1))
402 if (changes
->changecount
>= MAXMODEARGS
)
403 localsetmodeflush(changes
, 0);
405 changes
->changes
[changes
->changecount
].str
=bansstr
;
406 changes
->changes
[changes
->changecount
].flag
='b';
407 changes
->changes
[changes
->changecount
++].dir
=dir
;
410 setban(changes
->cp
, bansstr
->content
);
415 * localdosetmode_key:
416 * Set or clear a key on the channel
419 void localdosetmode_key (modechanges
*changes
, const char *key
, short dir
) {
423 /* Check we have space in the buffer */
424 if (changes
->changecount
>= MAXMODEARGS
)
425 localsetmodeflush(changes
,0);
428 /* Get a copy of the key for use later */
429 keysstr
=getsstring(key
, KEYLEN
);
431 /* Check there isn't a key set/clear in the pipeline already.. */
432 for (i
=0;i
<changes
->changecount
;i
++) {
433 if (changes
->changes
[i
].flag
=='k') {
434 /* There's a change already.. */
435 if (changes
->changes
[i
].dir
==MCB_ADD
) {
436 /* Already an add key change. Here, we just replace the key
437 * we were going to add with this one. Note that we need to
438 * free the current cp->key, and the changes.str */
439 freesstring(changes
->changes
[i
].str
);
440 changes
->changes
[i
].str
=keysstr
;
441 freesstring(changes
->cp
->key
);
442 changes
->cp
->key
=getsstring(key
, KEYLEN
);
443 /* That's it, we're done */
446 /* There was a command to delete key.. we need to flush
447 * this out then add the new key (-k+k isn't valid).
448 * Make sure this gets flushed, then drop through to common code */
449 localsetmodeflush(changes
, 1);
454 /* We got here, so there's no change pending already .. check for key on chan */
455 if (IsKey(changes
->cp
)) {
456 if (sstringcompare(changes
->cp
->key
, keysstr
)) {
457 /* Key is set and different. Need to put -k in and flush changes now */
458 changes
->changes
[changes
->changecount
].str
=changes
->cp
->key
; /* implicit free */
459 changes
->changes
[changes
->changecount
].dir
=MCB_DEL
;
460 changes
->changes
[changes
->changecount
++].flag
='k';
461 localsetmodeflush(changes
, 1); /* Note that this will free the sstring on the channel */
463 /* Key is set and the same: do nothing. */
464 freesstring(keysstr
); /* Don't need this after all */
469 /* If we get here, there's no key on the channel right now and nothing in the buffer to
470 * add or remove one */
472 changes
->cp
->key
=getsstring(key
, KEYLEN
);
474 changes
->changes
[changes
->changecount
].str
=keysstr
;
475 changes
->changes
[changes
->changecount
].dir
=MCB_ADD
;
476 changes
->changes
[changes
->changecount
++].flag
='k';
478 /* We're removing a key.. */
479 /* Only bother if key is set atm */
480 if (IsKey(changes
->cp
)) {
481 ClearKey(changes
->cp
);
482 for(i
=0;i
<changes
->changecount
;i
++) {
483 if (changes
->changes
[i
].flag
=='k') {
484 /* We were already doing something with a key..
485 * it MUST be adding one */
486 assert(changes
->changes
[i
].dir
==MCB_ADD
);
487 /* Just forget the earlier change */
488 freesstring(changes
->changes
[i
].str
);
489 changes
->changecount
--;
490 for (j
=i
;j
<changes
->changecount
;j
++) {
491 changes
->changes
[j
]=changes
->changes
[j
+1];
493 /* Explicitly free key on chan */
494 freesstring(changes
->cp
->key
);
495 changes
->cp
->key
=NULL
;
500 /* We didn't hit a key change, so put a remove command in */
501 changes
->changes
[changes
->changecount
].str
=changes
->cp
->key
; /* implicit free */
502 changes
->cp
->key
=NULL
;
503 changes
->changes
[changes
->changecount
].dir
=MCB_DEL
;
504 changes
->changes
[changes
->changecount
++].flag
='k';
509 void localdosetmode_limit (modechanges
*changes
, unsigned int limit
, short dir
) {
514 localdosetmode_simple(changes
, 0, CHANMODE_LIMIT
);
518 /* Kill redundant changes */
519 if ((IsLimit(changes
->cp
) && changes
->cp
->limit
==limit
) || !limit
)
522 SetLimit(changes
->cp
);
523 changes
->cp
->limit
=limit
;
524 changes
->delflags
&= ~CHANMODE_LIMIT
;
526 /* Check for existing limit add */
527 for (i
=0;i
<changes
->changecount
;i
++) {
528 if (changes
->changes
[i
].flag
=='l') {
530 freesstring(changes
->changes
[i
].str
);
531 sprintf(buf
,"%u",limit
);
532 changes
->changes
[i
].str
=getsstring(buf
,20);
537 /* None, add new one. Note that we can do +l even if a limit is already set */
538 if (changes
->changecount
>= MAXMODEARGS
)
539 localsetmodeflush(changes
,0);
541 changes
->changes
[changes
->changecount
].flag
='l';
542 sprintf(buf
,"%u",limit
);
543 changes
->changes
[changes
->changecount
].str
=getsstring(buf
,20);
544 changes
->changes
[changes
->changecount
++].dir
=MCB_ADD
;
547 void localdosetmode_simple (modechanges
*changes
, flag_t addmodes
, flag_t delmodes
) {
550 /* We can't add a mode we're deleting, a key, limit, or mode that's already set */
551 addmodes
&= ~(delmodes
| CHANMODE_KEY
| CHANMODE_LIMIT
| changes
->cp
->flags
);
553 /* We can't delete a key or a mode that's not set */
554 delmodes
&= (~(CHANMODE_KEY
) & changes
->cp
->flags
);
556 /* If we're doing +p, do -s as well, and vice versa */
557 /* Also disallow +ps */
558 if (addmodes
& CHANMODE_SECRET
) {
559 addmodes
&= ~(CHANMODE_PRIVATE
);
560 delmodes
|= (CHANMODE_PRIVATE
& changes
->cp
->flags
);
563 if (addmodes
& CHANMODE_PRIVATE
) {
564 delmodes
|= (CHANMODE_SECRET
& changes
->cp
->flags
);
567 /* Fold changes into channel */
568 changes
->cp
->flags
|= addmodes
;
569 changes
->cp
->flags
&= ~delmodes
;
571 if (delmodes
& CHANMODE_LIMIT
) {
572 /* Check for +l in the parametered changes */
573 for (i
=0;i
<changes
->changecount
;i
++) {
574 if (changes
->changes
[i
].flag
=='l') {
575 freesstring(changes
->changes
[i
].str
);
576 changes
->changecount
--;
577 for (j
=0;j
<changes
->changecount
;j
++) {
578 changes
->changes
[j
]=changes
->changes
[j
+1];
583 changes
->cp
->limit
=0;
586 /* And into the changes buffer */
587 changes
->addflags
&= ~delmodes
;
588 changes
->addflags
|= addmodes
;
590 changes
->delflags
&= ~addmodes
;
591 changes
->delflags
|= delmodes
;
596 * Applies a mode change.
599 void localdosetmode_nick (modechanges
*changes
, nick
*target
, short modes
) {
602 if ((lp
=getnumerichandlefromchanhash(changes
->cp
->users
,target
->numeric
))==NULL
) {
603 /* Target isn't on channel, abort */
607 if ((modes
& MC_DEOP
) && (*lp
& CUMODE_OP
)) {
609 if (changes
->changecount
>= MAXMODEARGS
)
610 localsetmodeflush(changes
, 0);
611 changes
->changes
[changes
->changecount
].str
=getsstring(longtonumeric(target
->numeric
,5),5);
612 changes
->changes
[changes
->changecount
].dir
=MCB_DEL
;
613 changes
->changes
[changes
->changecount
++].flag
='o';
616 if ((modes
& MC_DEVOICE
) && (*lp
& CUMODE_VOICE
)) {
617 (*lp
) &= ~CUMODE_VOICE
;
618 if (changes
->changecount
>= MAXMODEARGS
)
619 localsetmodeflush(changes
, 0);
620 changes
->changes
[changes
->changecount
].str
=getsstring(longtonumeric(target
->numeric
,5),5);
621 changes
->changes
[changes
->changecount
].dir
=MCB_DEL
;
622 changes
->changes
[changes
->changecount
++].flag
='v';
625 if ((modes
& MC_OP
) && !(modes
& MC_DEOP
) && !(*lp
& CUMODE_OP
)) {
627 if (changes
->changecount
>= MAXMODEARGS
)
628 localsetmodeflush(changes
, 0);
629 changes
->changes
[changes
->changecount
].str
=getsstring(longtonumeric(target
->numeric
,5),5);
630 changes
->changes
[changes
->changecount
].dir
=MCB_ADD
;
631 changes
->changes
[changes
->changecount
++].flag
='o';
634 if ((modes
& MC_VOICE
) && !(modes
& MC_DEVOICE
) && !(*lp
& CUMODE_VOICE
)) {
635 (*lp
) |= CUMODE_VOICE
;
636 if (changes
->changecount
>= MAXMODEARGS
)
637 localsetmodeflush(changes
, 0);
638 changes
->changes
[changes
->changecount
].str
=getsstring(longtonumeric(target
->numeric
,5),5);
639 changes
->changes
[changes
->changecount
].dir
=MCB_ADD
;
640 changes
->changes
[changes
->changecount
++].flag
='v';
647 * Sends out mode changes to the network.
650 void localsetmodeflush (modechanges
*changes
, int flushall
) {
665 strcpy(addmodes
, printflags_noprefix(changes
->addflags
, cmodeflags
));
666 ampos
=strlen(addmodes
);
668 strcpy(remmodes
, printflags_noprefix(changes
->delflags
, cmodeflags
));
669 rmpos
=strlen(remmodes
);
671 changes
->addflags
=changes
->delflags
=0;
673 for (i
=0;i
<changes
->changecount
;i
++) {
674 /* Don't overflow the string, kinda nasty to work out.. format is: */
675 /* AAAA M #chan +add-rem (addstr) (remstr) */
676 if ((changes
->cp
->index
->name
->length
+ aapos
+ rapos
+
677 ampos
+ rmpos
+ changes
->changes
[i
].str
->length
+ 20) > BUFSIZE
)
680 switch (changes
->changes
[i
].dir
) {
682 addmodes
[ampos
++]=changes
->changes
[i
].flag
;
683 aapos
+=sprintf(addargs
+aapos
, "%s ", changes
->changes
[i
].str
->content
);
687 remmodes
[rmpos
++]=changes
->changes
[i
].flag
;
688 rapos
+=sprintf(remargs
+rapos
, "%s ", changes
->changes
[i
].str
->content
);
691 freesstring(changes
->changes
[i
].str
);
694 if (i
<changes
->changecount
) {
695 for (j
=i
;j
<changes
->changecount
;j
++)
696 changes
->changes
[j
-i
]=changes
->changes
[j
];
699 changes
->changecount
-= i
;
701 if ((ampos
+rmpos
)==0) {
706 addmodes
[ampos
]='\0';
707 remmodes
[rmpos
]='\0';
711 if (changes
->source
==NULL
||
712 (lp
=getnumerichandlefromchanhash(changes
->cp
->users
,changes
->source
->numeric
))==NULL
) {
713 /* User isn't on channel, hack mode */
714 strcpy(source
,mynumeric
->content
);
716 /* Check the user is local */
717 if (homeserver(changes
->source
->numeric
)!=mylongnum
) {
720 if ((*lp
&CUMODE_OP
)==0) {
721 localgetops(changes
->source
,changes
->cp
);
723 strcpy(source
,longtonumeric(changes
->source
->numeric
,5));
727 irc_send("%s M %s %s%s%s%s %s%s",source
,changes
->cp
->index
->name
->content
,
728 rmpos
? "-" : "", remmodes
,
729 ampos
? "+" : "", addmodes
, remargs
, addargs
);
732 /* If we have to flush everything out but didn't finish, go round again */
733 if (changes
->changecount
&& flushall
)
734 localsetmodeflush(changes
, 1);
739 * Sets modes for the user on the channel. This is now a stub routine that
740 * uses the new functions.
743 int localsetmodes(nick
*np
, channel
*cp
, nick
*target
, short modes
) {
746 localsetmodeinit (&changes
, cp
, np
);
747 localdosetmode_nick (&changes
, target
, modes
);
748 localsetmodeflush (&changes
, 1);
753 /* This function just sends the actual mode change,
754 * it assumes that the actual channel modes have been changed appropriately.
755 * This is unfortunately inconsistent with the rest of the localuser API..
758 void localusermodechange(nick
*np
, channel
*cp
, char *modes
) {
762 if (np
==NULL
|| (lp
=getnumerichandlefromchanhash(cp
->users
,np
->numeric
))==NULL
) {
763 /* User isn't on channel, hack mode */
764 strcpy(source
,mynumeric
->content
);
766 /* Check the user is local */
767 if (homeserver(np
->numeric
)!=mylongnum
) {
770 if ((*lp
&CUMODE_OP
)==0) {
773 strcpy(source
,longtonumeric(np
->numeric
,5));
777 irc_send("%s M %s %s",source
,cp
->index
->name
->content
,modes
);
781 /* This function actually sets the topic itself though.. a bit inconsistent :/ */
783 void localsettopic(nick
*np
, channel
*cp
, char *topic
) {
787 if (np
==NULL
|| (lp
=getnumerichandlefromchanhash(cp
->users
,np
->numeric
))==NULL
) {
788 /* User isn't on channel, hack mode */
789 strcpy(source
,mynumeric
->content
);
791 /* Check the user is local */
792 if (homeserver(np
->numeric
)!=mylongnum
) {
795 if ((*lp
&CUMODE_OP
)==0 && IsTopicLimit(cp
)) {
798 strcpy(source
,longtonumeric(np
->numeric
,5));
802 freesstring(cp
->topic
);
805 cp
->topic
=getsstring(topic
,TOPICLEN
);
806 cp
->topictime
=getnettime();
809 irc_send("%s T %s %u %u :%s",source
,cp
->index
->name
->content
,cp
->timestamp
,cp
->topictime
,(cp
->topic
)?cp
->topic
->content
:"");
813 void localkickuser(nick
*np
, channel
*cp
, nick
*target
, const char *message
) {
817 if (np
==NULL
|| (lp
=getnumerichandlefromchanhash(cp
->users
,np
->numeric
))==NULL
) {
818 /* User isn't on channel, hack mode */
819 strcpy(source
,mynumeric
->content
);
821 /* Check the user is local */
822 if (homeserver(np
->numeric
)!=mylongnum
) {
825 if ((*lp
&CUMODE_OP
)==0 && IsTopicLimit(cp
)) {
828 strcpy(source
,longtonumeric(np
->numeric
,5));
831 if ((lp
=getnumerichandlefromchanhash(cp
->users
,target
->numeric
))==NULL
)
834 /* Send the message to the network first in case delnickfromchannel()
835 * destroys the channel.. */
837 irc_send("%s K %s %s :%s",source
,cp
->index
->name
->content
,
838 longtonumeric(target
->numeric
,5), message
);
841 delnickfromchannel(cp
, target
->numeric
, 1);
844 void sendmessagetochannel(nick
*source
, channel
*cp
, char *format
, ... ) {
852 longtonumeric2(source
->numeric
,5,senderstr
);
855 /* 10 bytes of numeric, 5 bytes of fixed format + terminator = 17 bytes */
856 /* So max sendable message is 495 bytes. Of course, a client won't be able
857 * to receive this.. */
859 vsnprintf(buf
,BUFSIZE
-17,format
,va
);
863 irc_send("%s P %s :%s",senderstr
,cp
->index
->name
->content
,buf
);
867 void localinvite(nick
*source
, channel
*cp
, nick
*target
) {
869 /* Servers can't send invites */
873 /* CHECK: Does the sender have to be on the relevant channel? */
875 /* For some reason invites are sent with the target nick as
878 irc_send("%s I %s :%s",longtonumeric(source
->numeric
,5),
879 target
->nick
, cp
->index
->name
->content
);