-
Notifications
You must be signed in to change notification settings - Fork 0
/
mIRCd_mask.mrc
710 lines (669 loc) · 29.8 KB
/
mIRCd_mask.mrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
; mIRCd_mask.mrc
;
; This script contains the following command(s): ACCEPT, BLOCK, GLINE, SHUN, SILENCE, ZLINE
on *:signal:mIRCd_timeCheck:{
if (($hcount($mIRCd.glines) == 0) && ($hcount($mIRCd.shuns) == 0) && ($hcount($mIRCd.zlines) == 0)) { return }
var %this.time = $+($ctime,:)
if ($hfind($mIRCd.glines,%this.time,0,r).data > 0) { mIRCd.removePunishment $mIRCd.glines %this.time }
if ($hfind($mIRCd.shuns,%this.time,0,r).data > 0) { mIRCd.removePunishment $mIRCd.shuns %this.time }
if ($hfind($mIRCd.zlines,%this.time,0,r).data > 0) { mIRCd.removePunishment $mIRCd.zlines %this.time }
}
; Hash Tables
alias mIRCd.glines { return mIRCd[Glines] }
alias mIRCd.klines { return mIRCd[Klines] }
alias mIRCd.local { return $+(mIRCd[local],$bracket($1)) }
; `-> For local Shuns and Zlines. Like K-lines, these will not expire.
alias mIRCd.shuns { return mIRCd[Shuns] }
alias mIRCd.zlines { return mIRCd[Zlines] }
; IRCd Commands
alias mIRCd_command_accept {
; /mIRCd_command_accept <sockname> ACCEPT [<nick>|<-|+n!u@h>]
if (($pos(-+,$left($3,1)) == $null) || ($3 == $null)) {
; `-> Show any accept(s) (for a user).
var %this.sock = $1
if ($getSockname($3) != $null) {
var %this.sock = $v1
if (($bool_fmt($mIRCd(HIDE_CLIENT_LISTS)) == $true) || ($bool_fmt($mIRCd(HIDE_ACCEPT_LIST)) == $true)) {
if ($is_oper($1) == $false) { var %this.sock = $1 }
}
}
if ($hcount($mIRCd.accept(%this.sock)) == 0) {
mIRCd.sraw $1 $mIRCd.reply(162,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick))
return
}
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.accept(%this.sock))) {
inc %this.loop 1
var %this.mask = $hget($mIRCd.accept(%this.sock),%this.loop).item
mIRCd.sraw $1 $mIRCd.reply(161,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick),%this.mask)
}
mIRCd.sraw $1 $mIRCd.reply(162,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick))
return
}
var %this.flag = $left($3,1), %this.mask = $makeMask($right($3,-1))
if (%this.flag == -) {
if ($hfind($mIRCd.accept($1),%this.mask,0,w) == 0) { return }
var %this.loop = $hfind($mIRCd.accept($1),%this.mask,0,w)
while (%this.loop > 0) {
mIRCd.delAccept $1 $hfind($mIRCd.accept($1),%this.mask,%this.loop,w).item
dec %this.loop 1
}
mIRCd.raw $1 $+(:,$mIRCd.fulladdr($1)) ACCEPT $3
return
}
; ,-> Treat everything else as an addition.
if ($hcount($mIRCd.accept($1)) >= $mIRCd(MAXACCEPT)) {
if ((%this.flag == +) && ($is_accepted($1,%this.mask) == $false)) {
mIRCd.sraw $1 $mIRCd.reply(510,$mIRCd.reply($1,nick),%this.mask)
return
}
; `-> Unless setting the accept will clear up the list in some way.
}
var %this.acceptNumber = $hfind($mIRCd.accept($1),%this.mask,0,w)
while (%this.acceptNumber > 0) {
mIRCd.delAccept $1 $hfind($mIRCd.accept($1),%this.mask,%this.acceptNumber,w).item
dec %this.acceptNumber 1
}
mIRCd.addAccept $1 %this.mask
mIRCd.raw $1 $+(:,$mIRCd.fulladdr($1)) ACCEPT $3
}
alias mIRCd_command_block {
; /mIRCd_command_block <sockname> BLOCK [<nick>|<-|+n!u@h>]
if (($pos(-+,$left($3,1)) == $null) || ($3 == $null)) {
; `-> Show any block(s) (for a user).
var %this.sock = $1
if ($getSockname($3) != $null) {
var %this.sock = $v1
if (($bool_fmt($mIRCd(HIDE_CLIENT_LISTS)) == $true) || ($bool_fmt($mIRCd(HIDE_BLOCK_LIST)) == $true)) {
if ($is_oper($1) == $false) { var %this.sock = $1 }
}
}
if ($hcount($mIRCd.block(%this.sock)) == 0) {
mIRCd.sraw $1 $mIRCd.reply(164,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick))
return
}
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.block(%this.sock))) {
inc %this.loop 1
var %this.mask = $hget($mIRCd.block(%this.sock),%this.loop).item
mIRCd.sraw $1 $mIRCd.reply(163,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick),%this.mask)
}
mIRCd.sraw $1 $mIRCd.reply(164,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick))
return
}
var %this.flag = $left($3,1), %this.mask = $makeMask($right($3,-1))
if (%this.flag == -) {
if ($hfind($mIRCd.block($1),%this.mask,0,w) == 0) { return }
var %this.loop = $hfind($mIRCd.block($1),%this.mask,0,w)
while (%this.loop > 0) {
mIRCd.delBlock $1 $hfind($mIRCd.block($1),%this.mask,%this.loop,w).item
dec %this.loop 1
}
mIRCd.raw $1 $+(:,$mIRCd.fulladdr($1)) BLOCK $3
return
}
; ,-> Treat everything else as an addition.
if ($hcount($mIRCd.block($1)) >= $mIRCd(MAXBLOCK)) {
if ((%this.flag == +) && ($is_blocked($1,%this.mask) == $false)) {
mIRCd.sraw $1 $mIRCd.reply(509,$mIRCd.info($1,nick,%this.mask)
return
}
; `-> Unless setting the block will clear up the list in some way.
}
var %this.blockNumber = $hfind($mIRCd.block($1),%this.mask,0,w)
while (%this.blockNumber > 0) {
mIRCd.delBlock $1 $hfind($mIRCd.block($1),%this.mask,%this.blockNumber,w).item
dec %this.blockNumber 1
}
mIRCd.addBlock $1 %this.mask
mIRCd.raw $1 $+(:,$mIRCd.fulladdr($1)) BLOCK $3
}
alias mIRCd_command_gline {
; /mIRCd_command_gline <sockname> GLINE [<-|+!RrealName|#chan|user@host> <duration> :<reason>]
if ($is_oper($1) == $false) {
mIRCd.sraw $1 $mIRCd.reply(481,$mIRCd.info($1,nick))
return
}
var %this.flag = $left($3,1)
if (($pos(-+,%this.flag) == $null) || ($3 == $null)) {
; `-> Show G-lines.
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.glines)) {
inc %this.loop 1
var %this.item = $hget($mIRCd.glines,%this.loop).item
var %this.data = $hget($mIRCd.glines,%this.item)
mIRCd.sraw $1 $mIRCd.reply(247,$mIRCd.info($1,nick),%this.item,$left($gettok(%this.data,1,32),-1),$gettok(%this.data,2-,32))
}
mIRCd.sraw $1 $mIRCd.reply(281,$mIRCd.info($1,nick))
return
}
if (($5- == :) || ($5- == $null)) {
mIRCd.sraw $1 $mIRCd.reply(461,$mIRCd.info($1,nick),$2)
return
}
if ($4 !isnum 1-) {
mIRCd.sraw $1 $mIRCd.reply(515,$mIRCd.info($1,nick),$4)
return
}
var %this.what = $right($3,-1), %this.reason = $left($5-,$mIRCd(TOPICLEN))
if (%this.flag == -) {
if ($is_glined(%this.what) == $false) {
mIRCd.sraw $1 $mIRCd.reply(512,$mIRCd.info($1,nick),%this.what)
return
}
var %this.data = $hget($mIRCd.glines,%this.what)
mIRCd.serverNotice 512 $mIRCd.info($1,nick) removing local $iif(#* iswm %this.what,BADCHAN,GLINE) for $+(%this.what,$comma) expiring at $gettok(%this.data,1,32) $gettok(%this.data,2-,32)
mIRCd.deletePunishment $mIRCd.glines %this.what
return
}
; ,-> +
if ($left(%this.what,1) == $chr(35)) {
; `-> Ban a channel.
var %this.trim = $trimStars(%this.what)
if ($is_exists(%this.what).chan == $true) {
; ¦-> Make sure the channel exists first, because the restriction on wildcards could prevent G-lining a channel like:
; `-> #this***************chan
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local BADCHAN for $+(%this.trim,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.glines %this.trim $+($calc($ctime + $4),:) %this.reason
; `-> Add the G-line first to prevent anyone else joining it.
var %this.id = $getChanID(%this.what)
var %this.loop = $hcount($mIRCd.chanUsers(%this.id))
while (%this.loop > 0) {
var %this.sock = $hget($mIRCd.chanUsers(%this.id),%this.loop).item
mIRCd.sraw %this.sock KICK $mIRCd.info(%this.id,name) $mIRCd.info(%this.sock,nick) :Bad channel $parenthesis(%this.reason)
; `-> We don't need to inform the others, since they'll be joining them.
mIRCd.chanDelUser %this.id %this.sock
dec %this.loop 1
}
return
}
if ($is_glined(%this.trim) == $true) {
var %this.data = $hget($mIRCd.glines,%this.trim)
if ($gettok($left(%this.data,-1),1,32) > $calc($ctime + $4)) {
; `-> Revised time is less than the previous time; remove the G-line.
recurse_gline $1 GLINE $+(-,%this.trim) 1 $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) resetting expiration time on BADCHAN for $+(%this.trim,$comma) expiring at $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
mIRCd.addPunishment $mIRCd.glines %this.trim $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
return
}
if ($percentCheck($right(%this.trim,-1)) > 10) {
; `-> Mask too wide. (9% or less wildcards allowed.)
mIRCd.sraw $1 $mIRCd.reply(520,$mIRCd.info($1,nick),%this.trim)
return
}
; `-> Check for existing wildcard channels again and deal with them.
if ($hfind($mIRCd.chans,%this.trim,0,w).data > 0) {
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local BADCHAN for $+(%this.trim,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.glines %this.trim $+($calc($ctime + $4),:) %this.reason
; `-> Again, G-line first.
var %this.loop = $hfind($mIRCd.chans,%this.trim,0,w).data
while (%this.loop > 0) {
var %this.id = $hfind($mIRCd.chans,%this.trim,%this.loop,w).data
var %this.user = $hcount($mIRCd.chanUsers(%this.id))
while (%this.user > 0) {
var %this.sock = $hget($mIRCd.chanUsers(%this.id),%this.user).item
mIRCd.sraw %this.sock KICK $mIRCd.info(%this.id,name) $mIRCd.info(%this.sock,nick) :Bad channel $parenthesis(%this.reason)
mIRCd.chanDelUser %this.id %this.sock
dec %this.user 1
}
dec %this.loop 1
}
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local BADCHAN for $+(%this.trim,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.glines %this.trim $+($calc($ctime + $4),:) %this.reason
return
}
if ($left(%this.what,2) == !R) {
; `-> G-line a user with a matching realName.
var %this.name = $trimStars($right(%this.what,-2))
if ($percentCheck(%this.name) > 25) {
; `-> Mask too wide. (I'm only allowing <25% of wildcards in the realName.)
mIRCd.sraw $1 $mIRCd.reply(520,$mIRCd.info($1,nick),%this.name)
return
}
if ($is_glined(%this.name) == $true) {
var %this.data = $hget($mIRCd.glines,%this.name)
if ($gettok($left(%this.data,-1),1,32) > $calc($ctime + $4)) {
; `-> Revised time is less than the previous time; remove the G-line.
recurse_gline $1 GLINE $+(-!R,%this.name) 1 $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) resetting expiration time on GLINE for $+(!R,%this.name,$comma) expiring at $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
mIRCd.addPunishment $mIRCd.glines $+(!R,%this.name) $+($calc($ctime + $4),:) %this.reason
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local GLINE for $+(!R,%this.name,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.glines $+(!R,%this.name) $+($calc($ctime + $4),:) %this.reason
var %this.loop = $hcount($mIRCd.users)
while (%this.loop > 0) {
var %this.sock = $hget($mIRCd.users,%this.loop).item, %this.realName = $+(!R,$strip($mIRCd.info(%this.sock,realName)))
if ($is_glineMatch(%this.realName) == $true) {
mIRCd.serverNotice 512 G-line active for $mIRCd.info(%this.sock,nick) $parenthesis($gettok($mIRCd.fulladdr(%this.sock),2,33))
mIRCd.sraw %this.sock $mIRCd.reply(465,$mIRCd.info($1,nick),%this.reason)
mIRCd.errorUser %this.sock G-lined $parenthesis(%this.reason)
}
dec %this.loop 1
}
return
}
; ,-> user@host.
var %this.mask = $gettok($makeMask(%this.what),2,33)
if ($percentCheck($gettok(%this.mask,2,64)) > 0) {
; `-> Mask too wide. (No wildcards allowed in host.)
mIRCd.sraw $1 $mIRCd.reply(520,$mIRCd.info($1,nick),%this.mask)
return
}
if ($is_glined(%this.mask) == $true) {
var %this.data = $hget($mIRCd.glines,%this.mask)
if ($gettok($left(%this.data,-1),1,32) > $calc($ctime + $4)) {
; `-> Revised time is less than the previous time; remove the G-line.
recurse_gline $1 GLINE $+(-,%this.mask) 1 $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) resetting expiration time on GLINE for $+(%this.mask,$comma) expiring at $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
mIRCd.addPunishment $mIRCd.glines %this.mask $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local GLINE for $+(%this.mask,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.glines %this.mask $+($calc($ctime + $4),:) %this.reason
var %this.loop = $hcount($mIRCd.users)
while (%this.loop > 0) {
var %this.sock = $hget($mIRCd.users,%this.loop).item
if (($is_glineMatch($mIRCd.fulladdr(%this.sock)) == $true) || ($is_glineMatch($mIRCd.ipaddr(%this.sock)) == $true) || ($is_glineMatch($mIRCd.trueaddr(%this.sock)) == $true)) {
mIRCd.serverNotice 512 G-line active for $mIRCd.info(%this.sock,nick) $parenthesis($gettok($mIRCd.fulladdr(%this.sock),2,33))
mIRCd.sraw %this.sock $mIRCd.reply(465,$mIRCd.info($1,nick),%this.reason)
mIRCd.errorUser %this.sock G-lined $parenthesis(%this.reason)
}
dec %this.loop 1
}
}
alias mIRCd_command_shun {
; /mIRCd_command_shun <sockname> SHUN [<-|+!RrealName|user@host> <duration> :<reason>]
if ($is_oper($1) == $false) {
mIRCd.sraw $1 $mIRCd.reply(481,$mIRCd.info($1,nick))
return
}
var %this.flag = $left($3,1)
if (($pos(-+,%this.flag) == $null) || ($3 == $null)) {
; `-> List all shuns.
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.shuns)) {
inc %this.loop 1
var %this.item = $hget($mIRCd.shuns,%this.loop).item
var %this.data = $hget($mIRCd.shuns,%this.item)
mIRCd.sraw $1 $mIRCd.reply(290,$mIRCd.info($1,nick),%this.item,$left($gettok(%this.data,1,32),-1),$gettok(%this.data,2-,32))
}
if ($hcount($mIRCd.local(Shuns)) > 0) {
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.local(Shuns))) {
inc %this.loop 1
var %this.item = $hget($mIRCd.local(Shuns),%this.loop).item
var %this.data = $hget($mIRCd.local(Shuns),%this.item)
mIRCd.sraw $1 $mIRCd.reply(290,$mIRCd.info($1,nick),%this.item,N/A,%this.data)
}
}
mIRCd.sraw $1 $mIRCd.reply(291,$mIRCd.info($1,nick))
return
}
if (($5- == :) || ($5- == $null)) {
mIRCd.sraw $1 $mIRCd.reply(461,$mIRCd.info($1,nick),$2)
return
}
if ($4 !isnum 1-) {
mIRCd.sraw $1 $mIRCd.reply(515,$mIRCd.info($1,nick),$4)
return
}
var %this.what = $right($3,-1), %this.reason = $left($5-,$mIRCd(TOPICLEN))
if (%this.flag == -) {
if ($is_shunned(%this.what) == $false) {
mIRCd.sraw $1 $mIRCd.reply(594,$mIRCd.info($1,nick),$2)
return
}
var %this.data = $hget($mIRCd.shuns,%this.what)
mIRCd.serverNotice 512 $mIRCd.info($1,nick) removing local SHUN for $+(%this.what,$comma) expiring at $gettok(%this.data,1,32) $gettok(%this.data,2-,32)
mIRCd.deletePunishment $mIRCd.shuns %this.what
return
}
; ,-> +
if ($left(%this.what,2) == !R) {
; `-> Shun a user with a matching realName.
var %this.name = $trimStars($right(%this.what,-2))
if ($percentCheck(%this.name) > 25) {
; `-> Mask too wide. (I'm only allowing <25% of wildcards in the realName.)
mIRCd.sraw $1 $mIRCd.info(520,$mIRCd.info($1,nick),%this.name)
return
}
if ($is_shunned(%this.name) == $true) {
var %this.data = $hget($mIRCd.shuns,%this.name)
if ($gettok($left(%this.data,-1),1,32) > $calc($ctime + 4)) {
; `-> Revised time is less than the previous time; remove the shun.
recurse_shun $1 SHUN (-!R,%this.name) 1 $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) resetting expiration time on SHUN for $+(!R,%this.name,$comma) expiring at $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
mIRCd.addPunishment $mIRCd.shuns $+(!R,%this.name) $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local SHUN for $+(!R,%this.name,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.shuns $+(!R,%this.name) $+($calc($ctime + $4),:) %this.reason
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.users)) {
inc %this.loop 1
var %this.sock = $hget($mIRCd.users,%this.loop).item, %this.realName = $+(!R,$strip($mIRCd.info(%this.sock,realName)))
if ($is_shunMatch(%this.realName) == $true) {
mIRCd.serverNotice 512 Shun active for $mIRCd.info(%this.sock,nick) $parenthesis($gettok($mIRCd.fulladdr(%this.sock),2,33))
}
}
return
}
; ,-> user@host
var %this.mask = $gettok($makeMask(%this.what),2,33)
if ($percentCheck($gettok(%this.mask,2,64)) > 0) {
; `-> Mask too wide. (No wildcards allowed in host.)
mIRCd.sraw $1 $mIRCd.reply(520,$mIRCd.info($1,nick),%this.mask)
return
}
if ($is_shunned(%this.mask) == $true) {
var %this.data = $hget($mIRCd.shuns,%this.mask)
if ($gettok($left(%this.data,-1),1,32) > $calc($ctime + $4)) {
; `-> Revised time is less than the previous time; remove the shun.
recurse_shun $1 SHUN $+(-,%this.mask) 1 $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) resetting expiration time on SHUN for $+(%this.mask,$comma) expiring at $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
mIRCd.addPunishment $mIRCd.shuns %this.mask $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local SHUN for $+(%this.mask,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.shuns %this.mask $+($calc($ctime + $4),:) %this.reason
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.users)) {
inc %this.loop 1
var %this.sock = $hget($mIRCd.users,%this.loop).item
if (($is_shunMatch($mIRCd.fulladdr(%this.sock)) == $true) || ($is_shunMatch($mIRCd.ipaddr(%this.sock)) == $true) || ($is_shunMatch($mIRCd.trueaddr(%this.sock)) == $true)) {
mIRCd.serverNotice 512 Shun active for $mIRCd.info(%this.sock,nick) $parenthesis($gettok($mIRCd.fulladdr(%this.sock),2,33))
}
}
}
alias mIRCd_command_silence {
; /mIRCd_command_silence <sockname> SILENCE [<nick>|<-|+n!u@h>]
if (($pos(-+,$left($3,1)) == $null) || ($3 == $null)) {
; `-> Show any silence(s) (for a user).
var %this.sock = $1
if ($getSockname($3) != $null) {
var %this.sock = $v1
if (($bool_fmt($mIRCd(HIDE_CLIENT_LISTS)) == $true) || ($bool_fmt($mIRCd(HIDE_SILENCE_LIST)) == $true)) {
if ($is_oper($1) == $false) { var %this.sock = $1 }
}
}
if ($hcount($mIRCd.silence(%this.sock)) == 0) {
mIRCd.sraw $1 $mIRCd.reply(272,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick))
return
}
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.silence(%this.sock))) {
inc %this.loop 1
var %this.mask = $hget($mIRCd.silence(%this.sock),%this.loop).item
mIRCd.sraw $1 $mIRCd.reply(271,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick),%this.mask)
}
mIRCd.sraw $1 $mIRCd.reply(272,$mIRCd.info($1,nick),$mIRCd.info(%this.sock,nick))
return
}
var %this.flag = $left($3,1), %this.mask = $makeMask($right($3,-1))
if (%this.flag == -) {
if ($hfind($mIRCd.silence($1),%this.mask,0,w) == 0) { return }
var %this.loop = $hfind($mIRCd.silence($1),%this.mask,0,w)
while (%this.loop > 0) {
mIRCd.delSilence $1 $hfind($mIRCd.silence($1),%this.mask,%this.loop,w).item
dec %this.loop 1
}
mIRCd.raw $1 $+(:,$mIRCd.fulladdr($1)) SILENCE $3
return
}
; ,-> Treat everything else as an addition.
if ($hcount($mIRCd.silence($1)) >= $mIRCd(MAXSILENCE)) {
if ((%this.flag == +) && ($is_silenced($1,%this.mask) == $false)) {
mIRCd.sraw $1 $mIRCd.reply(511,$mIRCd.info($1,nick),%this.mask)
return
}
; `-> Unless setting the silence will clear up the list in some way.
}
var %this.silenceNumber = $hfind($mIRCd.silence($1),%this.mask,0,w)
while (%this.silenceNumber > 0) {
mIRCd.delSilence $1 $hfind($mIRCd.silence($1),%this.mask,%this.silenceNumber,w).item
dec %this.silenceNumber 1
}
mIRCd.addSilence $1 %this.mask
mIRCd.raw $1 $+(:,$mIRCd.fulladdr($1)) SILENCE $3
}
alias mIRCd_command_zline {
; /mIRCd_command_zline <sockname> ZLINE [<-|+ip> <duration> :<reason>]
if ($is_oper($1) == $false) {
mIRCd.sraw $1 $mIRCd.reply(481,$mIRCd.info($1,nick))
return
}
var %this.flag = $left($3,1)
if (($pos(-+,%this.flag) == $null) || ($3 == $null)) {
; `-> Show Z-lines.
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.zlines)) {
inc %this.loop 1
var %this.item = $hget($mIRCd.zlines,%this.loop).item
var %this.data = $hget($mIRCd.zlines,%this.item)
mIRCd.sraw $1 $mIRCd.reply(292,$mIRCd.info($1,nick),%this.item,$left($gettok(%this.data,1,32),-1),$gettok(%this.data,2-,32))
}
if ($hcount($mIRCd.local(Zlines)) > 0) {
var %this.loop = 0
while (%this.loop < $hcount($mIRCd.local(Zlines))) {
inc %this.loop 1
var %this.item = $hget($mIRCd.local(Zlines),%this.loop).item
var %this.data = $hget($mIRCd.local(Zlines),%this.item)
mIRCd.sraw $1 $mIRCd.reply(292,$mIRCd.info($1,nick),%this.item,N/A,%this.data)
}
}
mIRCd.sraw $1 $mIRCd.reply(293,$mIRCd.info($1,nick))
return
}
if (($5- == :) || ($5- == $null)) {
mIRCd.sraw $1 $mIRCd.reply(461,$mIRCd.info($1,nick),$2)
return
}
if ($4 !isnum 1-) {
mIRCd.sraw $1 $mIRCd.reply(515,$mIRCd.info($1,nick),$4)
return
}
var %this.ip = $right($3,-1)
if ($longip(%this.ip) == $null) {
mIRCd.sraw $1 $mIRCd.reply(595,$mIRCd.info($1,nick),%this.ip)
return
}
var %this.reason = $left($5-,$mIRCd(TOPICLEN))
if (%this.flag == -) {
if ($is_zlined(%this.ip) == $false) {
mIRCd.sraw $1 $mIRCd.reply(596,$mIRCd.info($1,nick),%this.ip)
return
}
var %this.data = $hget($mIRCd.zlines,%this.ip)
mIRCd.serverNotice 512 $mIRCd.info($1,nick) removing local ZLINE for $+(%this.ip,$comma) expiring at $gettok(%this.data,1,32) $gettok(%this.data,2-,32)
mIRCd.deletePunishment $mIRCd.zlines %this.ip
return
}
; ,-> +
if ($is_zlined(%this.ip) == $true) {
var %this.data = $hget($mIRCd.zlines,%this.ip)
if ($gettok($left(%this.data,-1),1,32) > $calc($ctime + $4)) {
; `-> Revised time is less than the previous time; remove the Z-line.
recurse_zline $1 ZLINE $+(-,%this.ip) 1 $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) resetting expiration time on ZLINE for (%this.ip,$comma) expiring at $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
mIRCd.addPunishment $mIRCd.zlines %this.ip $+($calc($ctime + $4),:) $gettok(%this.data,2-,32)
return
}
mIRCd.serverNotice 512 $mIRCd.info($1,nick) adding local ZLINE for $+(%this.ip,$comma) expiring at $+($calc($ctime + $4),:) %this.reason
mIRCd.addPunishment $mIRCd.zlines %this.ip $+($calc($ctime + $4),:) %this.reason
var %this.loop = $hcount($mIRCd.users)
while (%this.loop > 0) {
var %this.sock = $hget($mIRCd.users,%this.loop).item
if ($is_zlineMatch($sock(%this.sock).ip) == $true) {
mIRCd.serverNotice 512 Z-line active for $mIRCd.info(%this.sock,nick) $parenthesis($gettok($mIRCd.fulladdr(%this.sock),2,33))
mIRCd.sraw %this.sock $mIRCd.reply(465,$mIRCd.info(%this.sock,nick),%this.reason)
mIRCd.errorUser %this.sock Z-lined $parenthesis(%this.reason)
}
dec %this.loop 1
}
}
; Commands and Functions
alias gettokn {
var %c = \x $+ $base($3,10,16,2)
returnex $remove($gettok($regsubex($1,/(?<=^| %c )(?=$| %c )/gx,$lf),$2,$3),$lf)
}
alias is_accepted {
; $is_accepted(<sockname>,<mask>)
return $iif($hfind($mIRCd.accept($1),$2,0,w).item > 0,$true,$false)
}
alias is_acceptMatch {
; $is_acceptMatch(<sockname>,<fulladdr?>)
return $iif($hfind($mIRCd.accept($1),$2,0,W).item > 0,$true,$false)
}
alias is_blocked {
; $is_blocked(<sockname>,<mask>)
return $iif($hfind($mIRCd.block($1),$2,0,w).item > 0,$true,$false)
}
alias is_blockMatch {
; $is_blockMatch(<sockname>,<fulladdr?>)
return $iif($hfind($mIRCd.block($1),$2,0,W).item > 0,$true,$false)
}
alias is_banMatch {
; $is_banMatch(<chan ID>,<fulladdr?>)
return $iif($hfind($mIRCd.chanBans($1),$2,0,W).item > 0,$true,$false)
}
; `-> This one is for checking against fulladdresses. nick!user@host <-MATCHES-> nick!*@*, *!*@host, etc.
alias is_banned {
; $is_banned(<chan ID>,<mask>)
return $iif($hfind($mIRCd.chanBans($1),$2,0,w).item > 0,$true,$false)
}
; `-> Does the ban exist?
alias is_glined {
; $is_glined(<input>)
return $iif($hget($mIRCd.glines,$1) != $null,$true,$false)
}
; `-> 1:1.
alias is_glineMatch {
; $is_glineMatch(<input>)
return $iif($hfind($mIRCd.glines,$1,0,W).item > 0,$true,$false)
}
alias is_klineMatch {
; $is_klineMatch(<input>)
return $iif($hfind($mIRCd.klines,$1,0,W).item > 0,$true,$false)
}
alias is_shunned {
; $is_shunned(<input>)[.local]
return $iif($hget($iif($prop == local,$mIRCd.local(Shuns),$mIRCd.shuns),$1) != $null,$true,$false)
}
alias is_shunMatch {
; $is_shunMatch(<input>)[.local]
return $iif($hfind($iif($prop == local,$mIRCd.local(Shuns),$mIRCd.shuns),$1,0,W).item > 0,$true,$false)
}
; `-> 1:1.
alias is_silenced {
; $is_silenced(<sockname>,<mask>)
return $iif($hfind($mIRCd.silence($1),$2,0,w).item > 0,$true,$false)
}
alias is_silenceMatch {
; $is_silenceMatch(<sockname>,<fulladdr?>)
return $iif($hfind($mIRCd.silence($1),$2,0,W).item > 0,$true,$false)
}
alias is_zlined {
; $is_zlined(<ip>)[.local]
return $iif($hget($iif($prop == local,$mIRCd.local(Zlines),$mIRCd.zlines),$1) != $null,$true,$false)
}
alias is_zlineMatch {
; $is_zlineMatch(<ip>)[.local]
return $iif($hfind($iif($prop == local,$mIRCd.local(Zlines),$mIRCd.zlines),$1,0,W).item > 0,$true,$false)
}
alias makeMask {
; $makeMask(<input>)
if ($1 == $null) { return }
if ($count($1,!) == 0) {
if ($count($1,@) == 0) { return $trimStars($+($1,!*@*)) }
return $trimStars($+(*!,$iif($gettokn($1,1,64) != $null,$v1,*),@,$iif($gettokn($1,2,64) != $null,$v1,*)))
}
if ($count($1,@) == 0) { return $trimStars($+($iif($gettokn($1,1,33) != $null,$v1,*),!,$iif($gettokn($1,2,33) != $null,$v1,*),@*)) }
if ($calc($pos($1,@) - $pos($1,!)) == 1) { return $trimStars($+($iif($gettokn($1,1,33) != $null,$v1,*),!*@,$iif($gettokn($1,2,64) != $null,$v1,*))) }
if ($gettok($1,2,64) == $null) {
if ($pos($1,@,1) < $pos($1,!,1)) { return $trimStars($+($iif($gettokn($1,1,33) != $null,$v1,*),!*@*)) }
return $trimStars($+($iif($gettokn($1,1,33) != $null,$v1,*),!,$iif($gettokn($gettokn($1,1,64),2,33) != $null,$v1,$iif($gettokn($1,2,64) != $null,$v1,*)),@*))
}
if ($pos($1,@,1) < $pos($1,!,1)) { return $trimStars($+($iif($gettok($1,1,33) != $null,$v1,*),!*@*)) }
return $trimStars($+($iif($gettokn($1,1,33) != $null,$v1,*),!,$gettokn($1,2,33)))
}
; `-> v0.5. (It works, but I'm not entirely happy with this.)
alias mIRCd.addAccept {
; /mIRCd.addAccept <sockname> <mask>
hadd -m $mIRCd.accept($1) $2 $ctime
}
alias mIRCd.addBlock {
; /mIRCd.addBlock <sockname> <mask>
hadd -m $mIRCd.block($1) $2 $ctime
}
alias mIRCd.addSilence {
; /mIRCd.addSilence <sockname> <mask>
hadd -m $mIRCd.silence($1) $2 $ctime
}
alias mIRCd.addPunishment {
; /mIRCd.addPunishment <table> <#chan|ip|user@host> <expire time> <reason>
hadd -m $1 $2 $3 $4-
}
alias mIRCd.delAccept {
; /mIRCd.delAccept <sockname> <mask>
hdel $mIRCd.accept($1) $2
if ($hcount($mIRCd.accept($1)) == 0) { hfree $mIRCd.accept($1) }
; `-> Free the empty table.
}
alias mIRCd.delBlock {
; /mIRCd.delBlock <sockname> <mask>
hdel $mIRCd.block($1) $2
if ($hcount($mIRCd.block($1)) == 0) { hfree $mIRCd.block($1) }
; `-> Free the empty table.
}
alias mIRCd.deletePunishment {
; /mIRCd.deletePunishment <table> <item>
hdel $1 $2
}
alias mIRCd.delSilence {
; /mIRCd.delSilence <sockname> <mask>
hdel $mIRCd.silence($1) $2
if ($hcount($mIRCd.silence($1)) == 0) { hfree $mIRCd.silence($1) }
; `-> Free the empty table.
}
alias mIRCd.removePunishment {
; /mIRCd.removePunishment <table> <timestamp>
var %this.type = $mIRCd.glines GLINE, $mIRCd.shuns SHUN, $mIRCd.zlines ZLINE
var %this.table = $gettok($matchtok(%this.type,$1,1,44),1,32)
var %this.loop = $hfind(%this.table,$2,0,r).data
while (%this.loop > 0) {
var %this.item = $hfind(%this.table,$2,%this.loop,r).data
mIRCd.serverNotice 512 $iif(#* iswm %this.item,BADCHAN,$gettok($matchtok(%this.type,$1,1,44),2,32)) for %this.item expired $parenthesis($gettok($hget(%this.table,%this.item),2-,32))
mIRCd.deletePunishment %this.table %this.item
dec %this.loop 1
}
}
alias percentCheck {
; $percentCheck(<input>)
return $int($calc((($count($1,*) + $count($1,?)) / $len($1)) * 100))
}
alias recurse_gline { mIRCd_command_gline $1- }
alias recurse_shun { mIRCd_command_shun $1- }
alias recurse_zline { mIRCd_command_zline $1- }
; `-> These three are required.
alias trimStars {
; $trimStars(<input>)
var %this.string = $1, %this.string = $mid($1,$gettok($regsubex(%this.string,/(.)/g,$iif(\t != :,$+(\n,:))),1,58))
; `-> $1 must be set as a variable. Also, trim any :'s at the start again.
return $regsubex($str(.,$len(%this.string)),/./g,$iif($mid(%this.string,\n,1) == *,$iif($mid(%this.string,$calc(\n + 1),1) != *,$mid(%this.string,\n,1)),$mid(%this.string,\n,1)))
}
; EOF