-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodFunctions.bas
975 lines (760 loc) · 29.3 KB
/
modFunctions.bas
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
Attribute VB_Name = "modFunctions"
Public TimeFilter As Long
Public GotShowID As Boolean
Public Type UDTLast5Games
GameNames As String
GameTimes As Long
End Type
Public Last5Gamess(4) As UDTLast5Games
Public harvestbool As Boolean
Public HashCnter As Long
Public isMapfilter As Boolean
Public isGamefilter As Boolean
Public isHostfilter As Boolean
Public GameFilters2 As New Collection
Public str As Variant
Public AccessList As New clsHashTable
Public Whisperlist As New clsHashTable
Public GameDatas As New clsHashTable
Public Gamefilter As New clsHashTable
Public Function KillNull(ByVal strText As String) As String
If InStr(strText, Chr(0)) = 0 Then KillNull = strText: Exit Function
KillNull = Left(strText, InStr(strText, Chr(0)) - 1)
End Function
Public Function getMastFlags() As String
Dim s As String
s = Chr(83) & Chr(77)
getMastFlags = s
End Function
Public Function PrepareCheck(ByVal toCheck As String) As String
toCheck = Replace(toCheck, "[", "ÿ")
toCheck = Replace(toCheck, "]", "Ö")
toCheck = Replace(toCheck, "~", "Ü")
toCheck = Replace(toCheck, "#", "¢")
toCheck = Replace(toCheck, "-", "£")
toCheck = Replace(toCheck, "&", "¥")
toCheck = Replace(toCheck, "@", "¤")
toCheck = Replace(toCheck, "{", "ƒ")
toCheck = Replace(toCheck, "}", "á")
toCheck = Replace(toCheck, "^", "í")
toCheck = Replace(toCheck, "`", "ó")
toCheck = Replace(toCheck, "_", "ú")
toCheck = Replace(toCheck, "+", "ñ")
toCheck = Replace(toCheck, "$", "÷")
PrepareCheck = LCase(toCheck)
End Function
Public Function ConvertTime(ByVal lngMS As Long) As String
Dim lngSeconds As Long, lngDays As Long, lngHours As Long, lngMins As Long
Dim strSeconds As String, strDays As String
lngSeconds = lngMS / 1000
lngDays = Int(lngSeconds / 86400)
lngSeconds = lngSeconds Mod 86400
lngHours = Int(lngSeconds / 3600)
lngSeconds = lngSeconds Mod 3600
lngMins = Int(lngSeconds / 60)
lngSeconds = lngSeconds Mod 60
If lngSeconds <> 1 Then strSeconds = "s"
If lngDays <> 1 Then strDays = "s"
ConvertTime = lngDays & " day" & strDays & ", " & lngHours & " hours, " & lngMins & " minutes and " & lngSeconds & " second" & strSeconds
End Function
Public Function SplitStr(ByVal OriginalString As String, ByRef ReturnArray() As String, ByVal Delimiter As String) As Long
Dim sItem, lArrCnt
Dim lLen, lPos
lArrCnt = 0
lLen = Len(OriginalString)
Do
lPos = InStr(1, OriginalString, Delimiter, vbTextCompare)
If lPos <> 0 Then
sItem = Left$(OriginalString, lPos - 1)
OriginalString = Mid$(OriginalString, lPos + 1)
If sItem <> "" Then
lArrCnt = lArrCnt + 1
If lArrCnt = 1 Then
ReDim ReturnArray(1 To lArrCnt) As String
Else
ReDim Preserve ReturnArray(1 To lArrCnt) As String
End If
ReturnArray(lArrCnt) = sItem
End If
End If
Loop While lPos <> 0
If OriginalString <> "" Then
lArrCnt = lArrCnt + 1
ReDim Preserve ReturnArray(1 To lArrCnt) As String
ReturnArray(lArrCnt) = OriginalString
End If
SplitStr = lArrCnt
End Function
Public Function GetIconCode(ByVal Product As String, ByVal Flags As Long) As Integer
If (BNFLAGS_BLIZZ And Flags) = BNFLAGS_BLIZZ Then
GetIconCode = 15
Exit Function
ElseIf (BNFLAGS_OP And Flags) = BNFLAGS_OP Then
GetIconCode = 1
Exit Function
ElseIf (BNFLAGS_SYSOP And Flags) = BNFLAGS_SYSOP Then
GetIconCode = 16
Exit Function
ElseIf (BNFLAGS_SQUELCH And Flags) = BNFLAGS_SQUELCH Then
GetIconCode = 14
Exit Function
ElseIf (BNFLAGS_GLASSES And Flags) = BNFLAGS_GLASSES Then
GetIconCode = 18
Exit Function
ElseIf (BNFLAGS_GFPLAYER And Flags) = BNFLAGS_GFPLAYER Then
GetIconCode = 17
Exit Function
ElseIf (BNFLAGS_SPKR And Flags) = BNFLAGS_SPKR Then
GetIconCode = 17
Exit Function
End If
Select Case Product
Case "[SEXP]": GetIconCode = 9
Case "[STAR]": GetIconCode = 6
Case "[JSTR]": GetIconCode = 11
Case "[SSHR]": GetIconCode = 7
Case "[W2BN]": GetIconCode = 10
Case "[D2DV]": GetIconCode = 5
Case "[D2XP]": GetIconCode = 13
Case "[DRTL]": GetIconCode = 3
Case "[DSHR]": GetIconCode = 4
Case "[CHAT]": GetIconCode = 2
Case "[WAR3]": GetIconCode = WAR3
Case Else: GetIconCode = 12
End Select
End Function
Public Function GetFlagCode(ByVal Flags As Long) As Integer
If (BNFLAGS_BLIZZ And Flags) = BNFLAGS_BLIZZ Then
GetFlagCode = 15
Exit Function
ElseIf (BNFLAGS_OP And Flags) = BNFLAGS_OP Then
GetFlagCode = 1
Exit Function
ElseIf (BNFLAGS_SYSOP And Flags) = BNFLAGS_SYSOP Then
GetFlagCode = 16
Exit Function
ElseIf (BNFLAGS_SQUELCH And Flags) = BNFLAGS_SQUELCH Then
GetFlagCode = 14
Exit Function
ElseIf (BNFLAGS_GLASSES And Flags) = BNFLAGS_GLASSES Then
GetFlagCode = 18
Exit Function
ElseIf (BNFLAGS_GFPLAYER And Flags) = BNFLAGS_GFPLAYER Then
GetFlagCode = 17
Exit Function
ElseIf (BNFLAGS_SPKR And Flags) = BNFLAGS_SPKR Then
GetFlagCode = 17
Exit Function
Else
GetFlagCode = 2
Exit Function
End If
End Function
Public Function Whizperlist(User As String)
Send0x0E "/f add " & Trim(User)
Send0x0E Trim(User) & " has been added to the whisper list."
End Function
Public Function NotifyAll(Broadcast As String)
Send0x0E "/f msg " & Broadcast
End Function
Public Function AddtoAccess(WhoIniatedCMD As String, User As String, AccessLevel As Integer)
If AccessList.Exists(LCase(User)) = True Then 'Already In
If AccessList.Item(LCase(User)) = AccessLevel Then 'then same access
Chat.AddChat2 vbRed, User & " already has " & AccessLevel
Exit Function
End If
If AccessList.Item(LCase(User)) >= AccessList.Item(LCase(WhoIniatedCMD)) Then
Chat.AddChat2 vbRed, User & " has the same or more access than you."
End If
Else
AccessList.Add LCase(User), AccessLevel 'add
Chat.AddChat2 vbRed, "Added " & User & " with access " & AccessLevel
End If
End Function
Public Function DoWork(User As String, CMDData As String)
Dim SplitCMD() As String
SplitCMD = Split(CMDData, " ")
Select Case LCase(SplitCMD(0)) 'AccessList.Item(LCase(User))
''''''''Access Level of 10'''''''''
'''''''''''''''''''''''''''''''''''
Case "ver", "about", "version"
If AccessList.Item(LCase(User)) >= 10 Or LCase(User) = LCase(strMast) Then
Queue.Enqueue "Game Announcer v" & App.Major & "." & App.Minor & " (Build: " & App.Revision & ") by Myst and cHip."
End If
Case "find", "whois"
If AccessList.Item(LCase(User)) >= 10 Or LCase(User) = LCase(strMast) Then
If CheckAccess(SplitCMD(1)) = True Then
If LCase(SplitCMD(1)) = LCase(strMast) Then
Queue.Enqueue SplitCMD(1) & " is the bot's master."
Else
Queue.Enqueue SplitCMD(1) & " has " & AccessList.Item(LCase(SplitCMD(1))) & " access"
End If
Else
Queue.Enqueue SplitCMD(1) & " was not found."
End If
End If
Case "say"
If AccessList.Item(LCase(User)) >= 10 Or LCase(User) = LCase(strMast) Then
SplitCMD = Split(CMDData, " ", 2)
If Mid$(SplitCMD(1), 1, 1) = "/" Then
SplitCMD(1) = Replace(SplitCMD(1), "/", "", 1, 1)
End If
Queue.Enqueue SplitCMD(1)
End If
Case "trigger", "trig", "t"
If AccessList.Item(LCase(User)) >= 10 Or LCase(User) = LCase(strMast) Then
Queue.Enqueue "/w " & User & " Current Trigger: " & IniTrigger
End If
Case "timefilter", "time"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
If UBound(SplitCMD) = 0 Then 'blank time
Send0x0E "You must input how many seconds you wanted filtered!"
Exit Function
End If
If SplitCMD(1) = "" Then 'user forgot something
Send0x0E "You must input how many seconds you wanted filtered!"
Exit Function
End If
TimeFilter = Trim(SplitCMD(1))
Send0x0E "Detecting games within " & TimeFilter & " secs."
End If
Case "filtercount"
If AccessList.Item(LCase(User)) >= 20 Or LCase(User) = LCase(strMast) Then
Send0x0E "You have " & GameFilters2.count & " Filters. {" & Gamefilter.count & " Hashs)"
End If
Case "track"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
HandleTrack Mid$(CMDData, 7)
End If
Case "clearall", "clear"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
Call ClearAll
End If
Case "ep", "tv", "tvshow"
If AccessList.Item(LCase(User)) >= 10 Or LCase(User) = LCase(strMast) Then
GotShowID = False
frmMain.Inet1.Execute "http://services.tvrage.com/feeds/search.php?show=" & Trim(LCase(Mid$(CMDData, Len(SplitCMD(0)) + 2))) 'Smallville"
End If
Case "deletefilter", "delete", "del"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
Call DeleteFilter(Trim(LCase(Mid$(CMDData, Len(SplitCMD(0)) + 2))))
End If
Case "switch", "watch"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
Select Case UCase(Trim(SplitCMD(1)))
Case "UMS"
WatchType = "UMS"
Case "TVB"
WatchType = "TVB"
Case "MELEE"
WatchType = "MELEE"
Case Else
Send0x0E "Improper Watch Type, use : UMS, TVB, or MELEE"
Exit Function
End Select
Send0x0E "Switched to detecting " & WatchType & " games."
End If
Case "stop", "sleep", "stoptrack"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
If TimerOn = True Then
Call KillTimer(frmMain.hWnd, 1000)
Queue.Enqueue "Stopped Tracking!"
TimerOn = False
Else
Queue.Enqueue "Tracking is already off"
End If
End If
Case "start", "starttrack"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
If TimerOn = False Then
Call SetTimer(frmMain.hWnd, 1000, 10000, AddressOf TimerProc)
Queue.Enqueue "Tracking Started"
Else
Queue.Enqueue "Tracking is already on"
End If
End If
Case "weather"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
SplitCMD = Split(CMDData, " ", 2)
HandleWeather SplitCMD(1)
End If
Case "rem", "remove"
If AccessList.Item(LCase(User)) >= 80 Or LCase(User) = LCase(strMast) Then
If LCase(SplitCMD(1)) <> LCase(strMast) Then
RemoveAccess User, SplitCMD(1)
Else
Queue.Enqueue "You can't remove the master's access."
End If
End If
Case "add"
If AccessList.Item(LCase(User)) >= 80 Or LCase(User) = LCase(strMast) Then
If LCase(SplitCMD(1)) <> LCase(strMast) Then
AddAccess User, SplitCMD(1), SplitCMD(2)
Else
Queue.Enqueue "You can't change the Master's access."
End If
End If
Case "join"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
Queue.Enqueue "/join " & Trim(LCase(Mid$(CMDData, Len(SplitCMD(0)) + 2)))
End If
Case "language"
If AccessList.Item(LCase(User)) >= 70 Or LCase(User) = LCase(strMast) Then
Queue.Enqueue "Changed Language to " & Trim(LCase(Mid$(CMDData, Len(SplitCMD(0)) + 2)))
End If
Case "games", "last", "game"
If AccessList.Item(LCase(User)) >= 10 Or LCase(User) = LCase(strMast) Then
Queue.Enqueue Last5Games
End If
Case "listfilters", "filters", "filterlist"
If AccessList.Item(LCase(User)) >= 20 Or LCase(User) = LCase(strMast) Then
Queue.Enqueue ListFilters
End If
Case "harvest"
If LCase(SplitCMD(1)) = "on" Then
harvestbool = True
Queue.Enqueue "Harvesting Key Hashes = On"
Else
harvestbool = False
Queue.Enqueue "Harvesting Key Hashes = Off"
End If
'''''''WINAMP COMMANDS''''''''''''''''''
Case "mp3", "music"
If AccessList.Item(LCase(User)) >= 100 Or LCase(User) = LCase(strMast) Then
WindowTitle = GetWindowTitle("Winamp v1.x")
If WindowTitle = vbNullString Then
Send0x0E "Winamp is not active"
Else
WindowTitle = Left(WindowTitle, Len(WindowTitle) - 9)
Send0x0E "Track [" & WindowTitle & "] ..::Game Announcer::.."
End If
End If
Case "play", "p"
If AccessList.Item(LCase(User)) >= 100 Or LCase(User) = LCase(strMast) Then
iwinamp = WinAMP_SendCommandMessage(WA_PLAY)
If i = 0 Then
WindowTitle = GetWindowTitle("Winamp v1.x")
If WindowTitle = vbNullString Then
Send0x0E "Winamp is not active"
Else
WindowTitle = Left(WindowTitle, Len(WindowTitle) - 9)
' Send0x0E "Track [" & WindowTitle & "] ..::Game Announcer::.."
End If
Else
Send0x0E ("Winamp is not active")
End If
End If
Case "next", "n", "skip"
If AccessList.Item(LCase(User)) >= 100 Or LCase(User) = LCase(strMast) Then
iwinamp = WinAMP_SendCommandMessage(WA_NEXTTRACK)
If i = 0 Then
WindowTitle = GetWindowTitle("Winamp v1.x")
If WindowTitle = vbNullString Then
Send0x0E "Winamp is not active"
Else
WindowTitle = Left(WindowTitle, Len(WindowTitle) - 9)
' Send0x0E "Track [" & WindowTitle & "] ..::Game Announcer::.."
End If
Else
'Send LastCW & "Not on, use /winamp .", frmMain.wsBnet
Send0x0E "Winamp is not active."
End If
End If
Case "prev", "back", "last"
If AccessList.Item(LCase(User)) >= 100 Or LCase(User) = LCase(strMast) Then
iwinamp = WinAMP_SendCommandMessage(WA_PREVTRACK)
If i = 0 Then
WindowTitle = GetWindowTitle("Winamp v1.x")
If WindowTitle = vbNullString Then
Send0x0E "Winamp is not active"
Else
WindowTitle = Left(WindowTitle, Len(WindowTitle) - 9)
'Send0x0E "Track [" & WindowTitle & "] ..::Game Announcer::.."
End If
Else
Send0x0E "Winamp is not active"
End If
End If
Case "pause"
If AccessList.Item(LCase(User)) >= 100 Or LCase(User) = LCase(strMast) Then
iwinamp = WinAMP_SendCommandMessage(WA_PAUSE)
If i = 0 Then
' Send0x0E "Winamp Paused"
Else
Send0x0E "Winamp is not active"
End If
End If
Case "winamp"
If AccessList.Item(LCase(User)) >= 100 Or LCase(User) = LCase(strMast) Then
Select Case SplitCMD(1)
Case "on"
LoadWinamp
WinAMP_SendCommandMessage (WA_PLAY)
Send0x0E "..::Winamp Loaded::.. [Game Announcer]"
Case "off"
iwinamp = WinAMP_SendCommandMessage(WA_CLOSE)
Send0x0E "..::Winamp Closed::.. [Game Announcer]"
Case "stop"
iwinamp = WinAMP_SendCommandMessage(WA_STOP)
If i = 0 Then
Send0x0E "Winamp Stopped"
Else
Send0x0E "Winamp is not active"
End If
End Select
End If
Case Else 'unknown cmd
End Select
End Function
Public Function AddAccess(User As String, Person2Add As String, AccessLevel As String)
Dim UserAccess As Integer
UserAccess = AccessList.Item(LCase(User))
Select Case CheckAccess(Person2Add)
Case False
If UserAccess >= AccessLevel Or LCase(User) = LCase(strMast) Then
AccessList.Add LCase(Person2Add), AccessLevel
Queue.Enqueue "Added " & Person2Add & " with " & AccessList.Item(LCase(Person2Add)) & " access."
SaveDatabase Person2Add, AccessLevel
Else
Queue.Enqueue "You can't add someone more access than you have."
End If
Case True
If UserAccess > AccessList.Item(LCase(Person2Add)) Or LCase(User) = LCase(strMast) Then
AccessList.Remove (LCase(Person2Add))
AccessList.Add LCase(Person2Add), AccessLevel
Queue.Enqueue "Changed " & Person2Add & "'s access to " & AccessList.Item(LCase(Person2Add)) & "."
SaveDatabase Person2Add, AccessLevel
Else
Queue.Enqueue "Can't change someones access who's greater or equal to yours."
End If
End Select
End Function
Public Function RemoveAccess(User As String, Person2Rem As String)
Dim UserAccess As Integer
UserAccess = AccessList.Item(LCase(User))
Select Case CheckAccess(Person2Rem)
Case False
Queue.Enqueue Person2Rem & " was never in the database."
Case True
If UserAccess > AccessList.Item(LCase(Person2Rem)) Or LCase(User) = LCase(strMast) Then
AccessList.Remove (LCase(Person2Rem))
Queue.Enqueue "Removed " & Person2Rem & " from database."
SaveDatabase Person2Rem, AccessLevel, True
Else
Queue.Enqueue "Can't remove someone who has more access than you."
End If
End Select
End Function
Public Function SaveDatabase(User As String, ByVal AccessLevel As String, Optional IncomingRemove As Boolean)
Dim intFreeFile As Integer, i As Integer, o As Integer
i = 1
Const DELIMETER As String = ";"
intFreeFile = FreeFile
Open (App.Path & "\database.txt") For Output As #intFreeFile
Do Until AccessList.GrabKeyBasedOnINDEX(i) = ""
If AccessList.Exists(AccessList.GrabKeyBasedOnINDEX(i)) = True Then 'ignore its empty slot
Print #intFreeFile, AccessList.GrabKeyBasedOnINDEX(i) & DELIMETER & AccessList.Item(AccessList.GrabKeyBasedOnINDEX(i))
End If
i = i + 1
DoEvents
Loop
Chat.AddChat vbWhite, "Database.txt saved"
Close #intFreeFile
End Function
Public Function CheckAccess(User As String) As Boolean
If AccessList.Item(LCase(User)) <> "" Or LCase(User) = LCase(strMast) Then 'no access
CheckAccess = True
Else
CheckAccess = False
End If
End Function
Public Function LoadAccess(FiileName As String)
Dim whole_file As String
Dim animals() As String
Dim usersNaccess() As String
Dim i As Integer
'On Error GoTo checkthis
' Get the whole file.
whole_file = GrabFile(App.Path & "\" & FiileName)
' Break the file into lines.
animals = Split(whole_file, vbCrLf)
Do Until i = UBound(animals) + 1
'skip blank lines
If animals(i) = "" Then
Else
''
If InStr(1, animals(i), ";") = 0 Then
MsgBox "Invalid Database.txt format [" & animals(i) & "]. Input your users as Username;Accesslevel"
KillProcess.KillProcess ("GameAnnouncer.exe")
Exit Function
End If
End If
usersNaccess = Split(Mid$(animals(i), 1), ";")
If Mid$(Trim(animals(i)), 1) <> "" Then
If AccessList.Exists(LCase(usersNaccess(0))) = True Then
Else
AccessList.Add LCase(usersNaccess(0)), usersNaccess(1)
keysz = LCase(usersNaccess(0))
End If
End If
i = i + 1
DoEvents
Loop
'checkthis: MsgBox ("There is something wrong with your Database.txt, please check it (Format: Name;AccessLevel)")
End Function
Private Function GrabFile(ByVal file_name As String) As _
String
Dim fnum As Integer
On Error GoTo NoFile
fnum = FreeFile
Open file_name For Input As fnum
GrabFile = Input$(LOF(fnum), fnum)
Close fnum
Exit Function
NoFile:
GrabFile = ""
MsgBox "Couldnt Grab File :( something's wrong!!"
End Function
Public Sub HandleTrack(MSG As String)
Dim Filter As String
Dim What2Filter As String
Filter = Trim(LCase((Mid$(MSG, 1, InStr(1, MSG, " ")))))
What2Filter = Trim(LCase(Mid$(MSG, Len(Filter) + 1)))
Select Case LCase(Filter)
Case "map"
isMapfilter = True
Case "host"
isHostfilter = True
Case "game"
isGamefilter = True
Case Else
Queue.Enqueue "Invalid Filter, proper filters are: map, host, or game."
Exit Sub
End Select
If What2Filter = "" Then
Select Case LCase(Filter)
Case "map"
Queue.Enqueue "You need to tell me what map to look for."
Case "host"
Queue.Enqueue "You need to tell me what host to look for."
Case "game"
Queue.Enqueue "You need to tell me what game name to look for."
End Select
Exit Sub
Else
Call AddFilter(Filter, What2Filter)
End If
If FirstTime = True Then
Call SetTimer(frmMain.hWnd, 1000, 10000, AddressOf TimerProc)
End If
End Sub
Public Function AddFilter(FilType As String, Filter As String)
If Gamefilter.Exists(Gamefilter.HashCode("MYST" & Filter)) = True Then
Queue.Enqueue "Already Tracking: " & Filter
Else
Gamefilter.Add Gamefilter.HashCode("MYST" & Filter), Filter
GameFilters2.Add Filter
Queue.Enqueue "Tracking " & FilType & ": " & Filter
End If
End Function
Public Function ListFilters() As String
Dim MsgtoDisplay As String
Dim Y As Integer
For Y = 1 To GameFilters2.count
If GameFilters2.count = 0 Then
'do nothing
Else
If MsgtoDisplay = "" Then
MsgtoDisplay = GameFilters2.Item(Y)
Else
MsgtoDisplay = MsgtoDisplay & ", " & GameFilters2.Item(Y)
End If
End If
Next Y
'[12:48:36 PM] - : Announcer : - Filter(s): 3v3, bgh, micro, mouse, bald locks, rpg, diplo, temple siege
If MsgtoDisplay = "" Then
MsgtoDisplay = "I have no filters added yet."
End If
If Len(MsgtoDisplay) > 210 Then 'count takeing into consderation the "filter(s)" word
Dim HoleMe() As String, splitmsg As String
HoleMe = SplitString(MsgtoDisplay, 210)
Dim w As Integer, i As Integer
For i = 0 To UBound(HoleMe)
Queue.Enqueue "Filter(s): " & HoleMe(i)
Next i
Else
ListFilters = "Filter(s): " & MsgtoDisplay
End If
End Function
Public Function SplitString(ByVal TheString As String, ByVal StringLen As Integer) As String()
Dim ArrCount As Integer
Dim i As Long
Dim TempArray() As String
ReDim TempArray((Len(TheString) - 1) \ StringLen)
For i = 1 To Len(TheString) Step StringLen 'icrement it by teh len you wanted it by
TempArray(ArrCount) = Mid$(TheString, i, StringLen)
ArrCount = ArrCount + 1
Next
SplitString = TempArray
End Function
Public Function DeleteFilter(Filter As String)
If Gamefilter.Exists(Gamefilter.HashCode("MYST" & Filter)) = True Then
Gamefilter.Remove Gamefilter.HashCode("MYST" & Filter) 'remove from hashtable
Dim i As Integer
i = 1
Do Until i > GameFilters2.count
If GameFilters2.Item(i) = Filter Then
GameFilters2.Remove (i)
End If
i = i + 1
DoEvents
Loop
Send0x0E "Deleted " & Filter
Else
Queue.Enqueue Filter & " was never added."
End If
End Function
Public Function ClearAll()
Gamefilter.RemoveAll
Do Until GameFilters2.count = 0
GameFilters2.Remove (1) ' collections drop slots automaticly
DoEvents
Loop
isMapfilter = False
isHostfilter = False
isGamefilter = False
Send0x0E "Cleared all Filters"
End Function
Public Function ClearedMapData(MapData As String) As String 'Remove < 0x20 chars from data
Dim M As Long
M = 1
Do Until M >= Len(MapData)
If buf2.GetBYTE(Mid$(MapData, M, 1)) < 20 Then
MapData = Replace(MapData, Mid$(MapData, M, 1), "")
End If
M = M + 1
DoEvents
Loop
ClearedMapData = Trim(MapData)
End Function
Public Function CheckFilterMatch(GameData As String, MapData As String, HostData As String) As Boolean
Dim identif As String
Dim cnt As Long
cnt = 1
If GameFilters2.count = 0 Then
Exit Function
End If
Do Until cnt = GameFilters2.count + 1
identif = GameFilters2.Item(cnt)
If InStr(1, LCase(GameData), identif) <> 0 Then
CheckFilterMatch = True
Exit Function
End If
If InStr(1, LCase(MapData), identif) <> 0 Then
CheckFilterMatch = True
Exit Function
End If
If InStr(1, LCase(HostData), identif) <> 0 Then
CheckFilterMatch = True
Exit Function
End If
cnt = cnt + 1
DoEvents
Loop
End Function
Public Function Last5Games() As String
Dim MsgtoDisplay As String
Dim Y As Integer
For Y = 0 To UBound(Last5Gamess)
If Last5Gamess(Y).GameNames = "" Then
'do nothing
Else
If MsgtoDisplay = "" Then
MsgtoDisplay = Last5Gamess(Y).GameNames
Else
MsgtoDisplay = MsgtoDisplay & ", " & Last5Gamess(Y).GameNames
End If
End If
Next Y
If MsgtoDisplay = "" Then
MsgtoDisplay = "No games detected since I started."
End If
Last5Games = MsgtoDisplay
End Function
Public Function Stats(GameName As String, Map As String, Host As String, Time As String)
End Function
Private Sub HandleWeather(Params As String)
Dim xml_Google As New DOMDocument
Dim xml_node As IXMLDOMNode
Dim inet As String, Temp As String, Cond As String, City As String
Dim Wind As String, Humid As String
inet = frmMain.Inet1.OpenURL("http://www.google.com/ig/api?weather=" & Params)
xml_Google.loadXML inet 'loads into the inet
Set xml_node = xml_Google.documentElement.selectSingleNode("//xml_api_reply/weather/forecast_information/city")
City = xml_node.Attributes.getNamedItem("data").Text
If (City = vbNullString) = True Then
Send0x0E "U.S. City does not exist or wrong syntax"
Exit Sub
End If
Set xml_node = xml_Google.documentElement.selectSingleNode("//xml_api_reply/weather/current_conditions/temp_f")
Temp = xml_node.Attributes.getNamedItem("data").Text
Set xml_node = xml_Google.documentElement.selectSingleNode("//xml_api_reply/weather/current_conditions/condition")
Cond = xml_node.Attributes.getNamedItem("data").Text
Set xml_node = xml_Google.documentElement.selectSingleNode("//xml_api_reply/weather/current_conditions/wind_condition")
Wind = xml_node.Attributes.getNamedItem("data").Text
Set xml_node = xml_Google.documentElement.selectSingleNode("//xml_api_reply/weather/current_conditions/humidity")
Humid = xml_node.Attributes.getNamedItem("data").Text
Send0x0E City & " - Temperature: " & Temp & "ºF - " & "Currently: " & Cond & " - " & Wind & " - " & Humid & "."
Set xml_node = Nothing
Exit Sub
End Sub
Public Function ConnectingID(Cdkey As String) As String
Dim Product As Long
Dim PublicValue As Long
Dim PrivateValue As String
Select Case Len(Cdkey)
Case 26
If kd_quick(Cdkey, 0, 0, PublicValue, Product, outhash, 20) = 0 Then
End If
Case 13, 16
If decode_hash_cdkey(Cdkey, 0, 0, PublicValue, Product, outhash) = 0 Then
End If
End Select
Select Case Hex(Product)
Case 1, 2, 17 'SC
ConnectingID = "SC"
WhatConnectID = "SC"
Case 6, 7, "A", "C", 18, 19 'D2
ConnectingID = "D2"
WhatConnectID = "D2"
Case "E", "F", 12, 13 'W3
ConnectingID = "W3"
WhatConnectID = "W3"
Case Else
ConnectingID = "Unknown"
End Select
End Function
Public Sub ChangeBackground()
Select Case modFunctions.ConnectingID(IniCDKey)
Case "SC"
frmMain.Picture = LoadPicture(App.Path & "\SCBackground.jpg")
Case "D2"
frmMain.Picture = LoadPicture(App.Path & "\D2Background.jpg")
Case "W3"
frmMain.Picture = LoadPicture(App.Path & "\WCBackground.jpg")
Case Else
frmMain.Picture = LoadPicture(App.Path & "\SCBackground.jpg")
End Select
frmMain.txtChan.Refresh
End Sub
Public Function GoogleTranslate(Message As String, Optional OutputLanguage As String = "en") As String
Dim var1 As String 'Holds data that you're POSTing
If Len(Message) > 222 Then
GoogleTranslate = "Translation is too long for Battle.net server"
Exit Function
End If
TransON = True
On Error Resume Next
var1 = "q=" & Message & "?&v=1.0&langpair=en%7C" & OutputLanguage
frmMain.Inet1.Execute "http://ajax.googleapis.com/ajax/services/language/translate", "POST", var1, "Content-Type: application/x-www-form-urlencoded"
End Function