-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBaalChannelProject_2.0.6.txt
2179 lines (1919 loc) · 80.1 KB
/
BaalChannelProject_2.0.6.txt
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") = "BCP"
Script("Author") = "vi[r]us (IAreConnection @ StealthBot.net)"
Script("Major") = 2
Script("Minor") = 6
Script("Revision") = 0
'// This is a unique code given to each public release. The version name (BCP x.x.x) is always the first 3 numbers.
'// Major_Minor_Revision_BetaCode_ScriptType (ScriptType is always 0 for public releases)
Const bcpVID = 20600
Const bcpVD = "9/28/2010"
'// The bot maintains the following files and folders (in the StealthBot directory):
'// bcp_settings.ini -- Used to keep settings for the script.
'// bot folder/bcp_users -- The folder where user profiles are stored.
'// bcp_translations.txt -- A text file containing instructions used to "translate" friend messages.
'// bot folder/bcp_translations -- Formerly used to hold old translations. Defunct in this version.
'// bot folder/bcp_versions -- Will be used to hold outdated scripts in upcoming versions. Defunct in this version.
'// The bot will by default access the following websites on the internet:
'// http://toshley.net/bcp/downloads/getcurrentversion.php -- Used to find the current script version.
'// http://toshley.net/bcp/downloads/translations/getcurrentversion.php -- Used to find the current translations version.
'// http://toshley.net/bcp/.../commit.php -- Used to report information to the GDB if turned on.
'// http://toshley.net/bcp/news/[vID].txt -- Used to get the news for your version.
'// This file belongs in the /scripts/ folder of your StealthBot directory. It is no longer a plugin as of 2.0.4.
'// I have been getting a lot of comments lately about the BCP code itself. It is not commented on except in areas where there are
'// special notes required for myself. If you don't know how to use Visual Basic, please don't edit the script yourself.
' // SETTINGS ARE NOW STORED IN A CONFIG FILE IN THE BOT'S FOLDER CALLED bcp_settings.ini
'============================================================================================================================
'= Parenthesis "(" and ")" denote the user who found the bug, if it is
'= not specified, they were found by the community or a developer.
'=
'= Everything in the changelog is only there to show users what has changed. This
'= includes displayed messages and minor code changes, as well as large changes.
'============================================================================================================================
' ChangeLog for 2.0.6 (id 20600, 20601)
' * Added a quick disable/enable for the script's internal functions (the new scripting system isn't forgiving at all)
' --the bot will still do some things (such as reset the GDB on/off toggle)
' * Fixed a bug where the bot raises an error over a blank command
' * The script now checks for updates since 2.0.6, but does not download them for you
' * Added /bcp update command which checks for script updates
' * Added /bcp transupdate command which checks for translations file updates
' * Added /bcp mutual command which allows you to check if a friend is logged in and mutual (deprecated, for testing)
' * Added /bcp news command which gets the news for your version
' * Added LogoutOnNoMutual=int config entry, which is the time in minutes after a user has logged in that
' the bot will check their friend mutuality. If they aren't mutual or have gone offline, they will be removed
' --this only works if the bot has not been restarted: in testing
' * Added LogoutOnOffline config entry, which removes people if they are offline on your friends list periodically
' --this only happens if they are a runner
' --this follows the same time constraint as the game message display
' * Added /bcp config open command to open the settings file in the default editor (changes are automatic)
' * Added IsLadder profile setting to user profiles to fix temporary unknowns until someone rejoins the channel
' * Added IsHardcore profile setting ^
' * Added IsExpansion profile setting ^
' * The bot will now mark ladder, nonladder and hardcore on the GDB
' * The bot will not use the GDB for the duration of the session if it becomes unavailable for any reason
' --this resets when the bot logs on *meaning you can reconnect to reset it
' * Replaced the FOREWARD in the script file with a nonedit warning
' * Added /bcp setup command which runs an interface to help you set up the bot
' --this includes GDB setup
' * The firstrun message now tells you such a command exists IN BIG LETTERS.
' * The bots will now ignore Diablo-only commands from users that aren't using Diablo
' --effected commands: getinfo, myinfo, login, logout, games
' * When reporting command invalidity, the bot will now say the command and the required access
' * Reworded some responses that only make sense to people who know more than a "normal" person does (they were
' created when the script was in beta, and only developers needed to read it)
' * Added /bcp find command that works in the same fashion as the in-game one, it is however more descriptive
' * Fixed a bug where hardcore flags stick to users even after rejoining the channel (ChX-Dragon)
' * Fixed a bug where ladder flags stick to users even after rejoining the channel (ChX-Dragon)
' * Changed a potential type mismatch from product comparisons (ChX-Dragon)
' * Fixed the error occuring because %game is replaced before %gametime, thereby making the latter give the wrong value or never appear (ChX-Dragon)
' * Added information for files and locations at the top of the script. In case this is ever necessary, it is now in the script itself.
' * Added the option to show MessageBox notifications for things the bot has done or needs your help with to assist users who like to minimize at startup (Main:ShowDialogs = boolean)
' --effected events: translation updates, script updates, gdb turning off
' * Changed the way news is read so that it can see links
' * Added UseNewestProfile entry, which can be used to completely turn off GDB downloads for newer profiles by setting it to False (Behavior:UseNewestProfile = boolean)
' * Fixed an index error that occured when a translation mismatch occurs
' * The translation warning message no longer shows English to English
' * Removed unused functions and classes (code only)
' * Added a simple error escape for commands (you will no longer see the obnoxious StealthBot warning when mistyping a command)
' * Added /bcp reset command; this command allows you to reset a single person's game count and information (same clear method as purge)
' * The .myinfo command now includes the player's rank
' * Added Translations:GermanLanguageSupport=Boolean under translations, which simply hard removes " eingeklinkt" from game names (the space is included). Enabled by default.
' * Setting filters to nothing turns them off, and will no longer raise an error
' * Added Behavior:AutoLock=Boolean to automatically lock the bot's window when BCP loads
'
' Developer's Notes
' ### YNI (but still in code)
' * The bot will now check to see if the user logging in is a mutual friend (experimental, the bot takes a moment to update)
' * Added MsgMutualError config entry which is copied to the user when they are not a mutual friend (requires the above)
'
' * This release was coupled with a GDB reset and Blizzard also reset their ladder. If you experience any problem just turn GDB off temporarily.
'
'============================================================================================================================
' ChangeLog for 2.0.5 (id 20500)
' * Added dozens of debug messages
' * Added EagleEyes, a method to see what the bot sees that most users
' ignore in chat (works similar to .NET IDE's intellisense)
' * Added /bcp version command to check bot version and translations
' * Added /bcp eagleeyes [status] where [status] is "enable" or "disable"
' (no quotes): see above
' * Fixed the problem with users not being found (StealthBot scripts ignore
' scripting events with insufficient arguments, didn't realize that)
' * Open Characters (not ephemeral characters) are now treated as non-diablo players.
'
'============================================================================================================================
' ChangeLog for 2.0.4 (id 20400)
' * The plugin is now a StealthBot 2.7 script.
' * Added news module
' * Replaced the old BCP domain I used with the new .net domain
'
'============================================================================================================================
' ChangeLog for 2.0.3 (id 20300)
' * Added .top command
' * Added .career rank command (sub of career: .career rank)
' * Fixed profile updating
' * Added .getcareer <username> <command> command for getinfo compatability
' * Added a system of/for debug messages to help users diagnose problems
' * Minor typo fixes
' * This release includes a new translation system, old files will be outdated
' but fix themselves by auto-updating
' * Translations are now updated every 2 hours instead of 12.
' * MsgType config entry now accepts "True" and "False" and is reflective
' of True = "Repeat" and False = "Ask"; the old system is still in place
' $ The script still defaults MsgType to "Ask"
' * Properly adjusted the command system to use an "Else" operator on switch
' so that .career and .getcareer are the same as .myinfo and .getinfo
' * The mirror commands .myinfo and .getinfo are now defaulted in config
' * Added ProfileHead config entry; it's the Location section of the bot's
' profile when it updates it. It still includes the VID, however.
' ________________
'/
' HEY THERE
'
' YEAH, YOU
'
' THE ONE READING THE SCRIPT FILE
'
' YOU'RE IN THE WRONG SPOT, BRO
'
' CHECK OUT BCP_SETTINGS.INI TO CHANGE STUFF, NOT HERE
'
'\_________________
'
' _______________
'/ Quick Links
'
' ==> Help Topics
' http://toshley.net/bcp/help.php
'
' ==> GDB Explained
' http://toshley.net/bcp/help.php?view=GDB
'
' ==> Forum
' http://toshley.net/forum/
'
'\________________
'%=================================%
'% %
'% do not edit below here %
'% consult bcp_settings.ini %
'% %
'%=================================%
Public bcpFSO, bcpUsers
Public bcpIC, bcpLastGameRequest
Public bcpLastProfileUpdate
Public bcpLastConnect, bcpMarkOffline
Public bcpGDBTemp_Disable
Public bcpTmrSec, bcpTmrHr
'// The internal channel contains a bcp_User object without run data to easily swap it.
'// Helpful constants
Const bcp_game_DiabloII = "D2DV"
Const bcp_game_DiabloIIExp = "D2XP"
Class bcp_User
Public Username
Public StatString
Public Product
Public Character
Public CClass
Public Title 'Slayer, etc
Public Level 'Int
Public InGame 'Bool
Public GameObject 'bcp_Game
Public Language
Public IsExpansion 'Bool
Public IsLadder 'Bool
Public IsHardcore 'Bool
Public Runs 'Int
Public Time 'Int
Public Fastest 'Int
Public LastTime 'Int
Public LastGameName
'// Personal
Public HideGameDuration
Public NameOverCharacter
Public HideGDBGame
Public HideLogMsg
Public LastLog
Public LastSeen
'// Temporary
Public CareerResetCode
Sub EmptyGame()
If Not InGame Then Exit Sub
InGame = False
LastTime = GameObject.Duration()
LastGameName = GameObject.Name
End Sub
Sub Parse()
LastSeen = Now()
'Bot name differences, we have to make a system that agrees with both
'because Eric does not love me.
'...
'2.6: (Matriarch Swampie, a ladder level 90 sorceress on realm USEast).
'2.7: (Champion Swampie, a level 90 ladder Sorceress on USEast).
If (Not Product = bcp_game_DiabloII) and (Not Product = bcp_game_DiabloIIExp) Then
Character = Username
CClass = "nonchar"
Title = ""
bcp_EagleMsg Username & " is not using Diablo II or Lord of Destruction (Product: " & Product & ")."
Exit Sub
End If
If InStr(LCase(StatString), "open character") > 0 Then
If Len(Character) = 0 Then
Character = Username
CClass = "nonchar"
Title = ""
Level = 0
bcp_EagleMsg Username & " is an open character, but no record of character found. (Product: " & Product & ")."
Else
bcp_EagleMsg Username & " is an open character, keeping user as """ & Character & """."
End If
Exit Sub
End If
On Error Resume Next : Err.Clear
If UBound(Split(StatString, " ")) < 4 Then Product = "INVALID" : Exit Sub
StatString = Split(StatString, " (")(1)
StatString = Left(StatString, Len(StatString)-1)
partA = Split(Split(StatString, ", ")(0), " ")
partS = Split(StatString, ", ")(1)
partB = Split(Split(StatString, ", ")(1), " ")
If UBound(partA) = 1 Then
Title = partA(0)
Character = partA(1)
Else
Title = "Player"
Character = partA(0)
End If
p = Array("Paladin", "Barbarian", "Assassin", "Druid", "Amazon", "Necromancer", "Sorceress")
Level = Int(Split(Split(partS, " level ")(1), " ")(0))
For i = 0 to UBound(p)
If InStr(LCase(partS), LCase(" " & p(i) & " ")) > 0 Then
CClass = p(i)
Exit For
End If
Next
CClass = LCase(CClass)
If InStr(StatString, " ladder ") Then
IsLadder = True
Else
IsLadder = False
End If
If InStr(StatString, " hardcore ") Then
IsHardcore = True
Else
IsHardcore = False
End If
If Product = "D2XP" Then
IsExpansion = True
Else
IsExpansion = False
End If
On Error GoTo 0
If Err.Number <> 0 Then AddChat vbRed, "[BCP] StatString Parse error: " & StatString
Err.Clear
'// not the statstring, its what the bot "thinks" the statstring is (so it can be manipulated)
'// this was the problem with the 2.0.4 conversion; some users use different versions with diff
'// statstring values
bcp_EagleMsg "User " & Username & " stats: " & Product & " # [H|" & IsHardcore & "][L|" & IsLadder & "] [" & Title & "] " & Character & ", a level " & Level & " " & CClass & "."
End Sub
Function IsDiablo()
If Product = bcp_game_DiabloII or Product = bcp_game_DiabloIIExp Then
IsDiablo = True
Else
IsDiablo = False
End If
End Function
Function IsOpenCharacter()
If Not IsDiablo() or Int(Level) = 0 Then
IsOpenCharacter = True
Else
IsOpenCharacter = False
End If
End Function
Function FormatString(Message)
m = Message
On Error Resume Next : Err.Clear
a = Array("%user", "%name", "%char", "%class", "%lvl", _
"%runid", "%total", "%avg", "%fst", "%title", _
"%runs", "%gametime", "%game")
b = Array(PreferedName(), Username, Character, CClass, Level, _
Runs+1, bcp_FmtTime(Time), bcp_FmtTime(Average()), bcp_FmtTime(Fastest), Title, _
Runs, bcp_FmtTime(GameObject.Duration()), GameObject.Name)
On Error GoTo 0
If Err.Number <> 0 Then AddChat vbRed, "[BCP] Format error " & Err.Number & ": " & Err.Description
For i = 0 to UBound(a)
m = Replace(m, a(i), b(i))
Next
FormatString = m
End Function
Function GameTimeOK()
If GameObject.Duration() < bcp_Get("main", "MinGame") or GameObject.Duration() > bcp_Get("main", "MaxGame") Then
GameTimeOK = False
Else
GameTimeOK = True
End If
End Function
Sub Save()
path = "bcp_users/" & LCase(Username) & ".user"
If Runs = 0 Then
If bcpFSO.FileExists(path) Then bcpFSO.DeleteFile(path)
Exit Sub
End If
WriteConfigEntry "UData", "Username", CStr(Username), path
WriteConfigEntry "UData", "StatString", CStr(StatString), path
WriteConfigEntry "UData", "Product", CStr(Product), path
WriteConfigEntry "UData", "Level", CStr(Level), path
WriteConfigEntry "UData", "Character", CStr(Character), path
WriteConfigEntry "UData", "CClass", CStr(CClass), path
WriteConfigEntry "UData", "Title", CStr(Title), path
WriteConfigEntry "UData", "Runs", CStr(Runs), path
WriteConfigEntry "UData", "Time", CStr(Time), path
WriteConfigEntry "UData", "Fastest", CStr(Fastest), path
WriteConfigEntry "UData", "LastTime", CStr(LastTime), path
WriteConfigEntry "UData", "LastGameName", CStr(LastGameName), path
WriteConfigEntry "UData", "Language", CStr(Language), path
WriteConfigEntry "Personal", "HideGameDuration", CStr(HideGameDuration), path
WriteConfigEntry "Personal", "NameOverCharacter", CStr(NameOverCharacter), path
WriteConfigEntry "Personal", "HideGDBGame", CStr(HideGDBGame), path
WriteConfigEntry "UType", "IsLadder", CStr(IsLadder), path
WriteConfigEntry "UType", "IsHardcore", CStr(IsHardcore), path
WriteConfigEntry "UType", "IsExpansion", CStr(IsExpansion), path
End Sub
Sub GDB_Update(Status)
DoGDB_Update Status, 0
End Sub
Sub GDB_UpdateComp(Status, C)
DoGDB_Update Status, C
End Sub
Sub DoGDB_Update(Status, CompensateGame)
If Runs = 0 Then Exit Sub
Call Save()
If bcp_Get("GDB", "username") = "" or bcp_Get("GDB", "disable") = True Then
Exit Sub
End If
If bcpGDBTemp_Disable Then
AddChat vbYellow, "[BCP:GDB] The bot is temporarily not committing to the GDB. Update failed."
Exit Sub
End If
AddChat vbYellow, "[BCP:GDB] Updating " & Username & "..."
i_Status = Status
If HideGDBGame Then
i_Status = ""
AddChat vbYellow, "[BCP:GDB] Hiding " & Username & "'s game on the GDB."
End If
islString = "0"
If IsLadder Then islString = "1"
ishString = "0"
If IsHardcore Then ishString = "1"
WebString = Username & "|" & _
Character & "|" & _
Runs & "|" & _
Average() & "|" & _
"Realm|" & i_Status & "|" & _
Level & "|" & _
CClass & "|" & _
Time & "|" & _
Fastest & "|" & _
islString & "|" & _
ishString
uName = bcp_Get("GDB", "username")
uPassword = bcp_Get("GDB", "password")
webURL = bcp_Get("GDB", "location") & "?u=" & uName & "&p=" & uPassword & "&item1=" & WebString
On Error Resume Next : Err.Clear
SciNet.Cancel
t = Timer
result = SciNet.OpenURL(CStr(webURL))
t = Round(Timer-t, 2)
If Not Err.Number = 0 Then
AddChat vbRed, "[BCP] Note: Failed to update " & Username & " on the GDB."
AddChat vbRed, Space(8) & Err.Number & ": " & Err.Description
If (Err.Number = 35761) and (Err.Description = "Request timed out") Then
AddChat vbRed, "**************************************"
AddChat vbRed, "[BCP] The GDB database is not responding, the bot will temporarily stop committing data to the GDB until it is reloaded."
AddChat vbRed, "[BCP] It is possible the website is temporarily offline or updating, please try again in a few minutes."
AddChat vbRed, "**************************************"
If (bcp_Get("Main", "ShowDialogs")) Then Call MsgBox("The bot has temporarily turned off the GDB because it is unavailable.", 0, "BCP Warning")
bcpGDBTemp_Disable = True
End If
Err.Clear
Else
m = Split(result, " ", 2)
If Int(m(0)) = 1 Then
AddChat vbGreen, "[BCP:GDB] Success: " & m(1) & " (" & t & "s)"
ElseIf Int(m(0)) = 2 Then
AddChat vbCyan, "[BCP:GDB] Update: There is an updated profile for " & Username & "."
If (bcp_Get("Behavior", "UseNewestProfile")) Then
newData = Split(m(1), "|")
before = Runs
Username = newData(0)
Character = newData(1)
Runs = Int(newData(2))
'Average
'Realm
Status = newData(5)
Level = Int(newData(6))
CClass = newData(7)
Time = Int(newData(8))
Fastest = Int(newData(9))
If CompensateGame > 0 Then
timeBonus = CompensateGame
Runs = Runs + 1
Time = Time + timeBonus
End If
Call Save()
AddChat vbCyan, "[BCP:GDB] " & Username & " (" & Character & ") now has " & Runs & " games (had " & before & "), with an average time of " & bcp_FmtTime(Int(Time / Runs)) & "."
Else
AddChat vbRed, "[BCP] Note: There is a new profile for " & Username & " but you have turned profile downloading off."
End If
Else
AddChat vbRed, "[BCP:GDB] Failure (" & m(0) & "): " & m(1)
End If
End If
On Error GoTo 0
End Sub
Function Rank()
Rank = 0
bubble = bcp_RankBubble()
For i = 1 to UBound(bubble)
If LCase(bubble(i)) = LCase(Username) Then
Rank = i
Exit Function
End If
Next
End Function
Function MutualFriend()
MutualFriend = bcp_Mutual(Username)
End Function
Function Friend()
Friend = bcp_Friend(Username)
End Function
Function Average()
If Runs = 0 or Time = 0 Then Average = 0 : Exit Function
Average = Int(Time / Runs)
End Function
Function PreferedName()
If NameOverCharacter Then
PreferedName = Username
Else
PreferedName = Character
End If
End Function
Sub Class_Initialize()
InGame = False
Set GameObject = Nothing
HideGameDuration = False
NameOverCharacter = False
HideGDBGame = False
HideLogMsg = True
Runs = 0
Level = 0
Time = 0
Fastest = 0
LastTime = 0
LastGameName = "Incomplete"
IsLadder = False : IsHardcore = False
LastLog = DateAdd("s", -(bcp_Get("main", "MsgNoSpam")), Now())
CareerResetCode = "~" & Chr(0) & Chr(2) '// Can't type those
End Sub
End Class
Sub bcp_PurgeList(LimitOf)
For Each Key in bcpUsers.Keys
With bcpUsers.Item(Key)
If .Runs < LimitOf Then
.Runs = 0
.Time = 0
.Fastest = 0
.Save
AddChat vbRed, "[BCP] Purge: " & .Username
End If
End With
Next
End Sub
Sub bcp_Folder()
If Not bcpFSO.FolderExists(BotPath() & "bcp_users") Then
bcpFSO.CreateFolder(BotPath() & "bcp_users")
AddChat vbGreen, "[BCP] Users are stored in: {BOTPATH}/bcp_users as configuration files"
End If
End Sub
Class bcp_Game
Public Name
Public Host
Public Started
Function Duration()
Duration = Abs(DateDiff("s", Started, Now()))
End Function
Sub Class_Initialize()
Started = Now()
End Sub
End Class
Function bcp_Mutual(Username)
bcp_Mutual = False
For Each Friend in Friends
If LCase(Friend.Name) = LCase(Username) Then
If CBool(Friend.IsMutual) Then
bcp_Mutual = True
Exit For
End If
End If
Next
End Function
Function bcp_Friend(Username)
bcp_Friend = False
For Each Friend in Friends
If LCase(Friend.Name) = LCase(Username) Then
bcp_Friend = True
End If
Next
End Function
Function bcp_FriendOnline(Username)
bcp_FriendOnline = False
For Each Friend in Friends
If LCase(Friend.Name) = LCase(Username) Then
If Friend.Status = 1 Then
bcp_FriendOnline = True
End If
End If
Next
End Function
Function bcp_FixTranslation(Line)
bcp_FixTranslation = Line
For i = 0 to 255
bcp_FixTranslation = Replace(bcp_FixTranslation, "[" & i & "]", Chr(i))
Next
End Function
Function bcp_Translate(Text)
If Not bcpFSO.FileExists(BotPath() & "bcp_translations.txt") Then Exit Function
On Error Resume Next : Err.Clear
Set file = bcpFSO.OpenTextFile(BotPath() & "bcp_translations.txt", 1)
Q = Split(file.ReadAll(), vbCrLf)
lang = "?"
tVer = bcp_Get("Translations", "Version")
phixd = Text
bcp_DebugMsg "Translate: " & phixd
If tVer = 3 Then bcp_DebugMsg "Version 3 check..."
For i = 0 to UBound(Q)
p = Split(Q(i), "|")
If UBound(p) >= 2 Then
Name = p(0)
Game = p(1)
OE = p(2)
bcp_DebugMsg "Checking " & Name & "..."
Else
bcp_DebugMsg "Invalid translation: " & Join(p)
End If
If tVer = 3 Then
'// 3 and lower use padding
Padding = Int(p(3))
If Match(Text, Game, True) Then
lang = Name
D = Split(Game, "*")
p_user = Split(Split(Text, D(0))(1), D(1))(0)
p_prod = Split(Split(Text, D(1))(1), D(2))(0)
p_gamename = Split(Text, D(2))(1)
p_gamename = Left(p_gamename, Len(p_gamename)-1)
If Padding > 0 Then p_gamename = Right(p_gamename, Len(p_gamename)-Padding)
phixd = "Your friend " & p_user & " entered a " & p_prod & " game called " & p_gamename & "."
End If
If Match(Text, OE, True) Then
lang = Name
D = Split(OE, "*")
p_user = Split(Split(Text, D(0))(1), D(1))(0)
phixd = "Your friend " & p_user & " has exited Battle.net."
End If
ElseIf tVer > 3 Then
'// >3 doesn't use padding, it uses char replace
Game = bcp_FixTranslation(Game)
OE = bcp_FixTranslation(OE)
bcp_DebugMsg "Adjusted: " & Game
bcp_DebugMsg "Adjusted: " & OE
If Match(Text, Game, True) Then
lang = Name
D = Split(Game, "*")
p_user = Split(Split(Text, D(0))(1), D(1))(0)
p_prod = Split(Split(Text, D(1))(1), D(2))(0)
p_gamename = Split(Text, D(2))(1)
p_gamename = Left(p_gamename, Len(p_gamename)-1)
phixd = "Your friend " & p_user & " entered a " & p_prod & " game called " & p_gamename & "."
End If
If Match(Text, OE, True) Then
lang = Name
D = Split(OE, "*")
p_user = Split(Split(Text, D(0))(1), D(1))(0)
phixd = "Your friend " & p_user & " has exited Battle.net."
End If
End If
Next
file.Close
bcp_DebugMsg "Fixed from " & lang & " to English: " & phixd
If Err.Number <> 0 Then
AddChat vbRed, "[BCP] Translation error: " & Err.Description
Err.Clear
lang = "?"
phixd = Text
End If
bcp_Translate = Array(lang, phixd)
On Error GoTo 0
End Function
Sub bcp_CheckTranslationsCond()
If DateDiff("s", CDate(bcp_Get("Translations", "LastUpdate")), Now()) > (60 * 60 * 2) or bcp_Get("Translations", "Version") = 0 Then
bcp_CheckTranslations
Else
bcp_DebugMsg "Translations file #" & bcp_Get("Translations", "Version") & ", last updated " & bcp_Get("Translations", "LastUpdate") & "."
End If
End Sub
Sub bcp_CheckNews()
AddChat vbYellow, "[BCP] Checking for recent BCP news..."
Call bcp_Set("News", "Location", CStr("http://toshley.net/bcp/news/"), False)
newsUpdateLoc = bcp_Get("News", "Location")
newsFile = newsUpdateLoc & "news_" & bcpVID & ".txt"
SciNet.Cancel
On Error Resume Next : Err.Clear
data = SciNet.OpenURL(CStr(newsfile))
If Err.Number <> 0 or data = "" Then
AddChat vbRed, "[BCP] An error occured checking for news."
bcp_DebugMsg Err.Description
Err.Clear
Exit Sub
End If
On Error GoTo 0 : Err.Clear
If (InStr(data, "404 Not Found") > 0) Then
AddChat vbRed, "[BCP] An error occured checking for news: item not found"
bcp_DebugMsg "News download got 404ed"
Err.Clear
Exit Sub
End If
part = Split(data, "||")
title = part(0)
lines = Split(part(1), "\n")
AddChat vbWhite, " "
AddChat vbWhite, " http://toshley.net/bcp/"
AddChat vbGreen, " --- BCP News ---"
AddChat vbCyan, " " & title
For i = 0 to UBound(lines)
AddChat vbWhite, " " & lines(i)
Next
AddChat vbWhite, " "
End Sub
Sub bcp_CheckScriptVersion()
scriptVer = bcpVID
scriptLU = bcp_Get("Main", "ScriptLastUpdate")
scriptUpdateLoc = bcp_Get("Main", "ScriptUpdateLoc")
Call bcp_Set("Main", "ScriptLastUpdate", CStr(Now()), True)
AddChat vbYellow, "[BCP] Checking for script updates..."
SciNet.Cancel
On Error Resume Next : Err.Clear
data = SciNet.OpenURL(CStr(scriptUpdateLoc & "?id=" & bcpVID))
If Err.Number <> 0 or data = "" or InStr(data, "404 Not Found") > 0 Then
AddChat vbRed, "[BCP] An error occured checking for script updates."
bcp_DebugMsg Err.Description
Err.Clear
Exit Sub
End If
On Error GoTo 0 : Err.Clear
serverVer = Int(Split(data, "#")(0))
serverLoc = Split(data, "#")(1)
serverMsg = Split(data, "#")(2)
lines = Split(serverMsg, "//")
If serverVer = "ERROR" Then
AddChat vbRed, "[BCP] An error occured getting the most recent version: " & serverMsg
bcp_DebugMsg Err.Description
Err.Clear
Exit Sub
End If
If Int(serverVer) > Int(bcpVID) Then
AddChat vbRed, "[BCP] This current version of BCP is out of date. The server has BCP " & serverVer & " but you have BCP " & bcpVID & "."
AddChat vbRed, "[BCP] It is recommended that you update at " & serverLoc & " ."
If (serverMsg <> "") Then
AddChat vbWhite, "[BCP] The updater has supplied the following information about the update:"
For i = 0 to UBound(lines)
AddChat vbWhite, " " & lines(i)
Next
End If
If (bcp_Get("Main", "ShowDialogs")) Then Call MsgBox("There is a new version of the script available. Your bot window has more information for you.", 0, "BCP Warning")
ElseIf Int(serverVer) < Int(bcpVID) Then
AddChat vbRed, "[BCP] This current version of BCP is newer than the one on record. The server has BCP " & serverVer & " but you have BCP " & bcpVID & "."
AddChat vbRed, "[BCP] You do not need to get the older version, however you may want to consider reading the changelog at " & serverLoc & " ."
Else
AddChat vbGreen, "[BCP] This version of up to date (vID " & bcpVID & ")."
End If
End Sub
Sub bcp_CheckTranslations()
transVer = bcp_Get("Translations", "Version")
transLU = bcp_Get("Translations", "LastUpdate")
transUpdateLoc = bcp_Get("Translations", "GetVersion")
Call bcp_Set("Translations", "LastUpdate", CStr(Now()), True)
AddChat vbYellow, "[BCP] Checking for translation updates..."
SciNet.Cancel
On Error Resume Next : Err.Clear
data = SciNet.OpenURL(CStr(transUpdateLoc))
If Err.Number <> 0 or data = "" Then
AddChat vbRed, "[BCP] An error occured checking for translation updates."
bcp_DebugMsg Err.Description
Err.Clear
Exit Sub
End If
On Error GoTo 0 : Err.Clear
serverVer = Int(Split(data, "#")(0))
serverLoc = Split(data, "#")(1)
If serverVer <> transVer Then
AddChat vbYellow, "[BCP] Your translations file is out of date. The script will download it now. Please allow any script control dialogs."
AddChat vbYellow, "[BCP] Source of document (you have " & transVer & ") (server has " & serverVer & "): " & serverLoc
If bcpFSO.FileExists(BotPath() & "bcp_translations.txt") Then
bcpFSO.DeleteFile(BotPath() & "bcp_translations.txt")
End If
t = Timer
SSC.PrintURLToFile "bcp_translations.txt", CStr(serverLoc)
t = Round( Timer-t, 2)
Call bcp_Set("Translations", "Version", CStr(serverVer), True)
AddChat vbGreen, "[BCP] Download complete. Your translations are now up-to-date (" & t & "s.)"
If (bcp_Get("Main", "ShowDialogs")) Then Call MsgBox("Your bot has downloaded a new translations file.", 0, "BCP Warning")
Else
AddChat vbGreen, "[BCP] Your translations file is up to date (" & transVer & ")."
End If
End Sub
Sub bcp_GDBStatus(Status)
If bcp_Get("GDB", "username") = "" or bcp_Get("GDB", "disable") = True Then
Exit Sub
End If
If bcpGDBTemp_Disable Then
AddChat vbYellow, "[BCP:GDB] The bot is temporarily not committing to the GDB. Update failed."
Exit Sub
End If
AddChat vbYellow, "[BCP:GDB] Updating bot status..."
uName = bcp_Get("GDB", "username")
uPassword = bcp_Get("GDB", "password")
webURL = bcp_Get("GDB", "location") & "?u=" & uName & "&p=" & uPassword & "&setstatus=" & Replace(Status, " ", "+")
On Error Resume Next : Err.Clear
SciNet.Cancel
t = Timer
result = SciNet.OpenURL(CStr(webURL))
t = Round(Timer-t, 2)
If Not Err.Number = 0 Then
AddChat vbRed, "[BCP] Note: Failed to update " & Username & " on the GDB."
AddChat vbRed, Space(8) & Err.Number & ": " & Err.Description
If (Err.Number = 35761) and (Err.Description = "Request timed out") Then
AddChat vbRed, "**************************************"
AddChat vbRed, "[BCP] The GDB database is not responding, the bot will temporarily stop committing data to the GDB until it is reloaded."
AddChat vbRed, "[BCP] It is possible the website is temporarily offline or updating, please try again in a few minutes."
AddChat vbRed, "**************************************"
bcpGDBTemp_Disable = True
End If
Err.Clear
Else
m = Split(result, " ", 2)
If Int(m(0)) = 1 Then
AddChat vbGreen, "[BCP:GDB] Success: " & m(1) & " (" & t & "s)"
Else
AddChat vbRed, "[BCP:GDB] Failure (" & m(0) & "): " & m(1) & " (Username: " & uName & ")"
End If
End If
On Error GoTo 0
End Sub
Function bcp_TopX(n)
bcp_TopX = ""
bubble = bcp_RankBubble()
If (UBound(bubble) = 0) Then Exit Function
If UBound(bubble) < n Then
t = UBound(bubble)
Else
t = n
End If
For i = 1 to t
If bcpUsers.Exists(bubble(i)) Then
bcp_TopX = bcp_TopX & bubble(i) & " (" & bcpUsers.Item(bubble(i)).Runs & "), "
End If
Next
If bcp_TopX <> "" Then
bcp_TopX = Left(bcp_TopX, Len(bcp_TopX) - 2)
End If
End Function
Function bcp_RankBubble()
Dim b()
Sandbox = Split(Join(bcpUsers.Keys, chr(0)), chr(0))
For i = 0 to UBound(Sandbox)
Sandbox(i) = Sandbox(i) & "|" & bcpUsers.Item(Sandbox(i)).Runs
Next
Total = bcpUsers.Count
ReDim b(Total)
g = 0
k = "?"
n = 0
For i = 1 to Total
For x = 0 to UBound(Sandbox)
If Sandbox(x) <> "" Then
q = Split(Sandbox(x), "|")
If Int(q(1)) > g Then
k = q(0)
g = Int(q(1))
n = x
End If
End If
Next
Sandbox(n) = ""
b(i) = k
g = 0
Next
bcp_RankBubble = b
End Function
Function bcp_FmtTime(Seconds)
If Int(Seconds) < 60 Then bcp_FmtTime = Seconds & "s" : Exit Function
s = Int(Seconds) : m = 0 : h = 0
While s >= 60
s = s - 60
m = m + 1
If m = 60 Then m = 0 : h = h + 1
WEnd
If h > 0 Then ret = ret & h & " hours, "
If m > 0 Then ret = ret & m & " minutes, "
If s > 0 Then ret = ret & s & " seconds, "
bcp_FmtTime = Left(ret, Len(ret)-2)
End Function
Function bcp_FmtGameList()
fmtA = bcp_Get("Messages", "GameReturn") & " "
fmtB = bcp_Get("Messages", "GameDelimeter") & " "
smt = bcp_Get("Messages", "GamePretext") & " "
games = 0
For Each Key in bcpUsers.Keys
With bcpUsers.Item(Key)
If .InGame Then
games = games + 1
smt = smt & .FormatString(fmtA) & fmtB
End If
End With
Next
If games > 0 Then
smt = Replace(Left(smt, Len(smt)-Len(fmtB)), "%i", games)
Else
smt = bcp_Get("Messages", "NoGames")
End If
bcp_FmtGameList = smt
End Function
Sub bcp_Set(Section, Key, Value, Overwrite)
If bcp_Get(Section, Key) <> "" and Overwrite = False Then
Exit Sub
Else
ssc.WriteConfigEntry Section, Key, CStr(Value), "bcp_settings.ini"
bcp_DebugMsg "[BCP] Created config entry for " & Key & "."
Exit Sub
End If
ssc.WriteConfigEntry Section, Key, CStr(Value), "bcp_settings.ini"
End Sub
Function bcp_Get(Section, Key)
bcp_Get = ssc.GetConfigEntry(Section, Key, "bcp_settings.ini")
If bcp_Get = "True" or bcp_Get = "False" Then bcp_Get = CBool(bcp_Get)
if IsNumeric(bcp_Get) Then bcp_Get = Int(bcp_Get)
End Function
Sub bcp_ReadAll()
On Error Resume Next
Set contents = bcpFSO.GetFolder(BotPath & "bcp_users")
For Each file In contents.Files
nameArr = Split(file, "\")
name = "bcp_users/" & nameArr(UBound(nameArr))
Set nameArr = Nothing
If Len(name) > 6 Then
If Right(name, 5) = ".user" Then
Username = GetConfigEntry("UData", "Username", name)
If Not bcpUsers.Exists(Username) and Len(Username) > 3 and Len(Username) < 32 Then
bcpUsers.Add Username, new bcp_User
Err.Clear