@@ -413,32 +413,8 @@ HANDLER (channel_op)
413
413
414
414
ASSERT (validate_connection (con ));
415
415
(void ) len ;
416
- if (ISSERVER (con ))
417
- {
418
- if (* pkt != ':' )
419
- {
420
- log ("channel_op(): missing sender from server message" );
421
- return ;
422
- }
423
- pkt ++ ;
424
- sender = next_arg (& pkt );
425
- ASSERT (sender != 0 );
426
- if (!is_server (sender ))
427
- {
428
- senderUser = hash_lookup (Users , sender );
429
- if (!senderUser )
430
- {
431
- log ("channel_op(): could not find user %s" , sender );
432
- return ;
433
- }
434
- }
435
- }
436
- else
437
- {
438
- ASSERT (ISUSER (con ));
439
- sender = con -> user -> nick ;
440
- senderUser = con -> user ;
441
- }
416
+ if (pop_user_server (con , tag , & pkt , & sender , & senderUser ))
417
+ return ;
442
418
/* check for permission */
443
419
if (senderUser && senderUser -> level < LEVEL_MODERATOR )
444
420
{
@@ -484,12 +460,12 @@ HANDLER (channel_op)
484
460
{
485
461
if (ISUSER (user -> con ))
486
462
send_cmd (user -> con , MSG_SERVER_NOSUCH ,
487
- "%s removed you as operator on channel %s" ,
488
- sender , chan -> name );
463
+ "%s removed you as operator on channel %s" ,
464
+ sender , chan -> name );
489
465
chanUser -> flags &= ~ON_OPERATOR ;
490
466
notify_ops (chan ,
491
- "%s removed %s as operator on channel %s" ,
492
- sender , user -> nick , chan -> name );
467
+ "%s removed %s as operator on channel %s" ,
468
+ sender , user -> nick , chan -> name );
493
469
}
494
470
}
495
471
}
@@ -504,14 +480,14 @@ HANDLER (channel_op)
504
480
if (user )
505
481
{
506
482
chanUser = find_chanuser (chan -> users , user );
507
- if (chanUser )
483
+ if (chanUser )
508
484
{
509
485
if (ISUSER (user -> con ))
510
486
send_cmd (user -> con , MSG_SERVER_NOSUCH ,
511
- "%s set you as operator on channel %s" ,
512
- sender , chan -> name );
487
+ "%s set you as operator on channel %s" ,
488
+ sender , chan -> name );
513
489
notify_ops (chan , "%s set %s as operator on channel %s" ,
514
- sender , suser , chan -> name );
490
+ sender , suser , chan -> name );
515
491
/* do this here so the user doesn't get the message twice */
516
492
chanUser -> flags |= ON_OPERATOR ;
517
493
}
@@ -543,8 +519,8 @@ notify_ops (CHANNEL * chan, const char *fmt, ...)
543
519
chanUser = list -> data ;
544
520
ASSERT (chanUser -> magic == MAGIC_CHANUSER );
545
521
if (ISUSER (chanUser -> user -> con ) &&
546
- ((chanUser -> flags & ON_OPERATOR ) ||
547
- chanUser -> user -> level > LEVEL_USER ))
522
+ ((chanUser -> flags & ON_OPERATOR ) ||
523
+ chanUser -> user -> level > LEVEL_USER ))
548
524
queue_data (chanUser -> user -> con , buf , 4 + len );
549
525
}
550
526
}
@@ -666,7 +642,7 @@ HANDLER (channel_wallop)
666
642
status otherwise, and is_chanop() will fail). mods+ are assumed to
667
643
be trusted enough that the check for membership is not required. */
668
644
pass_message_args (con , tag , ":%s %s %s" , sender -> nick , chan -> name , pkt );
669
- notify_ops (chan , "%s [ops/%s]: %s" , sender -> nick , chan -> name , pkt );
645
+ notify_ops (chan , "%s [ops/%s]: %s" , sender -> nick , chan -> name , pkt );
670
646
}
671
647
672
648
static void
@@ -692,33 +668,8 @@ HANDLER (channel_mode)
692
668
693
669
(void ) len ;
694
670
ASSERT (validate_connection (con ));
695
- if (ISSERVER (con ))
696
- {
697
- if (* pkt != ':' )
698
- {
699
- log ("channel_mode(): invalid server message from %s" , con -> host );
700
- return ;
701
- }
702
- pkt ++ ;
703
- senderName = next_arg (& pkt );
704
- if (!is_server (senderName ))
705
- {
706
- sender = hash_lookup (Users , senderName );
707
- if (!sender )
708
- {
709
- log ("channel_mode(): unknown user %s" , senderName );
710
- return ;
711
- }
712
- }
713
- else
714
- sender = 0 ; /*server */
715
- }
716
- else
717
- {
718
- ASSERT (ISUSER (con ));
719
- senderName = con -> user -> nick ;
720
- sender = con -> user ;
721
- }
671
+ if (pop_user_server (con , tag , & pkt , & senderName , & sender ))
672
+ return ;
722
673
chanName = next_arg (& pkt );
723
674
if (!chanName )
724
675
{
@@ -742,10 +693,10 @@ HANDLER (channel_mode)
742
693
if (ISUSER (con ))
743
694
send_cmd_pre (con , tag , "mode for channel " , "%s%s%s%s" ,
744
695
chan -> name ,
745
- (chan ->
746
- flags & ON_CHANNEL_PRIVATE ) ? " +PRIVATE" : "" ,
747
- (chan ->
748
- flags & ON_CHANNEL_MODERATED ) ? " +MODERATED" : "" ,
696
+ (chan -> flags & ON_CHANNEL_PRIVATE ) ? " +PRIVATE" :
697
+ "" ,
698
+ (chan -> flags & ON_CHANNEL_MODERATED ) ? " +MODERATED"
699
+ : "" ,
749
700
(chan -> flags & ON_CHANNEL_INVITE ) ? " +INVITE" : "" ,
750
701
(chan -> flags & ON_CHANNEL_TOPIC ) ? " +TOPIC" : "" );
751
702
return ;
@@ -919,6 +870,186 @@ HANDLER (channel_invite)
919
870
chan -> name );
920
871
}
921
872
922
- notify_ops (chan ,"%s invited %s to channel %s" ,sender -> nick ,user -> nick ,
923
- chan -> name );
873
+ notify_ops (chan , "%s invited %s to channel %s" , sender -> nick , user -> nick ,
874
+ chan -> name );
875
+ }
876
+
877
+ /* 10211/10212 [:sender] <channel> [user [user ...]]
878
+ voice/devoice users in a channel */
879
+ HANDLER (channel_voice )
880
+ {
881
+ char * senderName ;
882
+ char * chanName ;
883
+ char * nick ;
884
+ USER * sender = 0 , * user ;
885
+ CHANUSER * chanUser ;
886
+ LIST * list ;
887
+ CHANNEL * chan ;
888
+
889
+ (void ) len ;
890
+ ASSERT (validate_connection (con ));
891
+ if (pop_user_server (con , tag , & pkt , & senderName , & sender ))
892
+ return ;
893
+ chanName = next_arg (& pkt );
894
+ if (!chanName )
895
+ {
896
+ if (ISUSER (con ))
897
+ send_cmd (con , MSG_SERVER_NOSUCH ,
898
+ "channel voice failed: missing channel name" );
899
+ return ;
900
+ }
901
+ chan = hash_lookup (Channels , chanName );
902
+ if (!chan )
903
+ {
904
+ if (ISUSER (con ))
905
+ send_cmd (con , MSG_SERVER_NOSUCH ,
906
+ "channel voice failed: no such channel" );
907
+ return ;
908
+ }
909
+ if (!pkt )
910
+ {
911
+ if (ISUSER (con ))
912
+ {
913
+ /* return a list of voiced users */
914
+ send_cmd (con , MSG_CLIENT_PRIVMSG ,
915
+ "ChanServ Voiced users on channel %s" , chan -> name );
916
+ for (list = chan -> users ; list ; list = list -> next )
917
+ {
918
+ chanUser = list -> data ;
919
+ if (chanUser -> flags & ON_CHANNEL_VOICE )
920
+ send_cmd (con , MSG_CLIENT_PRIVMSG , "ChanServ %s" ,
921
+ chanUser -> user -> nick );
922
+ }
923
+ send_cmd (con , MSG_CLIENT_PRIVMSG ,
924
+ "ChanServ End of voiced users on channel %s" ,
925
+ chan -> name );
926
+ }
927
+ return ;
928
+ }
929
+ pass_message_args (con , tag , ":%s %s %s" , senderName , chan -> name , pkt );
930
+ while (pkt )
931
+ {
932
+ nick = next_arg (& pkt );
933
+ user = hash_lookup (Users , nick );
934
+ if (!user )
935
+ {
936
+ if (ISUSER (con ))
937
+ send_cmd (con , MSG_SERVER_NOSUCH ,
938
+ "channel voice: %s is not online" , nick );
939
+ continue ;
940
+ }
941
+ for (list = chan -> users ; list ; list = list -> next )
942
+ {
943
+ chanUser = list -> data ;
944
+ if (chanUser -> user == user )
945
+ {
946
+ if (tag == MSG_CLIENT_CHANNEL_UNVOICE )
947
+ chanUser -> flags &= ~ON_CHANNEL_VOICE ;
948
+ else
949
+ {
950
+ chanUser -> flags |= ON_CHANNEL_VOICE ;
951
+ chanUser -> flags &= ~ON_CHANNEL_MUZZLED ;
952
+ }
953
+ if (ISUSER (chanUser -> user -> con ))
954
+ {
955
+ send_cmd (chanUser -> user -> con , MSG_SERVER_NOSUCH ,
956
+ "%s %s voice on channel %s" ,
957
+ (sender
958
+ && sender -> cloaked ) ? "Operator" : senderName ,
959
+ (chanUser -> flags & ON_CHANNEL_VOICE ) ?
960
+ "gave you" : "removed your" , chan -> name );
961
+ }
962
+ notify_ops (chan , "%s %s voice %s %s on channel %s" ,
963
+ senderName ,
964
+ (tag ==
965
+ MSG_CLIENT_CHANNEL_VOICE ) ? "gave" : "removed" ,
966
+ (tag == MSG_CLIENT_CHANNEL_VOICE ) ? "to" : "from" ,
967
+ user -> nick , chan -> name );
968
+ break ;
969
+ }
970
+ }
971
+ if (!list )
972
+ {
973
+ if (ISUSER (con ))
974
+ send_cmd (con , MSG_SERVER_NOSUCH ,
975
+ "channel voice: %s is not on channel %s" ,
976
+ user -> nick , chan -> name );
977
+ }
978
+ }
979
+ }
980
+
981
+ /* 10213/10214 [:sender] <channel> <user> ["reason"]
982
+ channel muzzle/unmuzzle */
983
+ HANDLER (channel_muzzle )
984
+ {
985
+ char * senderName ;
986
+ USER * sender , * user ;
987
+ CHANNEL * chan ;
988
+ LIST * list ;
989
+ CHANUSER * chanUser ;
990
+ int ac = -1 ;
991
+ char * av [3 ];
992
+
993
+ (void ) len ;
994
+ ASSERT (validate_connection (con ));
995
+ if (pop_user_server (con , tag , & pkt , & senderName , & sender ))
996
+ return ;
997
+ if (pkt )
998
+ ac = split_line (av , FIELDS (av ), pkt );
999
+ if (ac < 2 )
1000
+ {
1001
+ unparsable (con );
1002
+ return ;
1003
+ }
1004
+ chan = hash_lookup (Channels , av [0 ]);
1005
+ if (!chan )
1006
+ {
1007
+ nosuchchannel (con );
1008
+ return ;
1009
+ }
1010
+ if (sender
1011
+ && (sender -> level < LEVEL_MODERATOR && !is_chanop (chan , sender )))
1012
+ {
1013
+ permission_denied (con );
1014
+ return ;
1015
+ }
1016
+ user = hash_lookup (Users , av [1 ]);
1017
+ if (!user )
1018
+ {
1019
+ nosuchuser (con );
1020
+ return ;
1021
+ }
1022
+ /* don't allow ops to muzzle mods+ */
1023
+ if (sender -> level != LEVEL_ELITE && sender -> level < user -> level )
1024
+ {
1025
+ permission_denied (con );
1026
+ return ;
1027
+ }
1028
+ for (list = chan -> users ; list ; list = list -> next )
1029
+ {
1030
+ chanUser = list -> data ;
1031
+ if (chanUser -> user == user )
1032
+ {
1033
+ if (tag == MSG_CLIENT_CHANNEL_MUZZLE )
1034
+ {
1035
+ chanUser -> flags |= ON_CHANNEL_MUZZLED ;
1036
+ chanUser -> flags &= ~ON_CHANNEL_VOICE ;
1037
+ }
1038
+ else
1039
+ chanUser -> flags &= ~ON_CHANNEL_MUZZLED ;
1040
+ if (ISUSER (chanUser -> user -> con ))
1041
+ send_cmd (chanUser -> user -> con , MSG_SERVER_NOSUCH ,
1042
+ "%s %smuzzled you on channel %s: %s" ,
1043
+ (sender
1044
+ && sender -> cloaked ) ? "Operator" : senderName ,
1045
+ (chanUser -> flags & ON_CHANNEL_MUZZLED ) ? "" : "un" ,
1046
+ chan -> name , (ac > 2 ) ? av [2 ] : "" );
1047
+ notify_ops (chan , "%s %smuzzled %s on channel %s: %s" , senderName ,
1048
+ (chanUser -> flags & ON_CHANNEL_MUZZLED ) ? "" : "un" ,
1049
+ user -> nick , chan -> name , (ac > 2 ) ? av [2 ] : "" );
1050
+ break ;
1051
+ }
1052
+ }
1053
+ pass_message_args (con , tag , ":%s %s %s \"%s\"" , senderName , chan -> name ,
1054
+ user -> nick , (ac > 2 ) ? av [2 ] : "" );
924
1055
}
0 commit comments