180
199
if (match_my_nick(nick)) {
181
200
dprintf(idx, "I'm not going to kickban myself.\n");
184
m = ismember(chan, nick);
186
dprintf(idx, "%s is not on %s\n", nick, chan->dname);
188
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
189
u = get_user_by_host(s);
190
get_user_flagrec(u, &victim, chan->dname);
191
if ((chan_op(victim) || (glob_op(victim) && !chan_deop(victim))) &&
192
!(chan_master(user) || glob_master(user))) {
193
dprintf(idx, "%s is a legal op.\n", nick);
196
if ((chan_master(victim) || glob_master(victim)) &&
197
!(glob_owner(user) || chan_owner(user))) {
198
dprintf(idx, "%s is a %s master.\n", nick, chan->dname);
201
if (glob_bot(victim) && !(glob_owner(victim) || chan_owner(victim))) {
202
dprintf(idx, "%s is another channel bot!\n", nick);
206
(u_match_mask(global_exempts,s) || u_match_mask(chan->exempts, s))) {
207
dprintf(idx, "%s is permanent exempted!\n", nick);
210
if (m->flags & CHANOP)
211
add_mode(chan, '-', 'o', m->nick);
212
check_exemptlist(chan, s);
228
s1 = quickban(chan, m->userhost);
231
if (bantype == '@' || bantype == '-')
232
do_mask(chan, chan->channel.ban, s1, 'b');
235
dprintf(DP_SERVER, "KICK %s %s :%s\n", chan->name, m->nick, par);
236
m->flags |= SENTKICK;
237
u_addban(chan, s1, dcc[idx].nick, par, now + (60 * ban_time), 0);
238
dprintf(idx, "Okay, done.\n");
243
static void cmd_voice(struct userrec *u, int idx, char *par)
245
struct chanset_t *chan;
250
nick = newsplit(&par);
251
if (!(chan = has_op(idx, par)))
253
if (!nick[0] && !(nick = getnick(u->handle, chan))) {
254
dprintf(idx, "Usage: voice <nick> [channel]\n");
257
if (!channel_active(chan)) {
258
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
262
dprintf(idx, "I can't help you now because I'm not a chan op on %s.\n",
266
putlog(LOG_CMDS, "*", "#%s# (%s) voice %s %s", dcc[idx].nick,
267
dcc[idx].u.chat->con_chan, nick, par);
268
m = ismember(chan, nick);
270
dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
273
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
274
add_mode(chan, '+', 'v', nick);
275
dprintf(idx, "Gave voice to %s on %s\n", nick, chan->dname);
278
static void cmd_devoice(struct userrec *u, int idx, char *par)
280
struct chanset_t *chan;
285
nick = newsplit(&par);
286
if (!(chan = has_op(idx, par)))
288
if (!nick[0] && !(nick = getnick(u->handle, chan))) {
289
dprintf(idx, "Usage: devoice <nick> [channel]\n");
292
if (!channel_active(chan)) {
293
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
297
dprintf(idx, "I can't do that right now I'm not a chan op on %s.\n",
301
putlog(LOG_CMDS, "*", "#%s# (%s) devoice %s %s", dcc[idx].nick,
302
dcc[idx].u.chat->con_chan, nick, par);
303
m = ismember(chan, nick);
305
dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
308
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
309
add_mode(chan, '-', 'v', nick);
310
dprintf(idx, "Devoiced %s on %s\n", nick, chan->dname);
203
m = ismember(chan, nick);
205
dprintf(idx, "%s is not on %s\n", nick, chan->dname);
208
if (!me_op(chan) && chan_hasop(m)) {
209
dprintf(idx, "I can't help you now because halfops cannot kick ops.\n");
212
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
213
u = get_user_by_host(s);
214
get_user_flagrec(u, &victim, chan->dname);
215
if ((chan_op(victim) || (glob_op(victim) && !chan_deop(victim))) &&
216
!(chan_master(user) || glob_master(user))) {
217
dprintf(idx, "%s is a legal op.\n", nick);
220
if ((chan_master(victim) || glob_master(victim)) &&
221
!(glob_owner(user) || chan_owner(user))) {
222
dprintf(idx, "%s is a %s master.\n", nick, chan->dname);
225
if (glob_bot(victim) && !(glob_owner(user) || chan_owner(user))) {
226
dprintf(idx, "%s is another channel bot!\n", nick);
229
if (use_exempts && (u_match_mask(global_exempts, s) ||
230
u_match_mask(chan->exempts, s))) {
231
dprintf(idx, "%s is permanently exempted!\n", nick);
234
if (m->flags & CHANOP)
235
add_mode(chan, '-', 'o', m->nick);
236
check_exemptlist(chan, s);
252
s1 = quickban(chan, m->userhost);
255
if (bantype == '@' || bantype == '-')
256
do_mask(chan, chan->channel.ban, s1, 'b');
259
dprintf(DP_SERVER, "KICK %s %s :%s\n", chan->name, m->nick, par);
260
m->flags |= SENTKICK;
261
u_addban(chan, s1, dcc[idx].nick, par, now + (60 * chan->ban_time), 0);
262
dprintf(idx, "Okay, done.\n");
313
265
static void cmd_op(struct userrec *u, int idx, char *par)
395
355
get_user_flagrec(u, &victim, chan->dname);
396
356
if ((chan_master(victim) || glob_master(victim)) &&
397
357
!(chan_owner(user) || glob_owner(user))) {
398
dprintf(idx, "%s is a master for %s\n", m->nick, chan->dname);
358
dprintf(idx, "%s is a master for %s.\n", m->nick, chan->dname);
401
361
if ((chan_op(victim) || (glob_op(victim) && !chan_deop(victim))) &&
402
362
!(chan_master(user) || glob_master(user))) {
403
dprintf(idx, "%s has the op flag for %s\n", m->nick, chan->dname);
363
dprintf(idx, "%s has the op flag for %s.\n", m->nick, chan->dname);
406
366
add_mode(chan, '-', 'o', nick);
407
dprintf(idx, "Took op from %s on %s\n", nick, chan->dname);
367
dprintf(idx, "Took op from %s on %s.\n", nick, chan->dname);
370
static void cmd_halfop(struct userrec *u, int idx, char *par)
372
struct chanset_t *chan;
378
nick = newsplit(&par);
379
chan = get_channel(idx, par);
383
if (!nick[0] && !(nick = getnick(u->handle, chan))) {
384
dprintf(idx, "Usage: halfop <nick> [channel]\n");
388
get_user_flagrec(dcc[idx].user, &user, chan->dname);
389
m = ismember(chan, nick);
390
if (m && !chan_op(user) && (!glob_op(user) || chan_deop(user))) {
391
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
392
u2 = m->user ? m->user : get_user_by_host(s);
394
if (!u2 || strcmp(u2->handle, dcc[idx].nick) || (!chan_halfop(user) &&
395
(!glob_halfop(user) || chan_dehalfop(user)))) {
396
dprintf(idx, "You are not a channel op on %s.\n", chan->dname);
401
if (!channel_active(chan)) {
402
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
406
if (HALFOP_CANTDOMODE('h')) {
407
dprintf(idx, "I can't help you now because I'm not a chan op or halfop on "
408
"%s, or halfops cannot set +h modes.\n", chan->dname);
412
putlog(LOG_CMDS, "*", "#%s# (%s) halfop %s", dcc[idx].nick,
414
m = ismember(chan, nick);
416
dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
419
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
420
u = get_user_by_host(s);
421
get_user_flagrec(u, &victim, chan->dname);
422
if (chan_dehalfop(victim) || (glob_dehalfop(victim) && !glob_halfop(victim))) {
423
dprintf(idx, "%s is currently being auto-dehalfopped.\n", m->nick);
426
if (channel_bitch(chan) && !(chan_op(victim) || chan_op(victim) ||
427
(glob_op(victim) && !chan_deop(victim)) || (glob_halfop(victim) &&
428
!chan_dehalfop(victim)))) {
429
dprintf(idx, "%s is not a registered halfop.\n", m->nick);
432
add_mode(chan, '+', 'h', nick);
433
dprintf(idx, "Gave halfop to %s on %s.\n", nick, chan->dname);
436
static void cmd_dehalfop(struct userrec *u, int idx, char *par)
438
struct chanset_t *chan;
444
nick = newsplit(&par);
445
chan = get_channel(idx, par);
449
if (!nick[0] && !(nick = getnick(u->handle, chan))) {
450
dprintf(idx, "Usage: dehalfop <nick> [channel]\n");
454
get_user_flagrec(dcc[idx].user, &user, chan->dname);
455
m = ismember(chan, nick);
456
if (m && !chan_op(user) && (!glob_op(user) || chan_deop(user))) {
457
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
458
u2 = m->user ? m->user : get_user_by_host(s);
460
if (!u2 || strcmp(u2->handle, dcc[idx].nick) || (!chan_halfop(user) &&
461
(!glob_halfop(user) || chan_dehalfop(user)))) {
462
dprintf(idx, "You are not a channel op on %s.\n", chan->dname);
467
if (!channel_active(chan)) {
468
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
472
if (HALFOP_CANTDOMODE('h')) {
473
dprintf(idx, "I can't help you now because I'm not a chan op or halfop on "
474
"%s, or halfops cannot set -h modes.\n", chan->dname);
478
putlog(LOG_CMDS, "*", "#%s# (%s) dehalfop %s", dcc[idx].nick,
480
m = ismember(chan, nick);
482
dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
485
if (match_my_nick(nick)) {
486
dprintf(idx, "I'm not going to dehalfop myself.\n");
489
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
490
u = get_user_by_host(s);
491
get_user_flagrec(u, &victim, chan->dname);
492
if ((chan_master(victim) || glob_master(victim)) &&
493
!(chan_owner(user) || glob_owner(user))) {
494
dprintf(idx, "%s is a master for %s.\n", m->nick, chan->dname);
497
if ((chan_op(victim) || (glob_op(victim) && !chan_deop(victim))) &&
498
!(chan_master(user) || glob_master(user))) {
499
dprintf(idx, "%s has the op flag for %s.\n", m->nick, chan->dname);
502
if ((chan_halfop(victim) || (glob_halfop(victim) &&
503
!chan_dehalfop(victim))) && !(chan_master(user) || glob_master(user))) {
504
dprintf(idx, "%s has the halfop flag for %s.\n", m->nick, chan->dname);
507
add_mode(chan, '-', 'h', nick);
508
dprintf(idx, "Took halfop from %s on %s.\n", nick, chan->dname);
511
static void cmd_voice(struct userrec *u, int idx, char *par)
513
struct chanset_t *chan;
519
nick = newsplit(&par);
520
chan = get_channel(idx, par);
524
if (!nick[0] && !(nick = getnick(u->handle, chan))) {
525
dprintf(idx, "Usage: voice <nick> [channel]\n");
529
get_user_flagrec(dcc[idx].user, &user, chan->dname);
530
m = ismember(chan, nick);
532
/* By factoring out a !, this code becomes a lot clearer.
533
* If you are... not a (channel op, or a channel half op, or a global op
534
* without channel deop, or a global halfop without channel dehalfop)...
536
if (m && !(chan_op(user) || chan_halfop(user) || (glob_op(user) && !chan_deop(user)) || (glob_halfop(user) && !chan_dehalfop(user)))) {
537
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
538
u2 = m->user ? m->user : get_user_by_host(s);
540
if (!u2 || strcmp(u2->handle, dcc[idx].nick) || (!chan_voice(user) &&
541
(!glob_voice(user) || chan_quiet(user)))) {
542
dprintf(idx, "You are not a channel op or halfop on %s.\n", chan->dname);
547
if (!channel_active(chan)) {
548
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
552
if (HALFOP_CANTDOMODE('v')) {
553
dprintf(idx, "I can't help you now because I'm not a chan op or halfop on "
554
"%s, or halfops cannot set +v modes.\n", chan->dname);
558
putlog(LOG_CMDS, "*", "#%s# (%s) voice %s", dcc[idx].nick, chan->dname, nick);
559
m = ismember(chan, nick);
561
dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
564
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
565
add_mode(chan, '+', 'v', nick);
566
dprintf(idx, "Gave voice to %s on %s\n", nick, chan->dname);
569
static void cmd_devoice(struct userrec *u, int idx, char *par)
571
struct chanset_t *chan;
577
nick = newsplit(&par);
578
chan = get_channel(idx, par);
582
if (!nick[0] && !(nick = getnick(u->handle, chan))) {
583
dprintf(idx, "Usage: devoice <nick> [channel]\n");
587
get_user_flagrec(dcc[idx].user, &user, chan->dname);
588
m = ismember(chan, nick);
589
if (m && !(chan_op(user) || chan_halfop(user) || (glob_op(user) && !chan_deop(user)) || (glob_halfop(user) && !chan_dehalfop(user)))) {
590
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
591
u2 = m->user ? m->user : get_user_by_host(s);
593
if (!u2 || strcmp(u2->handle, dcc[idx].nick) || (!chan_voice(user) &&
594
(!glob_voice(user) || chan_quiet(user)))) {
595
dprintf(idx, "You are not a channel op or halfop on %s.\n", chan->dname);
600
if (!channel_active(chan)) {
601
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
605
if (HALFOP_CANTDOMODE('v')) {
606
dprintf(idx, "I can't help you now because I'm not a chan op or halfop on "
607
"%s, or halfops cannot set -v modes.\n", chan->dname);
611
putlog(LOG_CMDS, "*", "#%s# (%s) devoice %s", dcc[idx].nick,
613
m = ismember(chan, nick);
615
dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
618
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
619
add_mode(chan, '-', 'v', nick);
620
dprintf(idx, "Devoiced %s on %s\n", nick, chan->dname);
410
623
static void cmd_kick(struct userrec *u, int idx, char *par)
534
743
egg_snprintf(s1, sizeof s1, "%s %s", IRC_DESIRINGCHAN, chan->dname);
535
744
dprintf(idx, "%s, %d member%s, mode %s:\n", s1, chan->channel.members,
536
chan->channel.members == 1 ? "" : "s", s);
745
chan->channel.members == 1 ? "" : "s", s);
537
746
if (chan->channel.topic)
538
747
dprintf(idx, "%s: %s\n", IRC_CHANNELTOPIC, chan->channel.topic);
539
748
if (channel_active(chan)) {
749
/* find max nicklen and handlen */
750
maxnicklen = maxhandlen = 0;
751
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
752
if (strlen(m->nick) > maxnicklen)
753
maxnicklen = strlen(m->nick);
754
if ((m->user) && (strlen(m->user->handle) > maxhandlen))
755
maxhandlen = strlen(m->user->handle);
540
762
dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot)\n");
541
spaces[nick_len - 9] = 0;
542
spaces2[HANDLEN - 9] = 0;
543
dprintf(idx, " NICKNAME %s HANDLE %s JOIN IDLE USER@HOST\n",
545
spaces[nick_len - 9] = ' ';
546
spaces2[HANDLEN - 9] = ' ';
763
egg_snprintf(format, sizeof format, " %%-%us %%-%us %%-6s %%-5s %%s\n",
764
maxnicklen, maxhandlen);
765
dprintf(idx, format, "NICKNAME", "HANDLE", " JOIN", "IDLE", "USER@HOST");
547
766
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
548
767
if (m->joined > 0) {
549
if ((now - (m->joined)) > 86400)
550
egg_strftime(s, 6, "%d%b", localtime(&(m->joined)));
552
egg_strftime(s, 6, "%H:%M", localtime(&(m->joined)));
768
if ((now - (m->joined)) > 86400)
769
egg_strftime(s, 6, "%d%b", localtime(&(m->joined)));
771
egg_strftime(s, 6, "%H:%M", localtime(&(m->joined)));
554
strncpyz(s, " --- ", sizeof s);
555
if (m->user == NULL) {
556
egg_snprintf(s1, sizeof s1, "%s!%s", m->nick, m->userhost);
557
m->user = get_user_by_host(s1);
559
if (m->user == NULL) {
560
strncpyz(handle, "*", sizeof handle);
562
strncpyz(handle, m->user->handle, sizeof handle);
773
strncpyz(s, " --- ", sizeof s);
774
if (m->user == NULL) {
775
egg_snprintf(s1, sizeof s1, "%s!%s", m->nick, m->userhost);
776
m->user = get_user_by_host(s1);
779
strncpyz(handle, "*", sizeof handle);
781
strncpyz(handle, m->user->handle, sizeof handle);
564
782
get_user_flagrec(m->user, &user, chan->dname);
565
783
/* Determine status char to use */
566
if (glob_bot(user) && (glob_op(user)||chan_op(user)))
784
if (glob_bot(user) && (glob_op(user) || chan_op(user)))
568
786
else if (glob_bot(user))
570
788
else if (glob_owner(user))
572
790
else if (chan_owner(user))
574
792
else if (glob_master(user))
576
794
else if (chan_master(user))
578
796
else if (glob_deop(user))
580
798
else if (chan_deop(user))
800
else if (glob_dehalfop(user))
802
else if (chan_dehalfop(user))
582
804
else if (glob_autoop(user))
806
else if (chan_autohalfop(user))
808
else if (glob_autohalfop(user))
584
810
else if (chan_autoop(user))
586
812
else if (glob_op(user))
588
814
else if (chan_op(user))
816
else if (glob_halfop(user))
818
else if (chan_halfop(user))
590
820
else if (glob_quiet(user))
592
822
else if (chan_quiet(user))
594
824
else if (glob_gvoice(user))
596
826
else if (chan_gvoice(user))
598
828
else if (glob_voice(user))
600
830
else if (chan_voice(user))
602
832
else if (glob_friend(user))
604
834
else if (chan_friend(user))
616
846
else if (chan_exempt(user))
620
850
if (chan_hasop(m))
852
else if (chan_hashalfop(m))
622
854
else if (chan_hasvoice(m))
626
spaces[len = (nick_len - strlen(m->nick))] = 0;
627
spaces2[len2 = (HANDLEN - strlen(handle))] = 0;
629
dprintf(idx, "%c%s%s %s%s %s %c <- netsplit, %lus\n", chanflag,
630
m->nick, spaces, handle, spaces2, s, atrflag,
632
else if (!rfc_casecmp(m->nick, botname))
633
dprintf(idx, "%c%s%s %s%s %s %c <- it's me!\n", chanflag, m->nick,
634
spaces, handle, spaces2, s, atrflag);
636
/* Determine idle time */
637
if (now - (m->last) > 86400)
638
egg_snprintf(s1, sizeof s1, "%2lud", ((now - (m->last)) / 86400));
639
else if (now - (m->last) > 3600)
640
egg_snprintf(s1, sizeof s1, "%2luh", ((now - (m->last)) / 3600));
641
else if (now - (m->last) > 180)
642
egg_snprintf(s1, sizeof s1, "%2lum", ((now - (m->last)) / 60));
644
strncpyz(s1, " ", sizeof s1);
645
dprintf(idx, "%c%s%s %s%s %s %c %s %s\n", chanflag, m->nick,
646
spaces, handle, spaces2, s, atrflag, s1, m->userhost);
858
if (chan_issplit(m)) {
859
egg_snprintf(format, sizeof format,
860
"%%c%%-%us %%-%us %%s %%c <- netsplit, %%lus\n",
861
maxnicklen, maxhandlen);
862
dprintf(idx, format, chanflag, m->nick, handle, s, atrflag,
864
} else if (!rfc_casecmp(m->nick, botname)) {
865
egg_snprintf(format, sizeof format,
866
"%%c%%-%us %%-%us %%s %%c <- it's me!\n",
867
maxnicklen, maxhandlen);
868
dprintf(idx, format, chanflag, m->nick, handle, s, atrflag);
870
/* Determine idle time */
871
if (now - (m->last) > 86400)
872
egg_snprintf(s1, sizeof s1, "%2lud", ((now - (m->last)) / 86400));
873
else if (now - (m->last) > 3600)
874
egg_snprintf(s1, sizeof s1, "%2luh", ((now - (m->last)) / 3600));
875
else if (now - (m->last) > 180)
876
egg_snprintf(s1, sizeof s1, "%2lum", ((now - (m->last)) / 60));
878
strncpyz(s1, " ", sizeof s1);
879
egg_snprintf(format, sizeof format,
880
"%%c%%-%us %%-%us %%s %%c %%s %%s\n", maxnicklen,
882
dprintf(idx, format, chanflag, m->nick, handle, s, atrflag, s1,
650
885
if (chan_fakeop(m))
651
dprintf(idx, " (%s)\n", IRC_FAKECHANOP);
886
dprintf(idx, " (%s)\n", IRC_FAKECHANOP);
652
887
if (chan_sentop(m))
653
dprintf(idx, " (%s)\n", IRC_PENDINGOP);
888
dprintf(idx, " (%s)\n", IRC_PENDINGOP);
654
889
if (chan_sentdeop(m))
655
dprintf(idx, " (%s)\n", IRC_PENDINGDEOP);
890
dprintf(idx, " (%s)\n", IRC_PENDINGDEOP);
656
891
if (chan_sentkick(m))
657
dprintf(idx, " (%s)\n", IRC_PENDINGKICK);
892
dprintf(idx, " (%s)\n", IRC_PENDINGKICK);
660
895
dprintf(idx, "%s\n", IRC_ENDCHANINFO);
667
902
if (par[0] && (strchr(CHANMETA, par[0]) != NULL)) {
668
903
char *chname = newsplit(&par);
669
chan = has_op(idx, chname);
905
chan = get_channel(idx, chname);
671
chan = has_op(idx, "");
673
if (!channel_active(chan)) {
674
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
678
if (chan->channel.topic) {
679
dprintf(idx, "The topic for %s is: %s\n", chan->dname,
680
chan->channel.topic);
682
dprintf(idx, "No topic is set for %s\n", chan->dname);
684
} else if (channel_optopic(chan) && !me_op(chan)) {
685
dprintf(idx, "I'm not a channel op on %s and the channel is +t.\n",
688
dprintf(DP_SERVER, "TOPIC %s :%s\n", chan->name, par);
689
dprintf(idx, "Changing topic...\n");
690
putlog(LOG_CMDS, "*", "#%s# (%s) topic %s", dcc[idx].nick,
907
chan = get_channel(idx, "");
909
if (!chan || !has_oporhalfop(idx, chan))
912
if (!channel_active(chan)) {
913
dprintf(idx, "I'm not on %s right now!\n", chan->dname);
917
if (chan->channel.topic)
918
dprintf(idx, "The topic for %s is: %s\n", chan->dname,
919
chan->channel.topic);
921
dprintf(idx, "No topic is set for %s\n", chan->dname);
922
} else if (channel_optopic(chan) && !me_op(chan) && !me_halfop(chan))
923
dprintf(idx, "I'm not a channel op or halfop on %s and the channel is "
924
"+t.\n", chan->dname);
926
dprintf(DP_SERVER, "TOPIC %s :%s\n", chan->name, par);
927
dprintf(idx, "Changing topic...\n");
928
putlog(LOG_CMDS, "*", "#%s# (%s) topic %s", dcc[idx].nick,
696
933
static void cmd_resetbans(struct userrec *u, int idx, char *par)
699
935
struct chanset_t *chan;
701
chname = newsplit(&par);
705
chan = findchan_by_dname(chname);
707
dprintf(idx, "That channel doesn't exist!\n");
710
get_user_flagrec(u, &user, chname);
712
chan = findchan_by_dname(dcc[idx].u.chat->con_chan);
714
dprintf(idx, "Invalid console channel.\n");
717
get_user_flagrec(u, &user, dcc[idx].u.chat->con_chan);
719
if (glob_op(user) || chan_op(user)) {
720
putlog(LOG_CMDS, "*", "#%s# (%s) resetbans", dcc[idx].nick, chan->dname);
721
dprintf(idx, "Resetting bans on %s...\n", chan->dname);
936
char *chname = newsplit(&par);
938
chan = get_channel(idx, chname);
939
if (!chan || !has_oporhalfop(idx, chan))
942
putlog(LOG_CMDS, "*", "#%s# (%s) resetbans", dcc[idx].nick, chan->dname);
943
dprintf(idx, "Resetting bans on %s...\n", chan->dname);
726
947
static void cmd_resetexempts(struct userrec *u, int idx, char *par)
729
949
struct chanset_t *chan;
731
chname = newsplit(&par);
734
chan = findchan_by_dname(chname);
736
dprintf(idx, "That channel doesn't exist!\n");
739
get_user_flagrec(u, &user, chname);
741
chan = findchan_by_dname(dcc[idx].u.chat->con_chan);
743
dprintf(idx, "Invalid console channel.\n");
746
get_user_flagrec(u, &user, dcc[idx].u.chat->con_chan);
748
if (glob_op(user) || chan_op(user)) {
749
putlog(LOG_CMDS, "*", "#%s# (%s) resetexempts", dcc[idx].nick, chan->dname);
750
dprintf(idx, "Resetting exemptions on %s...\n", chan->dname);
950
char *chname = newsplit(&par);
952
chan = get_channel(idx, chname);
953
if (!chan || !has_oporhalfop(idx, chan))
956
putlog(LOG_CMDS, "*", "#%s# (%s) resetexempts", dcc[idx].nick, chan->dname);
957
dprintf(idx, "Resetting exempts on %s...\n", chan->dname);
755
961
static void cmd_resetinvites(struct userrec *u, int idx, char *par)
758
963
struct chanset_t *chan;
760
chname = newsplit(&par);
763
chan = findchan_by_dname(chname);
765
dprintf(idx, "That channel doesn't exist!\n");
768
get_user_flagrec(u, &user, chname);
770
chan = findchan_by_dname(dcc[idx].u.chat->con_chan);
772
dprintf(idx, "Invalid console channel.\n");
775
get_user_flagrec(u, &user, dcc[idx].u.chat->con_chan);
777
if (glob_op(user) || chan_op(user)) {
778
putlog(LOG_CMDS, "*", "#%s# (%s) resetinvites", dcc[idx].nick, chan->dname);
779
dprintf(idx, "Resetting invitations on %s...\n", chan->dname);
964
char *chname = newsplit(&par);
966
chan = get_channel(idx, chname);
967
if (!chan || !has_oporhalfop(idx, chan))
970
putlog(LOG_CMDS, "*", "#%s# (%s) resetinvites", dcc[idx].nick, chan->dname);
971
dprintf(idx, "Resetting resetinvites on %s...\n", chan->dname);
784
975
static void cmd_adduser(struct userrec *u, int idx, char *par)
946
1136
dprintf(idx, "%s\n", IRC_NOMONITOR);
948
1138
get_user_flagrec(u, &user, par);
949
if (!glob_master(user) && !chan_master(user)) {
950
dprintf(idx, "You are not a master on %s.\n", chan->dname);
951
} else if (!channel_active(chan)) {
952
dprintf(idx, "I'm not on %s at the moment!\n", chan->dname);
954
putlog(LOG_CMDS, "*", "#%s# reset %s", dcc[idx].nick, par);
955
dprintf(idx, "Resetting channel info for %s...\n", chan->dname);
956
reset_chan_info(chan);
1139
if (!glob_master(user) && !chan_master(user))
1140
dprintf(idx, "You are not a master on %s.\n", chan->dname);
1141
else if (!channel_active(chan))
1142
dprintf(idx, "I'm not on %s at the moment!\n", chan->dname);
1144
putlog(LOG_CMDS, "*", "#%s# reset %s", dcc[idx].nick, par);
1145
dprintf(idx, "Resetting channel info for %s...\n", chan->dname);
1146
reset_chan_info(chan);
959
} else if (!(u->flags & USER_MASTER)) {
1149
} else if (!(u->flags & USER_MASTER))
960
1150
dprintf(idx, "You are not a Bot Master.\n");
962
1152
putlog(LOG_CMDS, "*", "#%s# reset all", dcc[idx].nick);
963
1153
dprintf(idx, "Resetting channel info for all channels...\n");
964
1154
for (chan = chanset; chan; chan = chan->next) {
965
1155
if (channel_active(chan))
966
reset_chan_info(chan);
1156
reset_chan_info(chan);
971
static cmd_t irc_dcc[] =
973
{"adduser", "m|m", (Function) cmd_adduser, NULL},
974
{"deluser", "m|m", (Function) cmd_deluser, NULL},
975
{"reset", "m|m", (Function) cmd_reset, NULL},
976
{"resetbans", "o|o", (Function) cmd_resetbans, NULL},
977
{"resetexempts", "o|o", (Function) cmd_resetexempts, NULL},
978
{"resetinvites", "o|o", (Function) cmd_resetinvites, NULL},
979
{"act", "o|o", (Function) cmd_act, NULL},
980
{"channel", "o|o", (Function) cmd_channel, NULL},
981
{"deop", "o|o", (Function) cmd_deop, NULL},
982
{"invite", "o|o", (Function) cmd_invite, NULL},
983
{"kick", "o|o", (Function) cmd_kick, NULL},
984
{"kickban", "o|o", (Function) cmd_kickban, NULL},
985
{"msg", "o", (Function) cmd_msg, NULL},
986
{"voice", "o|o", (Function) cmd_voice, NULL},
987
{"devoice", "o|o", (Function) cmd_devoice, NULL},
988
{"op", "o|o", (Function) cmd_op, NULL},
989
{"say", "o|o", (Function) cmd_say, NULL},
990
{"topic", "o|o", (Function) cmd_topic, NULL},
991
{NULL, NULL, NULL, NULL}
1161
static cmd_t irc_dcc[] = {
1162
{"adduser", "m|m", (Function) cmd_adduser, NULL},
1163
{"deluser", "m|m", (Function) cmd_deluser, NULL},
1164
{"reset", "m|m", (Function) cmd_reset, NULL},
1165
{"resetbans", "o|o", (Function) cmd_resetbans, NULL},
1166
{"resetexempts", "o|o", (Function) cmd_resetexempts, NULL},
1167
{"resetinvites", "o|o", (Function) cmd_resetinvites, NULL},
1168
{"act", "o|o", (Function) cmd_act, NULL},
1169
{"channel", "o|o", (Function) cmd_channel, NULL},
1170
{"op", "o|o", (Function) cmd_op, NULL},
1171
{"deop", "o|o", (Function) cmd_deop, NULL},
1172
{"halfop", "ol|ol", (Function) cmd_halfop, NULL},
1173
{"dehalfop", "ol|ol", (Function) cmd_dehalfop, NULL},
1174
{"voice", "ov|ov", (Function) cmd_voice, NULL},
1175
{"devoice", "ov|ov", (Function) cmd_devoice, NULL},
1176
{"invite", "o|o", (Function) cmd_invite, NULL},
1177
{"kick", "lo|lo", (Function) cmd_kick, NULL},
1178
{"kickban", "lo|lo", (Function) cmd_kickban, NULL},
1179
{"msg", "o", (Function) cmd_msg, NULL},
1180
{"say", "o|o", (Function) cmd_say, NULL},
1181
{"topic", "lo|lo", (Function) cmd_topic, NULL},
1182
{NULL, NULL, NULL, NULL}