-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSnapNJacksTrivia_1.0.0.txt
More file actions
1802 lines (1629 loc) · 64.8 KB
/
Copy pathSnapNJacksTrivia_1.0.0.txt
File metadata and controls
1802 lines (1629 loc) · 64.8 KB
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
Script("Name") = "SnapNJacks Trivia"
Script("Abbreviation") = "st"
Script("Author") = "Snap - SnapWilliam@Gmail.com"
Script("Category") = "Entertainment"
Script("Major") = 1
Script("Minor") = 0
Script("Revision") = 0
Script("Description") = "Nondescript"
'This script has been converted from the plugin version of 0.849 by Neco (fallingground@live.com)
'All original coding credit goes to Snap.
'At the moment, all the commands remain the same as the plugin counterpart.
' • trivia on/off
' • score
' • score <user>
' • skip
' • qadd
' • category <category string>
' • qformat
' • hformat
' • hints <amount>
' • useserver <on/off>
' • stver
' • high scores/hscores
' • gemote on/off
' • hintchar [char]
' • reportbadq [id] [why]
' • AFormat [newformat]
' • difficulty [difficulty]-[difficulty]
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'|| CREDITS ||
'|| Assistant coders: Jack and Swent ||
'|| Extra ideas from: ||
'|| Nellaf, MoV-Leader, The.Warchief, Three_Stooges, TcHa2-PulK, Hr.Frosty ||
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Public ST_VER : ST_VER = Script("Major") & "." & Script("Minor") & Script("Revision")
Public Const ST_VER_DESCRIP = "Release"
Public Const ST_COLOR = &HFFCC99
Public ST_USER_LOC : ST_USER_LOC = BotPath() & "scripts\ST_users.ini"
Public ST_USERDB_LOC : ST_USERDB_LOC = BotPath() & "scripts\ST_users.mdb"
Public ST_CONFIG_LOC : ST_CONFIG_LOC = BotPath() & "scripts\ST_config.ini"
Public stFSO : Set stFSO = CreateObject("Scripting.FileSystemObject")
Public st_enabled '// Global on/off
Public st_q_array(41) '// Question DB pull 2deminsional array.
Public st_q_set '// Current Question Set
Public st_q_total '// Question Number - how many questions downloaded.
Public st_q_num '// Current Question Number
Public st_q_answer '// Question's Answer
Public st_q_skiped '// The answer to a skipped question
Public st_unanswerd '// The consecutive amount of questions unanswered.
Public st_hint_num '// Current Hint Number
Public st_hint_string '// Current Hint
Public st_q_asked '// Contains GetGTC of the time the question was asked.
Public st_flooduser '// Used to prevent spam.
Public st_floodtime '// ^
Public st_DBConnStr : ST_DBConnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & ST_USERDB_LOC
Public SNJ
Public ST_Streak, ST_Streak_User, ST_Streak_Con
Public ST_VQL
Public ST_File_Config
Public ST_File_Users
Public Sub Event_Load()
Set SNJ = New SNJClass
If stFSO.FileExists(ST_USER_LOC) AND NOT stFSO.FileExists(ST_USERDB_LOC) Then
Addchat vbYellow, "ST: SnapNJacks will now create the database, and copy the users over."
call SNJ.OpenDB()
call SNJ.MoveOldScores()
Else
call SNJ.OpenDB()
End If
If SNJ.Setting("configver") <> ST_VER And stFSO.FileExists(ST_CONFIG_LOC) Then
Addchat VBwhite, "Welcome to SnapNJacks Trivia, this script was brought to you free of charge by Snap"
Addchat VBwhite, "Be sure to visit the Guide: http://www.stealthbot.net/board/index.php?showtopic=12827"
If MsgBox("This appears to be a new update." & VBnewline & "Would you like to delete your ST_Config.ini? (This will reset the ST_Config to the new defaults. Which is recommended after a update.)", 4) = 6 Then
stFSO.DeleteFile ST_CONFIG_LOC
Addchat VByellow, "ST_Config File deleted"
Else
ST_WriteSetting "configver", ST_VER
End If
End If
If Not stFSO.FileExists(ST_CONFIG_LOC) Then
stFSO.CreateTextFile(ST_CONFIG_LOC)
ST_CreateConfig
End If
If Not stFSO.FolderExists("question files") Then
stFSO.CreateFolder("question files")
AddChat vbYellow, "ST: New folder ""question files"" created. Put your question files in here to use them."
End If
call CreateObj("LongTimer", "AskQuestion")
AskQuestion.Interval = 5
call CreateObj("LongTimer", "VirtualQ")
VirtualQ.Interval = 3
VirtualQ.Enabled = true
call CreateObj("LongTimer", "GiveHint")
GiveHint.Enabled = false
Randomize()
AddChat ST_COLOR, "SnapNJacks Trivia. Version " & ST_VER & " " & ST_VER_DESCRIP & " loaded with " & SNJ.GetUCount & " users in the DB"
End Sub
Public Sub Event_Close()
Set SNJ = Nothing
End Sub
Public Sub Event_UserTalk(Username, Flags, Message, Ping)
If Left(Message, 1) = BotVars.Trigger Then ST_Commands Username, Message, "Talk"
If st_enabled Then ST_CheckAnswer Username, Message
End Sub
Public Sub Event_PressedEnter(Text)
If Left(Text, 3) = "/a " AND st_enabled Then
ST_CheckAnswer BotVars.Username, Mid(Text, 4)
VetoThisMessage
Exit Sub
End If
If Left(Text, 2) = "//" Then
ST_Commands BotVars.Username, Mid(Text, 2), "UEnter"
Exit Sub
End If
If Left(Text, 1) = "/" Then ST_Commands BotVars.Username, Text, "Enter"
End Sub
Public Sub Event_WhisperFromUser(Username, Flags, Message, Ping)
If Left(Message, 1) = BotVars.Trigger Then ST_Commands Username, Message, "Whisper"
End Sub
Private Sub ST_CheckAnswer(Username, Message)
If SNJ.GetBlocked(Username) Then Exit Sub
GetDBEntry Username, UAccess, UFlags
If Not (Int(st_GetSetting("playaccess")) = 0) Then
If UAccess < st_GetSetting("playaccess") - 1 Then
Exit Sub
End If
End If
Dim Answers, NewScore, AddScore
If Not st_enabled Then Exit Sub
If instr(st_q_answer, "/") = 0 Then
If lcase(Message) = lcase(st_q_answer) Then
SNJ.AcceptAnswer SNJ.PUser(Username), st_q_set(3), GetGTC - st_q_asked
st_q_answer = ""
st_unanswerd = 0
End If
Exit Sub
End If
Answers = Split(st_q_answer, "/")
For Each Item in Answers
If Lcase(Message) = Lcase(Item) Then
SNJ.AcceptAnswer SNJ.PUser(Username), st_q_set(3), GetGTC - st_q_asked
st_q_answer = ""
st_unanswerd = 0
End If
Next
End Sub
Sub ST_SQ(Text)
If Instr(Text, "%nl") > 0 Then
Dim TextAry
TextAry = Split(Text, "%nl")
For Each Item in TextAry
STAQ Item
Next
Exit Sub
Else
STAQ Text
End If
End Sub
Private Sub STAQ(Text)
If Not SSC.IsOnline() Then
Addchat ST_COLOR, "ST: Stealthbot isn't online. Trivia will now be disabled."
ST_Disable
Exit Sub
End If
'//GlobalEmote=False
If lcase(st_GetSetting("GlobalEmote")) = "true" Then
If lcase(left(Text, 4)) = "/me " Then Text = Mid(Text, 5)
Dsp 2, Text, 0, 0
Else
Dsp 1, Text, 0, 0
End If
ST_VQL = ST_VQL + 1
End Sub
'For the Commands Sub
Private Sub ST_R(Username, Message, Method)
Select Case Method
Case "Enter"
AddChat ST_COLOR, Message
VetoThisMessage
Case "UEnter"
STAQ Message
VetoThisMessage
Case "Talk"
STAQ Message
Case "Whisper"
STAQ "/w " & Username & " " & Message
End Select
End Sub
Private Sub ST_Commands(Username, Message, Source)
Dim Lmsg, Tmp
'//Request Command and String
Dim RCmd, RStr
Lmsg = Trim(Mid(Message, 2))
'//No command?
If Lmsg = "" Then Exit Sub
'//Is there full-sentence alias for this command?
Tmp = ST_GetCommand(Lmsg)
If Tmp <> "" Then
RCmd = Lcase(Tmp)
Else
'//How about first-word alias?
RCmd = Lcase(Split(Lmsg)(0))
Tmp = ST_GetCommand(RCmd)
If Tmp <> "" Then RCmd = Lcase(Tmp)
If Instr(Lmsg, " ") > 0 Then RStr = Mid(Lmsg, Instr(Lmsg, " ") + 1)
End If
'//Command disabled?
If RCmd = "disabled" Then Exit Sub
Dim InBot
InBot = False
ST_Debug "Command used: " & RCmd
ST_Debug "String: " & RStr
'//Check access
GetDBentry Username, hisAccess, hisFlags
If Source = "Enter" OR Source = "UEnter" Then
hisAccess = 1000
InBot = True
End If
'//-1 Because script returns -1 if not in DB.
If hisAccess < st_getaccess(RCmd) - 1 Then Exit Sub
Username = SNJ.PUser(Username) '//Rids us of the @lordaeron and #2 etc.
'//Check For flooding!
If int(st_GetSetting("floodprotect")) > 0 AND Not InBot Then
If ST_VQL >= 2 Then
If int(st_GetSetting("floodprotect")) > 1 Then Addchat ST_COLOR, "ST: Flood protection has ignored due to a high virtual-q."
Exit Sub
End If
If st_flooduser = Username AND GetGTC - st_floodtime < 2300 Then
If int(st_GetSetting("floodprotect")) > 1 Then Addchat ST_COLOR, "ST: Flood protection has ignored a spammed command."
Exit Sub
End If
st_flooduser = Username
st_floodtime = GetGTC
End If
'//All done! On to our commands!
'//Score
If RCmd = "score" Then
If RStr = "" Then RStr = Username
Tmp = SNJ.GetUMoney(RStr)
If Tmp = "" Then
ST_R Username, "User not found: " & Rstr, Source
Else
ST_R Username, SNJ.ProcessVars(st_GetSetting("resscore"), RStr), Source
'// SNJ.GetRank
End If
End If
If RCmd = "donate" Then
Tmp = Split(RStr)
If UBound(Tmp) <> 1 Then
ST_R Username, "Format: " & Botvars.trigger & "donate [username] [howmuch] ;Example: " & Botvars.trigger & "donate bob 20", Source
Else
'//Allow the bot console to donate username -5 to take money from users.
If InBot AND Left(Tmp(1), 1) = "-" Then
If SNJ.GiveMoney(Tmp(1), Username, Tmp(0), InBot) Then
ST_R Username, "Removed " & FormatCurrency(Tmp(1)) & " from " & Tmp(0), Source
Else
ST_R Username, "Failed to remove money"
End If
Else
Tmp(1) = Replace(Tmp(1), "-", "")
If SNJ.GiveMoney(Tmp(1), Username, Tmp(0), InBot) Then
ST_R Username, "Donated " & FormatCurrency(Tmp(1)) & " to " & Tmp(0), Source
Else
ST_R Username, "Unable to donate, make sure you have the funds, and that the other user is in the database.", Source
End If
End If
End If
End If
If RCmd = "rank" AND RStr = "" Then
Tmp = SNJ.GetRank(Username)
If Tmp = 0 Then
ST_R Username, "I don't have you on record yet " & Username, Source
Else
ST_R Username, Username & ", you are ranked: " & SNJ.AddSuffix(Tmp), Source
End If
ElseIf RCmd = "rank" Then
Tmp = SNJ.GetRank(Rstr)
If Tmp = 0 Then
ST_R Username, "User not found: " & Rstr, Source
Else
ST_R Username, Split(Lmsg)(1) & " found: ranked: " & SNJ.AddSuffix(Tmp), Source
End If
End If
'==Addslashes
If RCmd = "stblock" And RStr <> "" Then
If SNJ.GetBlocked(Rstr) Then
ST_R Username, "User: " & Rstr & " is already blocked", Source
Exit Sub
Else
SNJ.Block(RStr)
ST_R Username, "User has been blocked from playing trivia: " & Rstr, Source
Exit Sub
End If
End If
If RCmd = "stunblock" And RStr <> "" Then
If Not SNJ.GetBlocked(Rstr) Then
ST_R Username, "User: " & Rstr & " isn't blocked.", Source
Exit Sub
Else
SNJ.UnBlock(RStr)
ST_R Username, "User has been unblocked from playing trivia: " & Rstr, Source
Exit Sub
End If
End If
If RCMd = "stblocklist" Then
ST_R Username, SNJ.BlockList, Source
Exit Sub
End If
If RCmd = "skip" AND st_enabled Then
If Source <> "Talk" Then STAQ "Question Skipped"
If Source = "Enter" Then VetoThisMessage
st_q_skiped = st_q_answer
call AskQuestion_Timer()
End If
If RCmd = "category off" Then
SNJ.Setting("category") = ""
ST_R Username, "Category reset to """"", Source
Exit Sub
End If
'//To update a category selection
If RCmd = "category" Then
If RCmd & RStr <> "category" Then
ST_WriteSetting "category", Split(Lmsg)(1)
ST_R Username, "New category string: """ & st_GetSetting("category") & """ Saved", Source
'//download a new set based on it :).
ST_GetQuestions
Else
ST_R Username, "Usage: '" & BotVars.Trigger & "category " & ST_Def_Set("category") & _
"'. Current setting: " & st_GetSetting("category"), Source
End If
End If
If RCmd = "hints" AND RStr <> "" Then
ST_WriteSetting "Hints", RStr
ST_R Username, "ST: Change saved: Hints=" & RStr, Source
End If
If Left(Lmsg, 9) = "hintchar " Then
ST_WriteSetting "hintchar", Mid(Message, 11, 1)
ST_R Username, "ST: Change saved: hintchar=" & Mid(Message, 11, 1), Source
End If
If RCmd = "setfile" Then
If RStr = "" Then
ST_R Username, "ST: No input, - listing files:", Source
If Source = "Enter" Then ST_Scan False Else ST_Scan True
Exit Sub
End If
Tmp = RStr
If InStrRev(lcase(Tmp), ".txt") <> (Len(Tmp) - 3) OR Len(Tmp) < 4 Then
Tmp = Tmp & ".txt"
End If
If stFSO.FileExists(BotPath() & "question files\" & Tmp) Then
ST_WriteSetting "questionfile", Tmp
ST_R Username, "ST: Change saved: questionfile=" & Tmp, Source
ST_WriteSetting "UseServer", "False"
ST_GetQuestions
ST_Enable
ElseIf Source = "Enter" Then
ST_R Username, "ST: File not found:" & Tmp & " Scanning...", Source
ST_Scan False
Else
ST_R Username, "ST: File not found:" & Tmp & " Scanning...", Source
ST_Scan True
End If
End If
If RCMd = "blurtstats on" Then
SNJ.Setting("blurtstats") = "true"
ST_R Username, "ST: Now blurtstats is now on.", Source
End If
If RCMd = "blurtstats off" Then
SNJ.Setting("blurtstats") = "false"
ST_R Username, "ST: Now blurtstats is now off.", Source
End If
'//Console Only Commands
If InBot Then
If RCMd = "stconfig" Then
ST_R Username, "ST: Opening config...", Source
psWShell.Open ST_CONFIG_LOC
End If
If RCMd = "stdebug on" Then
SNJ.Setting("debug") = "true"
ST_R Username, "ST: Now showing debug data", Source
End If
If RCMd = "stdebug off" Then
SNJ.Setting("debug") = "false"
ST_R Username, "ST: Now hiding debug data", Source
End If
If RCMd = "stdelete" Then
If RStr <> "" Then
SNJ.DeleteUser(RStr)
ST_R Username, "User " & RStr & " has been deleted", Source
End If
End If
If RCMd = "stuserlist" Then
ST_R Username, "Snap's Trivia Userlist (Top 500):", Source
Tmp = SNJ.TopMoney(500)
Tmp = Replace(Tmp, ": ", VBTab)
Tmp = Replace(Tmp, ", ", VBNewLine)
Addchat ST_COLOR, VBNewLine & Tmp
End If
End If
'//UseServer On/Off
If Trim(RCmd & " " & Lcase(RStr)) = "useserver on" Then
ST_WriteSetting "UseServer", "True"
ST_R Username, "ST: Change saved", Source
ST_GetQuestions
ElseIf Trim(RCmd & " " & Lcase(RStr)) = "useserver off" Then
ST_WriteSetting "UseServer", "False"
ST_R Username, "ST: Change saved", Source
ST_GetQuestions
End If
'//GEmote On/Off
If Trim(RCmd & " " & Lcase(RStr)) = "gemote on" Then
ST_WriteSetting "globalemote", "True"
ST_R Username, "ST: Change saved: globalemote=True" , Source
ElseIf Trim(RCmd & " " & Lcase(RStr)) = "gemote off" Then
ST_WriteSetting "globalemote", "False"
ST_R Username, "ST: Change saved: globalemote=False" , Source
End If
'//Use Profile On/Off
If Trim(RCmd & " " & Lcase(RStr)) = "useprofile on" Then
ST_WriteSetting "useprofile", "True"
ST_R Username, "ST: Change saved: useprofile=True" , Source
ElseIf Trim(RCmd & " " & Lcase(RStr)) = "useprofile off" Then
ST_WriteSetting "useprofile", "False"
ST_R Username, "ST: Change saved: useprofile=False" , Source
End If
If RCmd = "qformat" Then
If InStr(RStr, "%q") <> 0 AND RStr <> "" Then
ST_WriteSetting "qformat", RStr
ST_R Username, "New Qformat string: """ & st_GetSetting("qformat") & """ Saved", Source
Else
ST_R Username, "Usage: '" & BotVars.Trigger & "qformat " & ST_Def_Set("qformat") & _
"'. %q Required! Current setting: " & st_GetSetting("QFormat"), Source
End If
End If
If RCmd = "hformat" Then
If InStr(RStr, "%h") <> 0 AND RStr <> "" Then
ST_WriteSetting "hformat", RStr
ST_R Username, "New Hformat string: """ & st_GetSetting("hformat") & """ Saved", Source
Else
ST_R Username, "Usage: '" & BotVars.Trigger & "hformat " & ST_Def_Set("hformat") & _
"'. %h Required! Current setting: " & st_GetSetting("HFormat"), Source
End If
End If
If RCmd = "aformat" Then
If RStr <> "" Then
ST_WriteSetting "aformat", RStr
ST_R Username, "New Aformat string: """ & st_GetSetting("Aformat") & """ Saved", Source
Else
ST_R Username, "Usage: '" & BotVars.Trigger & "aformat " & ST_Def_Set("aformat") & _
"'. Current setting: " & st_GetSetting("AFormat"), Source
End If
End If
If RCmd = "pformat" Then
If RStr <> "" Then
ST_WriteSetting "pformat", RStr
ST_R Username, "New Pformat string: """ & st_GetSetting("Pformat") & """ Saved", Source
Else
ST_R Username, "Usage: '" & BotVars.Trigger & "Pformat " & ST_Def_Set("pformat") & _
"'. Current setting: " & st_GetSetting("PFormat"), Source
End If
End If
If RCmd = "difficulty" Then
If RStr <> "" Then
ST_WriteSetting "difficulty", RStr
ST_R Username, "New difficulty setting: """ & st_GetSetting("difficulty") & """ Saved", Source
Else
ST_R Username, "Usage: '" & BotVars.Trigger & "difficulty " & ST_Def_Set("difficulty") & _
"'. Current setting: " & st_GetSetting("difficulty"), Source
End If
End If
If RCmd = "stver" Then
ST_R Username, "ST Version " & ST_VER & " " & ST_VER_DESCRIP & " loaded.", Source
End If
If Trim(RCmd & " " & Lcase(RStr)) = "trivia off" Then
If st_enabled = True Then
ST_Disable
ST_R Username, "ST: Disabled '" & BotVars.Trigger & "trivia on' to start", Source
If st_q_answer <> "" Then
STAQ "Answer(s) to previous question: " & st_q_answer
st_q_answer = ""
End If
Else
ST_R Username, "ST: Trivia is already off", Source
End If
Exit Sub
End If
If Trim(RCmd & " " & Lcase(RStr)) = "trivia on" Then
If st_enabled = False Then
ST_Enable
ST_R Username, "ST: Enabled '" & BotVars.Trigger & "trivia off' to stop", Source
call AskQuestion_Timer()
Else
ST_R Username, "ST: Trivia is already on", Source
End If
Exit Sub
End If
If RCmd = "trivia" Then
If ST_Enabled Then
ST_R Username, "ST: Version " & ST_VER & " " & ST_VER_DESCRIP & " - Trivia is On.", Source
Else
ST_R Username, "ST: Version " & ST_VER & " " & ST_VER_DESCRIP & " - Trivia is off.", Source
End If
Exit Sub
End If
'//Top 10 High Scores
If RCmd = "hscores" Then
ST_R Username, "ST: Top 10: " & SNJ.TopMoney(10), Source
End If
If RCmd = "fanswers" Then
ST_R Username, "ST: Top 10: " & SNJ.TopFAnswers(10), Source
End If
If RCmd = "manswered" Then
ST_R Username, "ST: Top 10: " & SNJ.TopMAnswers(10), Source
End If
If RCmd = "lstreak" Then
ST_R Username, "ST: Top 10: " & SNJ.TopLStreaks(10), Source
End If
'//We need this for the next 2
Dim PreURL
'//reportbadq
If RCmd = "reportbadq" Then
Dim Rstring, R_ID, Response
Rstring = "<" & Username & "> " & Message
R_ID = Split(Rstring & " ")(2)
If IsNumeric(R_ID) Then
'//Run replacements for HTTP transmission
Rstring = SNJ.CleanURL(RString)
PreURL = "http://snapnjacks.com/repq.php?pass=" & st_GetSetting("reportpass")
PreURL = PreURL & "&R_ID=" & R_ID & "&R=" & Rstring
PreURL = PreURL & "&bot=" & botvars.username
Response = scInet.OpenURL(CStr(PreURL))
If Response <> "" AND Len(Response) < 230 Then
ST_R Username, "ST: " & Response, Source
Else
ST_Debug "Server Response: " & Response
ST_R Username, "ST: Could not send report!", Source
End If
Else
ST_R Username, "Format: " & BotVars.Trigger & "reportbadq 60323 The answer is wrong, it should be Rob Thomas", source
End If
End If
'//Question Add System
'//Message = ".qadd What's 12*9?|108/one hunderd and eight|3|1.99|0|Math"
If RCmd = "qadd " Then
Dim Qstring, Qary
Qstring = RStr
'//Run replacements for HTTP transmission
Qstring = SNJ.CleanURL(Qstring)
If Match(Qstring, "*|*|*|*|*|*", True) Then
Qary = Split(Qstring, "|")
PreURL = "http://snapnjacks.com/qadd.php?Q=" & Qary(0) & "&A=" & Qary(1) & _
"&Difficulty=" & Qary(2) & "&Value=" & Qary(3) & "&Type=" & Qary(4) & "&Category=" & Qary(5)
If scInet.OpenURL(CStr(PreURL)) = "Question Submited" Then
AddQ "Your question has been added to the Review Database, Thank you."
Else
AddQ "Error in sending Question. Sorry."
End If
Else
AddQ "Format: " & BotVars.Trigger & "qadd What's 12*9?|108/one hundred and eight|20|5.99|0|Math"
AddQ "Question|Answers Seperated by ""/""|Difficulty 0-5|Value|Type 0 (Used for special Q's)|Categorys seperated by "","""
End If
End If
End Sub
'|| END COMMANDS SUB ||
'||||||||||||||||||||||||||||||
Public Sub Event_ServerInfo(Message)
If Message = "No one hears you." AND st_enabled Then
If st_GetSetting("StopOnEmpty") <> "False" Then ST_Disable
End If
End Sub
Public Sub Event_ServerError(Message)
If Message = "All connections closed." AND st_enabled Then ST_Disable
End Sub
Public Sub AskQuestion_Timer()
If Not st_enabled Then
Exit Sub
End If
ST_AskQuestion
If st_GetSetting("Askrate") + 0 < 5 Then st_WriteSetting "Askrate", 5
AskQuestion.Interval = Int(st_GetSetting("Askrate") * (st_GetSetting("hints") + 1) + 1)
AskQuestion.Enabled = True
End Sub
Public Sub VirtualQ_Timer()
If ST_VQL > 0 Then ST_VQL = ST_VQL - 1
End Sub
Public Sub GiveHint_Timer()
If st_q_answer = "" Or Not st_enabled Then Exit Sub
st_hint_num = st_hint_num + 1
If Instr(st_q_answer, "/") Then
hintAnswer = Split(st_q_answer & "/", "/")(0)
Else
hintAnswer = st_q_answer
End If
'// Last hint already given?
If st_hint_num > Int(st_GetSetting("hints")) Then
GiveHint.Enabled = false
STAQ "The answer(s): " & st_q_answer
'==ST_Streak
st_q_answer = ""
st_hint_num = 0
st_hint_string = ""
Exit Sub
End If
Dim HintOdds
HintOdds = Cint(st_GetSetting("HintOdds"))
Dim i, hintchar, curHint
'//Set the hint char
hintchar = left(st_GetSetting("hintchar"), 1)
For x = 0 to 10
curHint = ""
'// Loop char-by-char through string
For i = 1 to Len(hintAnswer)
'// Skip spaces
If Mid(hintAnswer, i, 1) = " " Then
curHint = curHint & " "
'// Keep letters we already have
ElseIf st_hint_string <> "" And Mid(st_hint_string, i, 1) <> hintchar Then
curHint = curHint & Mid(st_hint_string, i, 1)
'// If it passes probability test uncover current character
ElseIf HintOdds / 100 > Rnd Then
curHint = curHint & Mid(hintAnswer, i, 1)
Else
curHint = curHint & hintchar
End If
Next
If curHint <> st_hint_string Then Exit For
Next'//The outer loop decreases the chances of getting an empty hint, or an unchanged hint.
'// Make sure the hint doesn't give the complete answer
If curHint = hintAnswer Then curHint = st_hint_string
'// Output the hint in the custom format
Dim HFormat
HFormat = st_GetSetting("HFormat")
'//If no %h then go with the defaults
If InStr(HFormat, "%h") = 0 Then HFormat = ST_Def_Set("HFormat")
HFormat = Replace(HFormat, "%h", curHint)
STAQ HFormat
'//Save for next round
st_hint_string = curHint
End Sub
'//Ask Question
Public Sub ST_AskQuestion()
'//Enable Disable based on the amount of users in the channel
If st_GetSetting("AutoDisableP") <> 0 AND st_GetSetting("AutoDisableP") < GetInternalUserCount() Then
STAQ "ST: Not enough users in channel."
ST_Disable
Exit Sub
End If
If st_GetSetting("AutoEnableP") <> 0 AND st_GetSetting("AutoEnableP") > GetInternalUserCount() Then
STAQ "ST: Trivia started because there are now " & GetInternalUserCount() & " users in the channel"
ST_Enable
Exit Sub
End If
If Not st_enabled Then Exit Sub
If st_q_num >= st_q_total Then st_q_num = -1
'//Clear olddata
st_hint_num = 0
st_hint_string = ""
'// move to the next question
st_q_num = st_q_num + 1
'//Make sure there's a question to be asked
If IsArray(st_q_array(st_q_num)) = False Then
Addchat VByellow, "ST: Loading questions..."
ST_GetQuestions
Exit Sub
End If
'// Current Question Set
st_q_set = st_q_array(st_q_num)
'//If Ubound(st_q_array(st_q_num))
QFormat = st_GetSetting("QFormat")
If InStr(QFormat, "%q") = 0 Then QFormat = ST_Def_Set("QFormat")
QFormat = Replace(QFormat, "%df", st_q_set(2))
QFormat = Replace(QFormat, "%vl", FormatCurrency(st_q_set(3)))
If st_q_set(5) = "" Then QFormat = Replace(QFormat, "%id", st_q_set(5))
QFormat = Replace(QFormat, "%id", "[" & st_q_set(5) & "] ")
QFormat = Replace(QFormat, "%ct", st_q_set(6))
QFormat = Replace(QFormat, "%q", st_q_set(0))
If len(st_q_skiped) <> 0 Then
QFormat = Replace(QFormat, "%sk", "(Previous Answer: " & st_q_skiped & ") ")
st_q_skiped = ""
Else
QFormat = Replace(QFormat, "%sk", "")
End If
'// Ask the question
STAQ QFormat
'//Set the time used for speed checking.
st_q_asked = GetGTC
'//variables:
' %sk = Previous skipped answer - if existing.
' %df = Difficulty
' %vl = Value
' %id = ID number on snapnjacks.com
' %q = Question
' %ct = Category
'Possible ST_QFormat = "%skQ# %id (%ct) Difficulty: %df, for $%pt!: %q"
'Possible outcome: "Q# 2341 (Family Guy/Cartoons) Difficulty: 20, for $2.50!: Who's the fattest guy in Family Guy?"
'//This would be a good time to update the profile.
If Lcase(st_GetSetting("useprofile")) = "true" Then SNJ.UpdateProfile
'//Set the question answer '// Additionaly, because we will be cutting this when question is answered
st_q_answer = Trim(st_q_set(1))
If st_GetSetting("hints") <> 0 Then
GiveHint.Interval = st_GetSetting("Askrate")
GiveHint.Enabled = True
End If
'//Check if we need to get more questions
If st_q_num >= st_q_total Then
ST_GetQuestions
Exit Sub
End If
End Sub
'//Scan Question Files folder for question files.
Sub ST_Scan(Output)
Dim QFolder, QFile, I, FileList, DspType
If OutPut = True Then
DspType = 1
If lcase(st_GetSetting("GlobalEmote")) = "true" Then DspType = 2
Else
DspType = 4
End If
If Not stFSO.FolderExists("question files") Then
stFSO.CreateFolder("question files")
AddChat vbYellow, "ST: New folder ""question files"" created in your StealthBot Folder. Place your question files in there to use them."
Exit Sub
End If
Set QFolder = stFSO.GetFolder("question files")
'== This will eventualy just output a list of good question files.
st_WriteSetting "QuestionFile", ""
For Each QFile In QFolder.Files
If InStrRev(lcase(QFile.Name), ".txt") = Len(QFile.Name) - 3 Then
If ST_CheckFile(QFile.Name) Then
If OutPut = True Then
FileList = FileList & ", " & QFile.Name
Else
AddChat vbYellow, "Question file found: " & VBtab & "ÿc0ÿcb" & QFile.Name
End If
st_WriteSetting "QuestionFile", QFile.Name
End If
End If
Next
If st_GetSetting("QuestionFile") = "" Then
Dsp DspType, "ST: No question files found in Question Files", "noone", VByellow
Dsp DspType, "Simply place a question file in the ""question files"" folder located in your StealthBot Folder to use", "noone", VByellow
Else
If OutPut = True Then
Dsp DspType, "ST: Question file(s) found: " & FileList, "noone", VByellow
End If
Dsp DspType, "ST: File set to: " & st_GetSetting("QuestionFile") & ". To use another file type " & botvars.trigger & "setfile filename", "noone", VByellow
End If
End Sub
'//Check file for questions. - Checks for 3 proper-syntaxed questions in a row.
Function ST_CheckFile(FileName)
ST_CheckFile = False
Dim File, I, Line
Set File = stFSO.OpenTextFile(BotPath() & "question files\" & FileName, 1, True)
Do Until File.AtEndOfStream
If I > 3 Then
ST_CheckFile = True
Exit Do
End If
Line = File.Readline
If Line <> "" OR Mid(Line, 1, 2) <> "//" Then
If Len(Line) > InStr(Line, "*") AND InStr(Line, "*") > 2 Then
ST_CheckFile = True
I = I + 1
Else
I = 0
End If
End If
Loop
File.Close
End Function
'//Get the questions
Sub ST_GetQuestions()
If lcase(st_GetSetting("UseServer")) = "false" Then
If st_GetSetting("QuestionFile") = "" Then
AddChat vbYellow, "Questions file not set - scanning bot directory"
ST_Scan False
If st_GetSetting("QuestionFile") = "" Then
AddChat vbYellow, "No files found, reverting to server"
st_WriteSetting "UseServer", "True"
ST_GetQuestions
Exit Sub
End If
End If
ST_ReadQuestionFiles
Exit Sub
End If
'//Downloads Questions, Parses them.
If st_q_num = 0 Then
st_q_num = -1
End If
Dim Received, LineAry, PreURL
PreURL = "http://snapnjacks.com/getq.php"
PreURL = PreURL & "?dif=" & st_GetSetting("difficulty")
If st_GetSetting("category") <> "" Then PreURL = PreURL & "&ctg=" & st_GetSetting("category")
'//Run replacements for HTTP transmission
PreURL = SNJ.CleanURL(PreURL)
If scInet.StillExecuting Then
ST_Debug "scInet is still executing last request, unable to get questions"
Exit Sub
End If
Received = scInet.OpenURL(CStr(PreURL))
If InStr(Received, "|") < 1 Then
AddChat vbRed, "ÿcbST: Question download failed."
If Received = "" Then
Addchat vbRed, "ST: The connection to the server failed, if this continues it could mean the server is down"
ElseIf Lcase(Left(Received, 7)) = "message" Then
Addchat VByellow, "ST: Message on server"
Addchat VByellow, Received
End If
If st_enabled Then
STAQ "ST: No questions were found with selected category. - try changing the category. ST Disabled"
ST_Disable
End If
If st_GetSetting("ErrorHandle") = "True" Then Addchat VByellow, Received
Exit Sub
End If
LineAry = Split(Received, "**")
If Ubound(LineAry) > 40 Then
AddChat vbRed, "ÿcbST: Server overload?: T=" & Ubound(LineAry)
Exit Sub
End If
For I = 0 To Ubound(LineAry)
st_q_array(I) = Split(LineAry(I), "|")
Next
'//Last question = st_q_array(st_q_total)(0)
st_q_total = I - 2
AddChat vbYellow, "ST: New set of questions Received " & st_q_total + 1
'//Ask our question
If ST_Enabled Then ST_AskQuestion
'//AddChat vbPink, "ÿcb" & I - 2 & " Questions Downloaded!"
'//The last question will be st_q_array(st_q_total)(0)
'//st_q_array now contains an array of questions.
'+---------------------------------------+
'| st_q_array(Question Number)(Part) |
'| Parts: |
'| 0 = Question |
'| 1 = answer |
'| 2 = difficulty |
'| 3 = point/money value |
'| 4 = 1/0 Hotspot question? |
'| 5 = Question ID number |
'| 6 = Category. |
'+---------------------------------------+
End Sub
'//Read Question file -- this may evolve into a multi-file reader - Thus fileS
Sub ST_ReadQuestionFiles()
If st_q_num = 0 Then
st_q_num = -1
End If
Dim File, I, X, Line, FileName, LineArray, FullFile, LineCount
FileName = st_GetSetting("QuestionFile")
If Not stFSO.FileExists(BotPath() & "question files\" & FileName) Then
st_WriteSetting "QuestionFile", ""
AddChat vbYellow, "File Not Found: " & FileName
Exit Sub
End If
Set File = stFSO.OpenTextFile(BotPath() & "question files\" & FileName, 1, True)
FullFile = File.Readall
File.Close
FullFile = Split(FullFile, vbNewLine)
I = 0
X = 0
'//Filter out comments and etc
For Each Line in FullFile
X = X + 1
If Line <> "" OR Mid(Line, 1, 2) <> "//" Then
If Len(Line) > InStr(Line, "*") AND InStr(Line, "*") > 2 Then
FullFile(I) = Line
I = I + 1
Else
ST_Debug "QFile Error:" & FileName & " Line: " & X
End If
End If
Next
Redim Preserve FullFile(I - 1)
'//Randomize 40 questions
Randomize
Dim Eran, Tmp
For I = 0 to Ubound(FullFile)
Eran = int(rnd * Ubound(FullFile) - I) + I
Tmp = FullFile(I)
FullFile(I) = FullFile(Eran)
FullFile(Eran) = Tmp
'//We only need 40 random questions
If I > 40 Then
Redim Preserve FullFile(40)
Exit For
End If
Next
I = 0
Dim QValue
For Each Line in FullFile
LineArray = Split(Line, "*")
QValue = st_GetSetting("qtxtvalue")
'//Use the custom value if it exists.
If UBound(LineArray) > 1 Then
If IsNumeric(LineArray(2)) Then