-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfiqbot.mrc
2460 lines (2327 loc) · 89.7 KB
/
fiqbot.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
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; ALIASES ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
;Build
alias fiqbot.build return 98
;Other's stuff
alias urlencode return $regsubex($1-,/\G(.)/g,$iif(($prop && \1 !isalnum) || !$prop,$chr(37) $+ $base($asc(\1),10,16),\1))
alias urldecode return $realace($regsubex($1-,/%(\w\w)/g,$chr($iif($base(\t,16,10) != 32,$v1,1))),$chr(1),$chr(32))
;Helpers
alias # return $chr(35)
alias fiqbot.cmd.isalias return $iif($gettok(%fiqbot_cmd_ [ $+ [ $1 ] ],4,58) != $null,$true,$false)
alias fiqbot.is_prefix return $iif($istok(%fiqbot_prefix,$1,32),$true,$false)
alias fiqbot.insertNetwork {
if ($asc($1) == $asc(#)) { return $network $+ $1 }
else return $1
}
alias fiqbot.removeNetwork {
var %len = $len($network)
if ($left($1,%len) == $network) { return $right($1,- $+ %len) }
else return $1
}
alias fiqbot.mode {
if ($asc($1) == $#) tokenize 32 $fiqbot.insertNetwork($1) $2-
if ($2) { return $iif($2 isincs %fiqbot_mode_ [ $+ [ $1 ] ],$true,$false) }
else {
if ($prop == data) { return $iif(%fiqbot_mode_ [ $+ [ $1 ] ],+ $+ %fiqbot_mode_ [ $+ [ $1 ] ],(none)) }
return %fiqbot_mode_ [ $+ [ $1 ] ]
}
}
alias fiqbot.mode.chg {
set -u0 %chanmode $false
echo -s testar: $2 och $fiqbot.removeNetwork($2)
if ($asc($fiqbot.removeNetwork($2)) == 35) {
%chanmode = $fiqbot.removeNetwork($2)
}
set -u0 %changedmode $2
var %i = 1
var %modes = $fiqbot.mode($2)
while (%i <= $len($3)) {
var %chr = $mid($3,%i,1)
if (%chr = -) { var %removemode = 1 }
elseif (%chr = +) { var %removemode = 0 }
elseif (%chr isincs $1) { var %modes = $iif(%removemode,$removecs(%modes,%chr),$iif(%chr isincs %modes,%modes,%modes $+ %chr)) }
inc %i
}
var %i = 1
while (%i <= $len(%modes)) { var %modes2 = %modes2 $+ . $+ $mid(%modes,%i,1) | inc %i }
var %modes = $remove($sorttok(%modes2,46),.)
var %oldmodes = $fiqbot.mode($2)
if (%modes == %oldmodes) { set -u1 %nochange 1 }
else {
set %fiqbot_mode_ $+ $2 %modes
echo -s test? %chanmode
if (%chanmode) {
if ((j isincs %modes) && (j isincs $3)) {
if ($me !ison %chanmode) { join %chanmode }
elseif (k isincs $chan(%chanmode).mode) {
set %fiqbot_key_ [ $+ [ $2 ] ] $gettok($chan(%chanmode).mode,2,32)
%send This channel has a key set. To make autojoin work properly, the channel key has been saved.
}
}
}
}
}
alias fiqbot.autojoin {
var %i = 1
while (%i <= $var(fiqbot_mode_ $+ $network $+ #*,0)) {
var %chan = $+($gettok($var(fiqbot_mode_ $+ $network $+ #*,%i),3-,$asc(_)))
if ($fiqbot.mode(%chan,j)) {
;compatibility with some networks that doesn't like empty keys (mibbit)
var %key = dummy
if (%fiqbot_key_ [ $+ [ %chan ] ]) { var %key = %fiqbot_key_ [ $+ [ %chan ] ] }
var %chanlist = $+(%chanlist,$chr(44),$fiqbot.removeNetwork(%chan))
var %keylist = $+(%keylist,$chr(44),%key)
}
inc %i
}
if (%chanlist) join $right(%chanlist,-1) $right(%keylist,-1)
}
alias fiqbot.whois {
%send Address: $2 $chr(124) $&
FIQ-bot access: $getaccess($2) $chr(124) $&
$1 has following flags set: $fiqbot.mode($address($1,2)).data
}
alias fiqbot.usage {
if (!$1) { %err Usage: fiqbot.usage <command> [channel] | halt }
%send Usage: $fiqbot.insertprefix($1,$2) $replace($fiqbot.cmd($1,2),(nothing),$null)
}
alias fiqbot.insertprefix {
var %prefixinfo
if ($2) {
if ($fiqbot.mode($fiqbot.insertNetwork($2),p).check) %prefixinfo = %fiqbot_prefix
else { %prefixinfo = %fiqbot_prefix $+ FIQ $+ $chr(160) }
}
return %prefixinfo $+ $lower($1)
}
alias fiqbot.cmd {
if ($remove($1,$chr(40),$chr(41),$chr(44)) != $1) {
tokenize 32 $remove($1,$chr(40),$chr(41),$chr(44)) $2-
}
var %cmd, %cmdraw
%cmd = $1
%cmdraw = $1
if ($gettok(%fiqbot_cmd_ [ $+ [ %cmd ] ],4,58)) {
%cmd = $gettok(%fiqbot_cmd_ [ $+ [ %cmd ] ],4,58)
}
if (!$2) return $iif(%fiqbot_cmd_ [ $+ [ %cmd ] ] != $null,$true,$false)
if ($2 == 4) return $gettok(%fiqbot_cmd_ [ $+ [ %cmdraw ] ],$2,58)
if ($2 isnum) return $gettok(%fiqbot_cmd_ [ $+ [ %cmd ] ],$2,58)
if ($2 == target) {
return %cmd
}
if ($2 == raw) {
return %fiqbot_cmd_ [ $+ [ %cmd ] ]
}
echo -s Error in $!fiqbot.cmd: Unknown $!2 requested: $2
return $false
}
alias fiqbot.welcome {
var %chan = $fiqbot.insertNetwork($1)
if ($isid) return %fiqbot_welcome_ [ $+ [ %chan ] ]
else { set %fiqbot_welcome_ [ $+ [ %chan ] ] $2- }
}
alias getaccess {
if (! isin $1) {
if (*!*@* !iswm $1) { var %fullhost = $address($1,5) }
else { var %fullhost = $1 }
var %i = 1 | while ($var(fiqbot_access_*,%i)) {
if ($right($var(fiqbot_access_*,%i),-15) iswm %fullhost) && ((!getaccess) || (%getaccess < $var(fiqbot_access_*,%i).value) && (%getaccess != -1)) { var %getaccess = $var(fiqbot_access_*,%i).value }
inc %i
}
}
var %getaccess = $iif(%getaccess,%getaccess,1)
if ($prop == num) { return %getaccess }
if (%getaccess == -1) { return Blacklisted user }
elseif (%getaccess == 1) { return Normal user }
elseif (%getaccess == 9) { return Master }
elseif (%getaccess == 10) { return Admin }
elseif (%getaccess == 11) { return Developer/Author }
elseif (%getaccess == 12) { return Local }
elseif (!%getaccess) { return Normal user }
else { return User level %getaccess }
}
alias getaccess.clear {
var %i = 1 | while ($var(fiqbot_access_*,%i)) {
if ($var(fiqbot_access_*,%i).value == 1) { unset %fiqbot_access_ [ $+ [ $right($var(fiqbot_access_*,%i),-15) ] ] }
inc %i
}
}
alias initcmd {
if (!%send) set -u0 %send echo -ag
var %reset = $false
if (($1 == -in-channel) && ($2 == Y)) {
%reset = $true
}
elseif (!%fiqbot_prefix) || (($1 != -in-channel) && ($?!="Do you want to unload all FIQ-bot variables?")) {
%reset = $true
}
if (%reset) {
unset %fiqbot*
set %fiqbot_prefix !
set %fiqbot_access_local 12
}
var %i = 1
while ($var(fiqbot_cmd_*,%i)) {
if (!$gettok($(,$var(fiqbot_cmd_*,%i)),4,58)) {
unset $var(fiqbot_cmd_*,%i)
}
inc %i
}
;
;Generic commands
;
set %fiqbot_cmd_access 1:[-rl] [nick/host] [level]:Add a nick's host or a host with userlevel [level]. With access-level 9 you can grant 8 or less, with level 10 you can grant full access. Use -r switch for removing access. Use -l switch for listing connected people with access. Every host type is supported.
set %fiqbot_cmd_alias 9:[-r] <name> [command]:Create an alias for another FIQ-bot command. Use -r to remove the alias. If no FIQ-bot command is used to set it as, it will show what the alias use right now.
set %fiqbot_cmd_constant 2:[-cdlr] [name|filter] [reply]:Make a custom command in FIQ-bot. The -c switch makes FIQ-bot reply in channel. The -r switch makes FIQ-bot use raw (level 5+). The -d switch deletes the constant. The -l switch lists current constants.¤Use &sN for parameter N, &nick for the nick, &chan for the channel.
set %fiqbot_cmd_forceerror 11:(nothing):Forces a custom error.
set %fiqbot_cmd_help 1:<command>:Displays help about a command.
set %fiqbot_cmd_hosts 9:(nothing):Displays the full host access list
set %fiqbot_cmd_join 9:<channel>:Makes FIQ-bot joining <channel>.
set %fiqbot_cmd_mode 4:<nick/host/#channel> [+/-flags]:Sets <nick/host/#channel> with flags. If no flags is specified, show current flags.¤ $&
Nick flags is +b (auto-ban), +d (no-op), +o (auto-op), +p (protect), +P (forces you to use prefix in query), +q (no-voice), +Q (makes the bot send to your query instead) +v (auto-voice).¤ $&
Channel flags is +b (force-deop if nick doesn't have level 5 or more), +d (ignore on access denied), +F (freeze-ops), +j (auto-join), +P (public - output sent in channel), +p (no-prefix), +u (ignore unknown commands), +v (voiceall), +w (enable-welcome).
set %fiqbot_cmd_official 1:[#channel]:Sets the current channel, or [#channel], to "official" and prevent the bot from joining this channel again. This can only be done by IRC Operators or people with user level 10 (Admin).
set %fiqbot_cmd_part 9:[#channel]:Makes FIQ-bot leave [#channel], or current channel if not specified.
set %fiqbot_cmd_prefix 9:[prefixes]:Shows or changes the prefix FIQ-bot use.
set %fiqbot_cmd_reload 11:[-u]:Reloads variables. If -u switch is used, unsets all variables and makes you level 10.
set %fiqbot_cmd_remote 10:<command>:Make FIQ-bot use a mIRC command with custom parameters.
set %fiqbot_cmd_restart 10:(nothing):Restarts the process
set %fiqbot_cmd_showcommands -1:[filter]:Shows available commands. If [filter] is specified, showing only commands matching [filter]. Possibility to use ? for 1 char match and * for zero-or-more char match.
set %fiqbot_cmd_source 1:(nothing):Links the FIQ-bot source code of this version
set %fiqbot_cmd_typeof 1:<command>:Display type of the command <command> (normal, constant, channelconstant or rawconstant)
set %fiqbot_cmd_version 1:(nothing):Returns the running version of FIQ-bot
set %fiqbot_cmd_whoami 1:(nothing):Display info about who you are for me.
set %fiqbot_cmd_whois 1:<nick>:Displays info about <nick>.
;
;Specific to tyrant version
;
set %fiqbot_cmd_apiraw 11:<query> [parameters]:Performs a manual API query and returns the JSON response. Parameters require ¶meter=foo syntax.
set %fiqbot_cmd_card 1:<name or ID>:Gives information about a card.
set %fiqbot_cmd_clientcode 11:[account] [new code]:Displays or set the assigned client code. If no code is set, or the code turns out to be incorrect, FIQ-bot will force a new code on a query by running "init".
set %fiqbot_cmd_conquestdebug 11:(nothing):Conquest debug log (output in status window)
set %fiqbot_cmd_faction 1:[-l] <name or ID>:Displays some information about the faction.
set %fiqbot_cmd_factionchat 3:[#channel] [on|off]:Turns faction chat announcing on or off for the current channel or [#channel].
set %fiqbot_cmd_factionchannel 11:[#channel] [internal account ID|reset] [nouser]:Shows, changes or removes a faction's account assign used. [nouser] means that the bot will ignore the fact that there's no user with that internal ID.
set %fiqbot_cmd_getid 1:<nick>:Displays user ID for specified nick.
set %fiqbot_cmd_hash 1:[add <deckname>/del/list] <deckname/cardlist/hash>:Displays the deck hash of the given cardlist, or a cardlist if the input was a deck hash. Add/del/list manages saved decks.
set %fiqbot_cmd_invasion 1:[[claim|unclaim|stuck|unstuck] <slot>|<add|set> <slot> <content>]:Manages a conquest invasion.¤ $&
Parameters are [claim|unclaim] - Claims (or unclaims) specified slot, [stuck|unstuck] - Marks or removes you as stuck on the slot, $&
<add|set> - Appends, or set from scratch, deck content for chosen slot.¤ $&
[slot] (only) - Shows details about the slot, i.e. HP, commander, deck, etc.
set %fiqbot_cmd_ison 1:<user-ID|username>:Checks whether or not an user is logged in to the game.
set %fiqbot_cmd_killsockets 11:(nothing):Resets all Tyrant requests and reloads the socket counter.
set %fiqbot_cmd_noalert 1:[check|[#channel] [nick [unset]|global|highlights|unset|reset]]:Disables war alert highlighting.¤ $&
Parameters are [check] - check current settings globally, for the current channel and for yourself globally and for the current channel, [nick] - disable alerts for [nick], [global] - disable alerts completely, [highlights] - keep alerts, but don't mass highlight, [reset] - unset channel/global settings, [unset] - unset setting for you or [nick].¤ $&
Use [#channel] to disable for a specific channel, either a specific nick or globally. Setting alert status for a specific nick which isn't you requires level 4+, setting channel alert status requires level 3+.
set %fiqbot_cmd_ownedcards 3:[-a] <name or ID>:Exports given player's owned cards to ownedcards.txt format. Use -a to list all cards that the user ever owned (this does NOT mean "list all cards in tyrant"). Unless you have level 5+, you can only check cards of factionmates.
set %fiqbot_cmd_player 1:[#channel] <name or ID> [netscore days]:Displays some information about the player. Displays extra info if the player is, or used to be, member of a channel's faction (or [#channel]), and if this is the case, [netscore days] will adjust the number of days back the netscore tracking goes.
set %fiqbot_cmd_postdata 11:<query> [parameters]:Shows post data for given query.
set %fiqbot_cmd_raid 1:[-l] <name or ID>:Displays raid hosted by given user. -l makes the raid key show up, if you have enough access (level 3).
set %fiqbot_cmd_rebuild 11:(nothing):Rebuilds the card and raid database.
set %fiqbot_cmd_spoiler 1:[#channel] [on|off]:Announces new Tyrant card spoilers in the channel, or [#channel] if specified.
set %fiqbot_cmd_startraid 11:<name/id>:Starts a raid and displays the join link.
set %fiqbot_cmd_setauth 11:<usertarget> <userid> <account token> <flashcode>:Sets the auth data which the bot uses. <usertarget> is a specified internal user ID, the rest is self explainatory.
set %fiqbot_cmd_setfaction 11:<usertarget> <faction ID> <faction points> <faction name>:Updates faction info for <usertarget> (internal account ID)
set %fiqbot_cmd_targets 1:[#channel] [reset|ignore [factions]|upcoming [1-6]]:Displays valid war targets for specified faction excluding those with infamy. Use [#channel] to check targets for that channel's faction.¤ $&
Parameters are [ignore] - changes the factions not to show list no matter what, [upcoming] - shows upcoming targets opening the coming 1-6h (default 2h),¤ $&
[reset] - reloads target list, useful during faction change (requires level 3+).
set %fiqbot_cmd_tiles 1:[#channel] [coordinates] [faction]:Displays tile information for [faction]. If no faction is specified, display tile information for the faction assigned to current channel, or [#channel].¤ $&
Use [coordinates] (in "12E,3N" format) to display detailed info about the given tile, and, if a channel assigned faction is used, amount of decks and if relevant, current invasion data. [faction] overrides [#channel] faction info.
set %fiqbot_cmd_tracker 11:<on|off|run>:Manually control FIQ-bot trackers. Parameters are on - Turn on tracking, off - Turn off tracking, run - Manually run the trackers once.
set %fiqbot_cmd_vault 1:[cards|current|reset]:Displays cards in the vault rotation. If [cards] are given, will set vault alert in-channel for specified cards when they hit vault, [current] shows current vault alerts, [reset] removes vault alerts.
set %fiqbot_cmd_war 1:[#channel] [id] [player]:Displays information about on going wars. Use [#channel] to check targets for that channel's faction. Use [id] to check out on a specific war. You can then specify [player] to look specifically for one player on either side.
set %fiqbot_cmd_warlog 1:[#channel] [amount] [faction]:Displays old wars, up to [amount]. [faction] limits it to only display wars against that faction. Use [#channel] to check targets for that channel's faction.
var %i = 1, %cmd
while ($var(fiqbot_cmd_*,%i)) {
if ($gettok($(,$var(fiqbot_cmd_*,%i)),4,58)) {
%cmd = $gettok($(,$var(fiqbot_cmd_*,%i)),4,58)
if (!%fiqbot_cmd_ [ $+ [ %cmd ] ]) {
unset $var(fiqbot_cmd_*,%i)
}
}
inc %i
}
;
;Random stuff
;
if (!%fiqbot_prefix) set %fiqbot_prefix !
set %fiqbot_access_local 12
if ($1 == -in-channel) { if ($2 == Y) { set %fiqbot_access_ $+ $address($3,2) 10 } }
elseif (%reset) { set %fiqbot_access_*!*@ $+ $?="Enter the auth you want to give max-access to" $+ .users.quakenet.org 10 }
if (%reset) {
%send Loading configuration...
load -rs $qt($+($scriptdir,fiqbot-config.mrc))
%send Loading Tyrant scripts...
load -rs $qt($+($scriptdir,tyrant-resources.mrc))
load -rs $qt($+($scriptdir,tyrant-tasks.mrc))
}
else {
reload -rs $qt($+($scriptdir,fiqbot.mrc))
reload -rs $qt($+($scriptdir,fiqbot-config.mrc))
reload -rs $qt($+($scriptdir,tyrant-resources.mrc))
reload -rs $qt($+($scriptdir,tyrant-tasks.mrc))
}
if (!$isalias(fiqbot.tyrant.version)) {
%send Error: Failed to load config from directory: $scriptdir :: Retrying...
load -rs $qt($+($scriptdir,fiqbot-config.mrc))
}
if (!$isalias(fiqbot.tyrant.downloadxml)) {
%send Error: Failed to load xml downloader from directory: $scriptdir :: Retrying...
load -rs $qt($+($scriptdir,tyrant-resources.mrc))
}
if (!$isalias(fiqbot.tyrant.login)) {
%send Error: Failed to load tyrant comm from directory: $scriptdir :: Retrying...
load -rs $qt($+($scriptdir,tyrant-tasks.mrc))
}
%send Loaded FIQ-bot version $fiqbot.version
}
;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; EVENTS ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
on *:INPUT:@fiqbot:{
if (!%PS1) %PS1 = fiq-bot$
aline @fiqbot 9 $+ %PS1 $1-
.msg $me $1-
}
on *:START:{
if (!%init_done) { initcmd | set %init_done 1 }
;window -e0 @fiqbot
}
on *:CONNECT:{
if ($authinfo) { .auth $authinfo }
if ($fiqbot.channel) join $fiqbot.channel
if ($fiqbot.trackerchannel) join $fiqbot.trackerchannel
fiqbot.autojoin
}
on *:PART:*:if ($nick == $me) && (($chan == $fiqbot.channel) || ($chan == $fiqbot.trackerchannel)) join $fiqbot.channel
on *:JOIN:*:{
if (%official_ [ $+ [ $fiqbot.insertNetwork($chan) ] ]) && ($chan != $fiqbot.channel) { part $chan Official channel | return }
elseif ($nick == $me) {
if (!%fiqbot_joined_ [ $+ [ $fiqbot.insertNetwork($chan) ] ]) { set %fiqbot_mode_ $+ $fiqbot.insertNetwork($chan) p | set %fiqbot_joined_ $+ $fiqbot.insertNetwork($chan) 1 }
}
if ($fiqbot.welcome($chan)) && ($fiqbot.mode($chan,w).check) { .notice $nick $chr(91) $+ $chan $+ $chr(93) $fiqbot.welcome($chan)) }
if ($me isop $chan) {
if ($fiqbot.mode($address($nick,2),o).check) { mode $chan +o $nick }
elseif ($fiqbot.mode($address($nick,2),v).check) { mode $chan +v $nick }
elseif ($fiqbot.mode($address($nick,2),b).check) { mode $chan +b $address($nick,2) | kick $chan $nick Banned }
elseif ($fiqbot.mode($chan,v).check) { mode $chan +v $nick }
}
}
on @*:OP:*:{
if ($nick == $me) { return }
if ($opnick == $me) { return }
if ($nick == Q) { return }
if (($fiqbot.mode($address($opnick,2),d).check)) { mode $chan -o $opnick }
elseif ($fiqbot.mode($address($opnick,2),b).check) && ((%fiqbot_access_ [ $+ [ $address($opnick,2) ] ] < 5) || (!%fiqbot_access_ [ $+ [ $address($opnick,2) ] ])) { mode $chan -o $opnick }
elseif ($fiqbot.mode($address($opnick,2),F).check) { mode $chan -o $opnick }
}
on @*:VOICE:*:{
if ($nick == $me) { return }
if ($vnick == $me) { return }
if ($fiqbot.mode($address($vnick,2),q).check) { mode $chan -v $vnick }
elseif ($fiqbot.mode($chan,b).check) && ((%fiqbot_access_ [ $+ [ $address($opnick,2) ] ] < 3) || (!%fiqbot_access_ [ $+ [ $address($vnick,2) ] ])) { mode $chan -v $vnick }
}
on @*:DEOP:*:{
if ($nick == $me) { return }
if ($opnick == $me) { return }
if ($nick == Q) { return }
if ($fiqbot.mode($address($opnick,2),p).check) && ($fiqbot.mode($address($opnick,2),o).check) { mode $chan +o $opnick }
elseif ($fiqbot.mode($fiqbot.insertNetwork($chan),F).check) { mode $chan +o $opnick }
}
on *:TEXT:!showprefix:*:{
if ($asc(%fiqbot_prefix) > 26) { .notice $nick Current prefix: %fiqbot_prefix }
else { .notice $nick Current prefix: ^ $+ $base($calc( $asc(%fiqbot_prefix) + 9),10,36) }
}
raw 313:*:{
if ($4 == %officialnick) {
set %official_ $+ %officialchan 1
%officialsend Done. Channel will now be prevented from joining.
part %officialchan This channel will not be joined anymore.
timerstaff off
}
}
on *:TEXT:rootme*:?:{
if (!$fiqbot.rootpass) return
if ($2 == $fiqbot.rootpass) {
set %fiqbot_access_ $+ $fulladdress 11
.notice $nick Well, ok.
}
}
on *:TEXT:*:*:{
;make sure that the dedicated admin account is admin.
if ($fiqbot.rootaccount) {
set %fiqbot_access_ [ $+ [ $fiqbot.rootaccount ] ] 11
}
;reset MODE command variables
unset %nochange
unset %changedmode
;prevent infinite loop
if ($nick == $me) { return }
;set -u0 is used to create global variables which are erased
;on script exit
set -u0 %send .notice $nick
set -u0 %err .notice $nick [Error] -
set -u0 %access $getaccess($fulladdress).num
set -u0 %access_name $getaccess($fulladdress)
set -u0 %host $address($nick,2)
set -u0 %query $iif(!$chan,$true,$false)
;prefixinfo variable is used to show how to execute commands
;with the correct prefix properly
;chanmode +p makes it use shortprefix (!HELP), query makes no prefix
var %prefixinfo
if ($fiqbot.mode($fiqbot.insertNetwork($chan),p).check) {
%prefixinfo = $gettok(%fiqbot_prefix,1,32)
}
else { %prefixinfo = $gettok(%fiqbot_prefix,1,32) $+ FIQ $+ $chr(160) }
if ((%query) && (!$fiqbot.mode(%host,P))) unset %prefixinfo
;determine prefix usage
;!FIQ <command>
if (($right($1,3) == FIQ) && ($fiqbot.is_prefix($left($1,-3)))) {
var %prefix = long
}
else {
;!<command>
;loop the prefixes variable to attempt to find one which was used
var %i = 0
while (%i < $gettok(%fiqbot_prefix,0,32)) {
inc %i
var %prefix_check = $gettok(%fiqbot_prefix,%i,32)
if ($left($1,$len(%prefix_check)) == %prefix_check) {
var %prefix = short
tokenize 32 a $right($1,- $+ $len(%prefix_check)) $2-
break
}
}
}
;max access for localuser
if ($nick == $me) {
set -u0 %send echo @fiqbot
set -u0 %access 12
set -u0 %access_name Self
}
;tokenizing trickery to make sure $N- contains the correct info
;regardless of using prefix or not (no prefix means used in query)
if (!%prefix) tokenize 32 a $1-
;return if no command was used (caused by stuff like "!FIQ" without params
if ($2 == $null) { return }
;determine whether or not the prefix is valid, return if not
;also manages where to send the output of the command which was given
if (%query) {
if ($fiqbot.mode(%host,P).check) && (!%prefix) return
if ($fiqbot.mode(%host,Q)) set -u0 %send msg $nick
}
else {
if (!%prefix) { return }
if ($fiqbot.mode($fiqbot.insertNetwork($chan),P)) set -u0 %send msg $chan
}
;escape input for the command name to prevent evil evalutions
tokenize 32 $1 $remove($2,$chr(44),$chr(40),$chr(41)) $3-
;branch from here (if none of these happens, there's insufficient access)
if (!$fiqbot.cmd($2)) { goto unknowncmd }
elseif (%access >= $fiqbot.cmd($2,1)) { goto $fiqbot.cmd($2,target) }
:accdenied
if ($chan) && ($fiqbot.mode($fiqbot.insertNetwork($chan),d).check) { return }
%send Access denied. You need level $fiqbot.cmd($2,1) $chr(124) You are: $getaccess($fulladdress) (level %access $+ )
return
:unknowncmd
if ($2 == $null) return
if ($2 == dev) { goto dev }
elseif (%addon_ [ $+ [ $2 ] ]) { %addon_cmd_ [ $+ [ $2 ] ] $nick $chan $3- | return }
elseif (%constant_ [ $+ [ $2 ] ]) {
var %constantreply = $replace(%constant_ [ $+ [ $2 ] ],&s1-,$3-,&s1,$3,&s2,$4,&s3,$5,&s4,$6,&s5,$7,&s6,$8,&nick,$nick,&chan,$chan)
if (%constantInChannel_ [ $+ [ $2 ] ]) { msg $chan %constantreply }
elseif (%constantUseRaw_ [ $+ [ $2 ] ]) { raw %constantreply }
else { %send %constantreply }
return
}
elseif ($chan) && ($fiqbot.mode($fiqbot.insertNetwork($chan),u).check) { return }
elseif (%fiqbot_autoremote) && (%access > 10) { tokenize 32 a a $2- | goto remote }
else { %send Unknown command ( $+ $2 $+ ). For a list of commands, type $fiqbot.insertprefix(showcommands,$chan) }
return
:ACCESS
if (!$3) || ($3 == -r) && (!$4) { fiqbot.usage $2 $chan | return }
if ($3 == -r) { tokenize 32 a a $4 1 }
elseif ($3 == -l) {
%send Listing connected people with access -1 or 2+ (level:nick)
var %i = 1
while ($ial(*,%i)) {
if ($getaccess($ial(*,%i)).num != 1) { set -nl %buffer %buffer $getaccess($ial(*,%i)).num $+ : $+ $gettok($ial(*,%i),1,33) $+ , }
inc %i
}
%send $iif(!%buffer,(none),$left(%buffer,-1))
return
}
if (!$4) { tokenize 32 a whois $3 | goto whois }
if (%access < 3) { %send You can only change people's access level at access level 3+ | return }
if ($address($3,2)) { var %targethost = $address($3,2) }
else var %targethost = $3
if (*!*@* !iswm %host) { %send Invalid host. | return }
var %hostaccess = $getaccess(%targethost).num
if (%hostaccess < 1) %hostaccess = 10
if (. isin $4 || $4 !isnum) { %send Level must be a number. | return }
if (%hostaccess >= %access) && (%access < 10) && (%targethost !iswm $fulladdress) || (%hostaccess > 10) { %send You cannot change access for people with access $getaccess(%targethost) | return }
else { var %give = $4 }
if (%give > 10) { var %give = 10 }
if (%access < 10) && (%give >= %access) {
%give = %access
if (%targethost !iswm $fulladdress) dec %give
}
if (%access < 10) && (%give < 1) { %give = 1 }
set %fiqbot_access_ [ $+ [ %targethost ] ] %give
write access_log.txt $nick $+ : $+ $fulladdress $+ : $+ $4 $+ : $+ %give $+ : $+ %targethost $+ : $+ $iif($ial(%targethost,1),$ial(%targethost,1),NOT_FOUND)
%send Done. Current access for $3 $+ : $getaccess(%targethost)
getaccess.clear
return
:ALIAS
if ((!$3) || (($3 == -r) && (!$4))) { fiqbot.usage $2 $chan | return }
if ($3 == -r) {
if (!$fiqbot.cmd($4,4)) { %send Alias doesn't exists. | return }
else { unset %fiqbot_cmd_ [ $+ [ $4 ] ] | %send Done }
}
else {
if (!$4) {
if (!$fiqbot.cmd($3,4)) { %send Alias doesn't exists. | return }
else { %send $3 is alias for the command: $fiqbot.cmd($3,4) }
}
else {
if ($3 !isalnum) { %send Alias name may not contain characters other than a-z, A-Z, 0-9. | return }
if (($fiqbot.cmd($3)) && ($3 == $fiqbot.cmd($3,target))) { %send You cannot override default commands. | return }
else {
if (!$fiqbot.cmd($4)) { %send $4 is an unknown command. | return }
elseif ($fiqbot.cmd($4,4)) { %send You can't create an alias for an alias. | return }
else { set %fiqbot_cmd_ $+ $3 $+(x:x:x:,$4) | %send Done }
}
}
}
return
:CONSTANT
if (!$4) && ($3 != -l) && ($left($3,1) == -) || (!$3) { fiqbot.usage $2 $chan | return }
if ($3 == -c) {
if ($4 !isalnum) { %send Constant name may not contain characters other than a-z, A-Z, 0-9. | return }
if ($fiqbot.cmd($4)) { %send Command $4 already exists. | return }
set %constant_ $+ $4 $5-
set %constantInChannel_ $+ $4 1
if (%access <= 4) && (%constantUseRaw_ [ $+ [ $4 ] ]) unset %constantUseRaw_ $+ $4
}
elseif ($3 == -r) {
if ($4 !isalnum) { %send Constant name may not contain characters other than a-z, A-Z, 0-9. | return }
if ($fiqbot.cmd($4)) { %send Command $4 already exists. | return }
if (%access > 4) { unset %constantInChannel_ [ $+ [ $4 ] ] | set %constantUseRaw_ $+ $4 1 }
set %constant_ $+ $4 $5-
}
elseif ($3 == -d) {
if (!%constant_ [ $+ [ $4 ] ]) { %send Constant " $+ $4 $+ " doesn't exists. | return }
unset %constant_ [ $+ [ $4 ] ]
unset %constantInChannel_ [ $+ [ $4 ] ]
unset %constantUseRaw_ [ $+ [ $4 ] ]
}
elseif ($3 == -l) {
var %i = 1
while ($var(constant_*,%i)) {
if ((!$4) || ($4 iswm $right($var(constant_*,%i),-12))) {
var %buffer2 = %buffer2 $right($var(constant_*,%i),-10) $+ $chr(44)
}
inc %i
}
%send Constants: $iif(%buffer2,%buffer2,(none))
return
}
elseif (!$4) {
if (!%constant_ [ $+ [ $3 ] ]) { %send Unknown constant: $3 | return }
%send Constant type: $iif(%constantInChannel_ [ $+ [ $3 ] ],channelsend,$iif(%constantUseRaw_ [ $+ [ $3 ] ],rawsend,normal)) $chr(124) Message: %constant_ [ $+ [ $3 ] ]
return
}
else {
if ($3 !isalnum) { %send Constant name may not contain characters other than a-z, A-Z, 0-9. | return }
if ($fiqbot.cmd($3)) { %send Command $3 already exists. | return }
set %constant_ $+ $3 $4-
}
%send Done.
return
:DEV
if (%access < 11) { tokenize 32 a dev | goto unknowncmd }
if ($3 == $null) { %send dev: cmd script clearhosts resetall set su | return }
elseif ($3 == set) {
if ($4 == $null) { %send dev/set: autoremote }
elseif ($4 == autoremote) { set %fiqbot_autoremote $iif($5 == false,0,$5) | %send Autoremote set }
else { %send Syntax error }
return
}
elseif ($3 == clearhosts) {
if (!$4) { %send dev/clearhosts: confirm }
elseif ($4 == confirm) {
unset %fiqbot_access*
set %fiqbot_access_ $+ $wildsite 11
%send Host Address List cleared.
}
else { %send Syntax error }
return
}
elseif ($3 == resetall) {
if (!$4) { %send dev/resetall: confirm }
elseif ($4 == confirm) {
if (!$5) { %send dev/resetall/confirm: really_do_this }
elseif ($5 == really_do_this) {
initcmd --in-channel Y $nick
set %fiqbot_access_ $+ $wildsite 11
}
else { %send Syntax error }
return
}
else { %send Syntax error }
return
}
elseif ($3 == cmd) {
if ($4 == $null) { %send dev/cmd: add }
elseif ($4 == add) {
if ($5 == $null) { %send dev/cmd/add: alias full }
if ($5 == alias) { tokenize 32 a alias $6- | goto alias }
if ($5 == full) {
if ($9 == $null) { %send dev/cmd/add/full: <accesslevel> <name> <script id> <help info, seperate syntax information from message with :, use (nothing) if no params is required> | return }
var %lvl = $6, %name = $7, %id = $8, %helpsyntax = $gettok($9-,1,58), %helpmsg = $gettok($5-,2,58)
if (!%fiqbot_script_ [ $+ [ %id ] ]) { %send ID not found. | return }
if (!$read($script, w, *BEGIN OF CUSTOM*)) { %send Couldn't match following expected if: (!$read($script, w, *END OF CUSTOM*)) || Debug: $readn | return }
else { noop $read($script, w, *BEGIN OF CUSTOM*,$calc($readn + 2)) }
var %i = 1
var %line = $readn
inc %line
write -il $+ %line $script : $+ %name
inc %line
while (%fiqbot_script_ [ $+ [ %id ] $+ [ _ ] $+ [ %i ] ] != $null) {
write -il $+ %line $script %fiqbot_script_ [ $+ [ %id ] $+ [ _ ] $+ [ %i ] ]
inc %line
inc %i
}
write -il $+ %line $script return
set %fiqbot_cmd_ $+ %name $+(%lvl,:,%helpsyntax,:,%helpmsg)
unset %fiqbot_script_ [ $+ [ %id ] ]
unset %fiqbot_script_ [ $+ [ %id ] $+ [ _* ] ]
%send Command created successfully. Bot will now reload the script.
reload -rs $script
}
}
else { %send Syntax error }
return
}
elseif ($3 == script) {
if ($4 == $null) { %send dev/script: edit }
elseif ($4 == edit) {
if ($7 == $null) { %send dev/script/edit: <id, will make one if not exist> <line> <code> | return }
set %fiqbot_script_ $+ $5 1
set %fiqbot_script_ $+ $5 $+ _ $+ $6 $7-
}
else { %send Syntax error }
return
}
elseif ($3 == su) {
if ($4 == $null) { %send dev/su: setaccess }
elseif ($4 == setaccess) {
if ($6 == $null) { %send dev/su/setaccess: <hostmask> <level> }
else {
set %fiqbot_access_ $+ $5 $6
%send successful
}
return
}
else { %send Syntax error }
}
else %send Syntax error.
return
:FORCEERROR
var %script = error.command
var %line = 1
goto error
:HELP
if (!$3) { goto showcommands }
elseif (!$fiqbot.cmd($3)) { %send Unknown command: $3 $+ . | return }
if ($fiqbot.cmd($3,1) > %access) { %send You don't have sufficient access to use $3 $+ . | return }
fiqbot.usage $3 $chan
%send Least access level required: $fiqbot.cmd($3,1)
var %i = 1
while (%i <= $gettok($fiqbot.cmd($3,3),0,164)) {
%send $$gettok($fiqbot.cmd($3,3),%i,164)
inc %i
}
if ($fiqbot.cmd($3,4)) { %send $3 is an alias for the command: $fiqbot.cmd($3,4) }
return
:HOSTS
%send Host Address List
var %i = 1
while ($var(fiqbot_access_*,%i)) {
unset %sent
if ((!$3) || ($3 iswm $right($var(fiqbot_access_*,%i),-12))) { set -nl %buffer %buffer $right($var(fiqbot_access_*,%i),-15) $+ $chr(44) }
if ($len(%buffer) > 400) { %send %buffer | set -nl %buffer $null | set -u1 %sent 1 }
inc %i
}
if (!%sent) %send $iif(!%buffer,(none),$left(%buffer,-1))
return
:JOIN
if (!$3) { fiqbot.usage $2 $chan | return }
if (, isin $3) { %send I don't join multiple channels simultaneously. | return }
if (%official_ [ $+ [ $gettok($3,1,44) ] ]) { %send This channel is official. The channel couldn't be joined. | return }
set -u3 %fiqbot_joinedby $nick
join $gettok($3,1,44) $gettok($4,1,44)
%send Done.
return
:MODE
if (!$3) { fiqbot.usage $2 $chan | return }
if (, isin $3) && ($left($3,1) == $chr($asc(#))) { %send , is invalid in channel names | return }
if (!$4) { %send Flags for $3 $+ : $iif($fiqbot.mode($iif($address($3,2),$address($3,2),$fiqbot.insertNetwork($3))),+ $+ $fiqbot.mode($iif($address($3,2),$address($3,2),$fiqbot.insertNetwork($3))),(none)) | return }
elseif ($left($3,1) == $#) { fiqbot.mode.chg bdFjPpuvw $fiqbot.insertNetwork($3-) }
else { fiqbot.mode.chg bdopPqQv $iif($address($3,2),$address($3,2),$3) $4- }
if (%changedmode) {
if (%nochange) { %send Nothing changed. Probably your flag specification were invalid. | return }
else { %send Done. Flags for $3 $+ : $iif($fiqbot.mode($iif($address($3,2),$address($3,2),$fiqbot.insertNetwork($3))),+ $+ $fiqbot.mode($iif($address($3,2),$address($3,2),$fiqbot.insertNetwork($3))),(none)) }
}
return
:OFFICIAL
var %chan = $3
if (!$3) %chan = $chan
if (!%chan) { %send You have to specify a channel to part. | return }
if (, isin %chan) { %send I don't leave multiple channels simultaneously. | return }
if ($getaccess($fulladdress) != Admin) {
set -u3 %officialnick $nick
set -u3 %officialchan %chan
set -u3 %officialsend %send
whois $nick
.timerstaff 1 3 %send You haven't enough access and you're not an IRC Operator (or the status couldn't be detected)
}
else {
set %official_ $+ %chan 1
part %chan This channel will not be joined anymore.
%send Done. Channel will now be prevented from joining.
}
return
:PART
var %chan = $3
if (!$3) %chan = $chan
if (!%chan) { %send You have to specify a channel to part. | return }
if (, isin %chan) { %send I don't leave multiple channels simultaneously. | return }
if (%chan == $fiqbot.channel) || (%chan == $fiqbot.trackerchannel) { %send I don't part that channel. | return }
part $3
%send Done.
return
:PREFIX
if (!$3) %send Current prefix: %fiqbot_prefix
else {
set %fiqbot_prefix $3-
%send Done
}
return
:RELOAD
if ($3 == -u) { initcmd -in-channel Y }
else { initcmd -in-channel N }
return
:REMOTE
var %script = remote.command
var %line = 1
var %scriptline = $3-
scon -r $3-
;%send Remote disabled for security reasons.
return
:RESTART
%send Restarting...
!.exit -nr
return
:SHOWCOMMANDS
%send Following commands are available for you with access " $+ $getaccess($fulladdress) $+ ". For help with a specific command, type %prefixinfo $+ help <command>
var %i = 1
while ($var(fiqbot_cmd_*,%i)) {
if ((($gettok($(,$var(fiqbot_cmd_*,%i)),1,58) <= %access) || (($gettok($(,$var(fiqbot_cmd_*,%i)),1,58) <= 1))) && (!$gettok($(,$var(fiqbot_cmd_*,%i)),4,58))) {
if ((!$3) || ($3 iswm $right($var(fiqbot_cmd_*,%i),-12))) {
var %buffer = %buffer $right($var(fiqbot_cmd_*,%i),-12) $+ $chr(44)
}
}
inc %i
}
var %i = 1
while ($var(constant_*,%i)) { if ((!$3) || ($3 iswm $right($var(constant_*,%i),-10))) var %buffer2 = %buffer2 $right($var(constant_*,%i),-10) $+ $chr(44) | inc %i }
%send Normal commands: $iif(!$lower($left(%buffer,-1)),(none),$lower($left(%buffer,-1))) $chr(124) Constants: $iif(!$lower($left(%buffer2,-1)),(none),$lower($left(%buffer2,-1)))
return
:SOURCE
%send The source of FIQ-bot can be found here: https://github.com/FredrIQ/fiqbot3-tyrant
return
:TYPEOF
if (!$3) { fiqbot.usage $2 $chan | return }
if (%constantUseRaw_ [ $+ [ $3 ] ]) { var %type = rawconstant }
elseif (%constantInChannel_ [ $+ [ $3 ] ]) { var %type = channelconstant }
elseif (%constant_ [ $+ [ $3 ] ]) { var %type = constant }
elseif (%addon_ [ $+ [ $3 ] ]) { var %type = addon }
elseif ($fiqbot.cmd.isalias($3)) { var %type = alias }
elseif ($fiqbot.cmd($3)) { var %type = normal }
else { %send Command $3 doesn't exists. | return }
%send Type of $3 is " $+ %type $+ ".
return
:VERSION
var %buffer = FIQ-bot version $fiqbot.version
if (%access == 11) %buffer = %buffer (build $fiqbot.build $+ )
%buffer = %buffer :: Tyrant version: $fiqbot.tyrant.version
%send %buffer
return
:VOICE
if ($left($3,1) == $#) { var %chan = $3 | var %nick = $iif(!$4,$nick,$4) }
else { var %chan = $chan | var %nick = $iif(!$3,$nick,$3) }
if ($me !isop %chan) { %send I'm not op in %chan | return }
if (%nick !ison %chan) { %send %nick isn't on %chan | return }
mode %chan +v %nick
%send Done.
return
:WELCOME
if (!$3) { fiqbot.usage $2 $chan | return }
if ($left($3,1) != $left($chan,1)) { %send Illegal channel name: $3 | return }
if (!$4) { %send Welcome message for $3 is: $iif(%fiqbot_welcome_ [ $+ [ $fiqbot.insertNetwork($3) ] ],%fiqbot_welcome_ [ $+ [ $fiqbot.insertNetwork($3) ] ],(none)) | return }
set %fiqbot_welcome_ [ $+ [ $fiqbot.insertNetwork($chan) ] ] $4-
%send Done.
return
:WHOAMI
:WHOIS
if ($2 == WHOAMI) { tokenize 32 $1-2 $fulladdress }
elseif ($2 == WHOIS) {
if (!$3) { fiqbot.usage $2 $chan | return }
elseif (!$ial($3)) { .notice $nick $3 isn't on any common channels with me. | return }
tokenize 32 $1-2 $ial($3)
}
fiqbot.whois $gettok($3,1,33) $3
return
;BEGIN OF TYRANT CODE
:APIRAW
fiqbot.tyrant.login 1
if ($3 isnum) && (. !isin $3) {
fiqbot.tyrant.login $3
tokenize 32 $1-2 $4-
}
if (!$3) { fiqbot.usage $2 $chan | return }
fiqbot.tyrant.apiraw $3-
return
:CARD
if (!$3) { fiqbot.usage $2 $chan | return }
var %id, %name, %faction, %rarity, %type, %stats, %skills, %set
if ($3 !isnum) || (. isin $3) {
var %name = $replace($3-,*,+)
%id = $hget(cards,id $+ $remove(%name,$chr(32)))
}
else {
%id = $3
}
if (!$hget(cards,rarity $+ %id)) {
%send No such card.
return
}
%name = $hget(cards,name $+ %id)
%type = $hget(cards,type $+ %id)
if (%type != 3) %faction = $hget(cards,faction $+ %id)
%set = $hget(cards,set $+ %id)
else %faction = 2
if (%faction == 1) %faction = Imperial
if (%faction == 2) %faction = $null
if (%faction == 3) %faction = Bloodthirsty
if (%faction == 4) %faction = Xeno
if (%faction == 8) %faction = Righteous
if (%faction == 9) %faction = Raider
%rarity = $hget(cards,rarity $+ %id)
if (%rarity == 1) %rarity = Common
if (%rarity == 2) %rarity = Uncommon
if (%rarity == 3) %rarity = Rare
if (%rarity == 4) %rarity = Legendary
%unique = $hget(cards,unique $+ %id)
if (%unique) %rarity = Unique $iif(%rarity != Rare,%rarity,$null)
if (%type == 4) %stats = $+($hget(cards,attack $+ %id),/,$hget(cards,health $+ %id),/,$hget(cards,cost $+ %id))
if (%type == 2) %stats = $+(-/,$hget(cards,health $+ %id),/,$hget(cards,cost $+ %id))
if (%type == 1) %stats = $+(-/,$hget(cards,health $+ %id),/-)
if (%type == 3) %stats = -/-/-
if (%type == 1) %type = Commander
if (%type == 2) %type = Structure
if (%type == 3) %type = Action
if (%type == 4) %type = Assault
if (%set == 1000) %set = Standard
if (%set == 1) %set = Enclave
if (%set == 2) %set = Nexus
if (%set == 3) %set = Blight
if (%set == 4) %set = Purity
if (%set == 5) %set = Homeworld
if (%set == 6) %set = Phobos
if (%set == 7) %set = Phobos Aftermath
if (%set == 8) %set = Awakening
if (%set == 9) %set = Terminus
if (%set == 10) %set = Occupation
if (%set == 11) %set = Worldship
if (%set == 12) %set = Flashpoint
if (%set == 5000) %set = Reward
if (%set == 5001) %set = Promotional
if (%set == 5002) %set = Upgraded
if (%set == 9999) %set = RaiderSet
if (%set) %set = :: %set
var %i = 1
while ($hget(cards,$+(skill,%id,_,%i))) {
var %skill = $hget(cards,$+(skill,%id,_,%i))
if ($gettok(%skill,1,32) == Summon) {
%skill = $gettok(%skill,1,32) $hget(cards,$+(name,$gettok(%skill,2,32))) $gettok(%skill,3-,32)
}
if (%i == 1) %skills = :: %skill
else %skills = %skills $+ , %skill
inc %i
}
%send $+([,%id,]) %name ( $+ %stats $+ ) %rarity %faction %type %skills %set
return
:CLIENTCODE
if (!$3) {
if (%fiqbot_tyrant_clientcode1) {
if (%bruteforcing) {
%send Clientcode verification in progress! Progress is $calc( %fiqbot_tyrant_clientcode1 / 10 ) $+ %
}
else {
%send Current client code: %fiqbot_tyrant_clientcode1
}
}
else {
%send No clientcode is set.
}
return
}
if (!$4) {
set %fiqbot_tyrant_clientcode1 $int($3)
%send Clientcode set to %fiqbot_tyrant_clientcode1
}
else {
set %fiqbot_tyrant_clientcode [ $+ [ $int($3) ] ] $int($4)
%send Clientcode for $int($3) set to %fiqbot_tyrant_clientcode [ $+ [ $int($3) ] ]
}
return
:CONQUESTDEBUG
fiqbot.tyrant.login 1
fiqbot.tyrant.checkconquestmap
return
:FACTION
if ($3 == -l) {
tokenize 32 $1-2 $4-
if (%access == 1) set -u0 %access 2
}
else set -u0 %access 1
if (!$3) { fiqbot.usage $2 $chan | return }
%id = $fiqbot.tyrant.db.select(factions,$3-)
if (!%id) && (($3 !isnum) || (. isin $3)) {
%send No such faction.
return
}
if (!%id) %id = $3
elseif ($gettok(%id,0,32) > 1) {
%send There are several factions with this name. The most likely option has been selected. Options are: %id (query by ID to get those)
%id = $gettok(%id,1,32)
}
fiqbot.tyrant.login 2
fiqbot.tyrant.showfaction %id
return
:FACTIONCHAT
var %chan = $chan
if ($left($3,1) == $#) {
var %chan = $3
tokenize 32 $1-2 $4-
if (%access < 5) && ($nick !ison %chan) {
%send You're not in %chan and don't have sufficient access to check unless you're in the channel.
return
}
}
var %factionuser = %fiqbot_tyrant_factionchannel_ [ $+ [ %chan ] ]
if (!%factionuser) {
%send There's currently no faction assigned to $iif(%chan == $chan,this channel,%chan) $+ .
return
}
if (!%fiqbot_tyrant_userid [ $+ [ %factionuser ] ]) {
%send There's currently no account assigned to $iif(%chan == $chan,this channel,%chan) $+ .
return
}
if (!$3) {
%send Faction chat relay is currently $iif(%fiqbot_tyrant_chat_ [ $+ [ %factionuser ] ],on,off)
return
}
if ($3 != on) && ($3 != off) { fiqbot.usage $2 $chan | return }
unset %fiqbot_tyrant_chat_ [ $+ [ %factionuser ] ]
if ($3 == on) set %fiqbot_tyrant_chat_ [ $+ [ %factionuser ] ] 1
%send Done. Faction chat relay is currently $iif(%fiqbot_tyrant_chat_ [ $+ [ %factionuser ] ],on,off)
return