Skip to content

Commit ae3bd7b

Browse files
author
drscholl
committed
added channel voice and muzzle commands
1 parent 6228dd0 commit ae3bd7b

9 files changed

+372
-118
lines changed

Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ distdir: $(DISTFILES)
285285
@for file in $(DISTFILES); do \
286286
d=$(srcdir); \
287287
if test -d $$d/$$file; then \
288-
cp -pr $$/$$file $(distdir)/$$file; \
288+
cp -pr $$d/$$file $(distdir)/$$file; \
289289
else \
290290
test -f $(distdir)/$$file \
291291
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \

README

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
opennap v0.32 (ALPHA)
1+
opennap v0.34 (ALPHA)
22
the open source (TM) napster server
33
===================================
4-
June 8, 2000
4+
June 22, 2000
55

66
http://opennap.sourceforge.net
77
IRC: #opennap on irc.openprojects.net
@@ -416,6 +416,22 @@ are implemented as additional functionality in the opennap server.
416416
join the specified channel. the user issuing the invite must be
417417
a member of the channel.
418418

419+
10211 give voice to speak in moderated channel [CLIENT]
420+
421+
Format: <channel> [user [user ...]]
422+
423+
10212 remove voice to speak in moderated channel [CLIENT]
424+
425+
Format: <channel> [user [user ...]]
426+
427+
10213 muzzle a user in a specific channel [CLIENT]
428+
429+
Format: <channel> <user> ["reason"]
430+
431+
10214 unmuzzle a user in specific channel [CLIENT]
432+
433+
Format: <channel> <user> ["reason"]
434+
419435
10300 share generic media file [CLIENT]
420436

421437
Format: "<filename>" <size> <md5> <content-type>

channel.c

+201-70
Original file line numberDiff line numberDiff line change
@@ -413,32 +413,8 @@ HANDLER (channel_op)
413413

414414
ASSERT (validate_connection (con));
415415
(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;
442418
/* check for permission */
443419
if (senderUser && senderUser->level < LEVEL_MODERATOR)
444420
{
@@ -484,12 +460,12 @@ HANDLER (channel_op)
484460
{
485461
if (ISUSER (user->con))
486462
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);
489465
chanUser->flags &= ~ON_OPERATOR;
490466
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);
493469
}
494470
}
495471
}
@@ -504,14 +480,14 @@ HANDLER (channel_op)
504480
if (user)
505481
{
506482
chanUser = find_chanuser (chan->users, user);
507-
if(chanUser)
483+
if (chanUser)
508484
{
509485
if (ISUSER (user->con))
510486
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);
513489
notify_ops (chan, "%s set %s as operator on channel %s",
514-
sender, suser, chan->name);
490+
sender, suser, chan->name);
515491
/* do this here so the user doesn't get the message twice */
516492
chanUser->flags |= ON_OPERATOR;
517493
}
@@ -543,8 +519,8 @@ notify_ops (CHANNEL * chan, const char *fmt, ...)
543519
chanUser = list->data;
544520
ASSERT (chanUser->magic == MAGIC_CHANUSER);
545521
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))
548524
queue_data (chanUser->user->con, buf, 4 + len);
549525
}
550526
}
@@ -666,7 +642,7 @@ HANDLER (channel_wallop)
666642
status otherwise, and is_chanop() will fail). mods+ are assumed to
667643
be trusted enough that the check for membership is not required. */
668644
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);
670646
}
671647

672648
static void
@@ -692,33 +668,8 @@ HANDLER (channel_mode)
692668

693669
(void) len;
694670
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;
722673
chanName = next_arg (&pkt);
723674
if (!chanName)
724675
{
@@ -742,10 +693,10 @@ HANDLER (channel_mode)
742693
if (ISUSER (con))
743694
send_cmd_pre (con, tag, "mode for channel ", "%s%s%s%s",
744695
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+
: "",
749700
(chan->flags & ON_CHANNEL_INVITE) ? " +INVITE" : "",
750701
(chan->flags & ON_CHANNEL_TOPIC) ? " +TOPIC" : "");
751702
return;
@@ -919,6 +870,186 @@ HANDLER (channel_invite)
919870
chan->name);
920871
}
921872

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] : "");
9241055
}

handler.c

+4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ static HANDLER Protocol[] = {
197197
{MSG_CLIENT_CHANNEL_WALLOP, channel_wallop}, /* 10208 */
198198
{MSG_CLIENT_CHANNEL_MODE, channel_mode}, /* 10209 */
199199
{MSG_CLIENT_CHANNEL_INVITE, channel_invite},/* 10210 */
200+
{MSG_CLIENT_CHANNEL_VOICE, channel_voice}, /* 10211 */
201+
{MSG_CLIENT_CHANNEL_UNVOICE, channel_voice},/* 10212 */
202+
{MSG_CLIENT_CHANNEL_MUZZLE, channel_muzzle},/* 10213 */
203+
{MSG_CLIENT_CHANNEL_UNMUZZLE, channel_muzzle},/* 10214 */
200204
{MSG_CLIENT_SHARE_FILE, share_file}, /* 10300 */
201205
{MSG_CLIENT_BROWSE_NEW, browse_new}, /* 10301 */
202206
};

0 commit comments

Comments
 (0)