27
27
static int tcl_chanlist STDVAR
31
32
struct chanset_t *chan;
32
struct flag_record plus = {FR_CHAN | FR_GLOBAL | FR_BOT, 0, 0, 0, 0, 0},
33
minus = {FR_CHAN | FR_GLOBAL | FR_BOT, 0, 0, 0, 0, 0},
34
user = {FR_CHAN | FR_GLOBAL | FR_BOT, 0, 0, 0, 0, 0};
33
struct flag_record plus = { FR_CHAN | FR_GLOBAL | FR_BOT, 0, 0, 0, 0, 0 },
34
minus = { FR_CHAN | FR_GLOBAL | FR_BOT, 0, 0, 0, 0, 0},
35
user = { FR_CHAN | FR_GLOBAL | FR_BOT, 0, 0, 0, 0, 0 };
36
37
BADARGS(2, 3, " channel ?flags?");
37
39
chan = findchan_by_dname(argv[1]);
39
41
Tcl_AppendResult(irp, "invalid channel: ", argv[1], NULL);
48
50
break_down_flags(argv[2], &plus, &minus);
49
f = (minus.global || minus.udef_global ||
50
minus.chan || minus.udef_chan || minus.bot);
51
f = (minus.global || minus.udef_global || minus.chan || minus.udef_chan ||
51
53
/* Return empty set if asked for flags but flags don't exist */
52
if (!plus.global && !plus.udef_global &&
53
!plus.chan && !plus.udef_chan && !plus.bot && !f)
54
if (!plus.global &&!plus.udef_global && !plus.chan && !plus.udef_chan &&
55
57
minus.match = plus.match ^ (FR_AND | FR_OR);
57
59
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
61
egg_snprintf(nuh, sizeof nuh, "%s!%s", m->nick, m->userhost);
62
m->user = get_user_by_host(nuh);
58
64
get_user_flagrec(m->user, &user, argv[1]);
59
65
user.match = plus.match;
60
66
if (flagrec_eq(&plus, &user)) {
61
67
if (!f || !flagrec_eq(&minus, &user))
62
Tcl_AppendElement(irp, m->nick);
68
Tcl_AppendElement(irp, m->nick);
229
static int tcl_ishalfop STDVAR
231
struct chanset_t *chan, *thechan = NULL;
234
BADARGS(2, 3, " nick ?channel?");
237
chan = findchan_by_dname(argv[2]);
240
Tcl_AppendResult(irp, "illegal channel: ", argv[2], NULL);
246
while (chan && (thechan == NULL || thechan == chan)) {
247
if ((mx = ismember(chan, argv[1])) && chan_hashalfop(mx)) {
248
Tcl_AppendResult(irp, "1", NULL);
253
Tcl_AppendResult(irp, "0", NULL);
191
257
static int tcl_isvoice STDVAR
193
259
struct chanset_t *chan, *thechan = NULL;
196
BADARGS(2, 3, " ?nick channel?");
262
BADARGS(2, 3, " nick ?channel?");
198
265
chan = findchan_by_dname(argv[2]);
304
static int tcl_washalfop STDVAR
306
struct chanset_t *chan;
309
BADARGS(3, 3, " nick channel");
311
chan = findchan_by_dname(argv[2]);
313
Tcl_AppendResult(irp, "illegal channel: ", argv[2], NULL);
316
if ((mx = ismember(chan, argv[1])) && chan_washalfop(mx))
317
Tcl_AppendResult(irp, "1", NULL);
319
Tcl_AppendResult(irp, "0", NULL);
237
323
static int tcl_onchan STDVAR
239
325
struct chanset_t *chan, *thechan = NULL;
241
327
BADARGS(2, 3, " nickname ?channel?");
243
330
chan = findchan_by_dname(argv[2]);
246
333
Tcl_AppendResult(irp, "illegal channel: ", argv[2], NULL);
247
334
return TCL_ERROR;
252
339
while (chan && (thechan == NULL || thechan == chan)) {
253
340
if (ismember(chan, argv[1])) {
733
861
comment = argv[3];
737
Tcl_AppendResult(irp, "need op", NULL);
864
if (!me_op(chan) && !me_halfop(chan)) {
865
Tcl_AppendResult(irp, "need op or halfop", NULL);
738
866
return TCL_ERROR;
743
871
/* Loop through all given nicks */
746
p = strchr(nick, ','); /* Search for beginning of next nick */
874
p = strchr(nick, ','); /* Search for beginning of next nick */
752
880
m = ismember(chan, nick);
881
if (!me_op(chan) && !(me_halfop(chan) && !chan_hasop(m))) {
882
Tcl_AppendResult(irp, "need op", NULL);
754
continue; /* Skip non-existant nicks */
755
m->flags |= SENTKICK; /* Mark as pending kick */
886
continue; /* Skip non-existant nicks */
887
m->flags |= SENTKICK; /* Mark as pending kick */
757
889
strcat(kicknick, ",");
758
strcat(kicknick, nick); /* Add to local queue */
890
strcat(kicknick, nick); /* Add to local queue */
761
893
/* Check if we should send the kick command yet */
775
static tcl_cmds tclchan_cmds[] =
777
{"chanlist", tcl_chanlist},
778
{"botisop", tcl_botisop},
779
{"botisvoice", tcl_botisvoice},
781
{"wasop", tcl_wasop},
782
{"isvoice", tcl_isvoice},
783
{"onchan", tcl_onchan},
784
{"handonchan", tcl_handonchan},
785
{"ischanban", tcl_ischanban},
786
{"ischanexempt", tcl_ischanexempt},
787
{"ischaninvite", tcl_ischaninvite},
788
{"ischanjuped", tcl_ischanjuped},
789
{"getchanhost", tcl_getchanhost},
790
{"onchansplit", tcl_onchansplit},
791
{"maskhost", tcl_maskhost},
792
{"getchanidle", tcl_getchanidle},
793
{"chanbans", tcl_chanbans},
794
{"chanexempts", tcl_chanexempts},
795
{"chaninvites", tcl_chaninvites},
796
{"hand2nick", tcl_hand2nick},
797
{"nick2hand", tcl_nick2hand},
798
{"getchanmode", tcl_getchanmode},
799
{"getchanjoin", tcl_getchanjoin},
800
{"flushmode", tcl_flushmode},
801
{"pushmode", tcl_pushmode},
802
{"resetbans", tcl_resetbans},
803
{"resetexempts", tcl_resetexempts},
804
{"resetinvites", tcl_resetinvites},
805
{"resetchan", tcl_resetchan},
806
{"topic", tcl_topic},
807
{"botonchan", tcl_botonchan},
808
{"putkick", tcl_putkick},
809
{"channame2dname", tcl_channame2dname},
810
{"chandname2name", tcl_chandname2name},
907
static tcl_cmds tclchan_cmds[] = {
908
{"chanlist", tcl_chanlist},
909
{"botisop", tcl_botisop},
910
{"botishalfop", tcl_botishalfop},
911
{"botisvoice", tcl_botisvoice},
913
{"wasop", tcl_wasop},
914
{"ishalfop", tcl_ishalfop},
915
{"washalfop", tcl_washalfop},
916
{"isvoice", tcl_isvoice},
917
{"onchan", tcl_onchan},
918
{"handonchan", tcl_handonchan},
919
{"ischanban", tcl_ischanban},
920
{"ischanexempt", tcl_ischanexempt},
921
{"ischaninvite", tcl_ischaninvite},
922
{"ischanjuped", tcl_ischanjuped},
923
{"getchanhost", tcl_getchanhost},
924
{"onchansplit", tcl_onchansplit},
925
{"maskhost", tcl_maskhost},
926
{"getchanidle", tcl_getchanidle},
927
{"chanbans", tcl_chanbans},
928
{"chanexempts", tcl_chanexempts},
929
{"chaninvites", tcl_chaninvites},
930
{"hand2nick", tcl_hand2nick},
931
{"nick2hand", tcl_nick2hand},
932
{"getchanmode", tcl_getchanmode},
933
{"getchanjoin", tcl_getchanjoin},
934
{"flushmode", tcl_flushmode},
935
{"pushmode", tcl_pushmode},
936
{"resetbans", tcl_resetbans},
937
{"resetexempts", tcl_resetexempts},
938
{"resetinvites", tcl_resetinvites},
939
{"resetchan", tcl_resetchan},
940
{"topic", tcl_topic},
941
{"botonchan", tcl_botonchan},
942
{"putkick", tcl_putkick},
943
{"channame2dname", tcl_channame2dname},
944
{"chandname2name", tcl_chandname2name},