-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemberInfo.txt
222 lines (174 loc) · 5.15 KB
/
MemberInfo.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
Script("Name") = "Member Info"
Script("Author") = "PyroManiac"
Script("Major") = 1
Script("Minor") = 1
'Requests information on a member of a clan.
'This script uses Battle.net packets instead of the website, so it's better. ;p
'REQUIRES DEV 38 OR HIGHER
'Example: .mi Pyro[BoT]
Const MI_COMMAND = "mi"
Const MI_USER = "username"
Public RequestDelay
Private reqDic
Private lastRequest
Private lastRequestObj
Sub Event_Load()
Set reqDic = CreateObject("Scripting.Dictionary")
Call InitCommands()
s = GetSettingsEntry("RequestDelay")
RequestDelay = Int(IIf(Len(s) = 0, "10", s))
End Sub
Sub Event_Command(Command)
If Command.Name <> MI_COMMAND Then Exit Sub
If DateDiff("s", lastRequest, Now) < RequestDelay Then
Command.Respond "You must wait " & RequestDelay & " seconds before requesting another profile."
Exit Sub
End If
If Not RequestUserInfo(Command.Argument(MI_USER), Command) Then
Command.Respond "A request for that user is already queued. Please wait."
End If
End Sub
Function RequestUserInfo(TargetUser, Command)
e = False
For Each r In reqDic.Items()
If Match(TargetUser, r.Name, True) Then
RequestUserInfo = False
Exit Function
End If
Next
Set req = New ProfileRequest
req.Name = TargetUser
req.Cookie = GetNextRequestCookie()
Set req.Command = Command
req.Status = 1
reqDic.Add req.Cookie, req
RequestClanTag req.Name, req.Cookie
lastRequest = Now
RequestUserInfo = True
End Function
Function GetNextRequestCookie()
x = 0
Do
If Not reqDic.Exists(x) Then
GetNextRequestCookie = x
Exit Function
End If
x = x + 1
Loop
End Function
Sub RequestClanTag(name, cookie)
DataBuffer.InsertDWORD cookie
DataBuffer.InsertNTString CStr(name)
DataBuffer.SendPacket &H35
End Sub
Sub RequestClanMemberInfo(name, tag, cookie)
DataBuffer.InsertDWORD cookie
DataBuffer.InsertDWORD tag
DataBuffer.InsertNTString CStr(name)
DataBuffer.SendPacket &H82
End Sub
Sub Event_PacketReceived(Protocol, ID, Length, Data)
If Protocol = "BNCS" Then
If ID = &H35 Then
Set pak = DataBufferEx()
pak.Data = Data
pak.Position = 4
cookie = pak.GetDWORD
status = pak.GetByte
If Not reqDic.Exists(cookie) Then Exit Sub
Set req = reqDic(cookie)
If status = &H0 Then
pDes = pak.GetString
pLoc = pak.GetString
dTag = pak.GetDWORD
If dTag = &H0 Then
req.Status = 7
req.Command.Respond req.Name & " is not in a clan."
req.Command.SendResponse
reqDic.Remove req.Cookie
Exit Sub
End If
hTag = Hex(dTag)
sTag = vbNullString
For x = 1 To (4 * 2) Step 2
i = Int("&H" & Mid(hTag, x, 2))
If i <> 0 Then
sTag = sTag & Chr(i)
End If
Next
req.ClanTag = sTag
req.Status = 2
RequestClanMemberInfo req.Name, dTag, req.Cookie
Else
req.Status = 8
req.Command.Respond "A profile could not be retreived for " & req.Name & "."
req.Command.SendResponse
reqDic.Remove req.Cookie
End If
ElseIf ID = &H82 Then
Set pak = DataBufferEx()
pak.Data = Data
pak.Position = 4
cookie = pak.GetDWORD
status = pak.GetByte
If Not reqDic.Exists(cookie) Then Exit Sub
Set req = reqDic(cookie)
If status = &H0 Then
req.ClanName = pak.GetString
req.ClanRankByte = pak.GetByte
req.ClanJoinDate = FileTimeToDate(pak.GetDWORD, pak.GetDWORD)
req.Status = 3
dt = Split(req.ClanJoinDate, " ")
req.Command.Respond StringFormat("{0} is a {1} in Clan '{2}' ({3}). They joined on {4} at {5} {6}.", req.Name, req.ClanRank, req.ClanName, req.ClanTag, dt(0), dt(1), dt(2))
Else
req.Status = 6
req.Command.Respond "An error occurred. A clan tag was returned ( " & req.ClanTag & ") but the user was not found in that clan."
End If
reqDic.Remove req.Cookie
req.Command.SendResponse
Set lastRequestObj = req
End If
End If
End Sub
Sub InitCommands()
Set cmd = OpenCommand(MI_COMMAND)
If cmd Is Nothing Then
Set cmd = CreateCommand(MI_COMMAND)
With cmd
.RequiredRank = 20
.RequiredFlags = "G"
.Description = "Gets the WarCraft 3 clan information for a user."
.Parameters.Add .NewParameter(MI_USER, False, "word")
.Save
End With
Set cmd = Nothing
End If
End Sub
Class ProfileRequest
Private requestStartTime
Private Sub Class_Initialize()
requestStartTime = Now
End Sub
Public Name
Public Cookie
Public Status
Public Command
Public ClanTag
Public ClanName
Public ClanRankByte
Public ClanJoinDate
Public Property Get ClanRank
Select Case ClanRankByte
Case &H0: ClanRank = "Peon (on probation)"
Case &H1: ClanRank = "Peon"
Case &H2: ClanRank = "Grunt"
Case &H3: ClanRank = "Shaman"
Case &H4: ClanRank = "Chieftain"
Case Else:
ClanRank = "Unknown (0x" & Right("00" & Hex(ClanRankByte), 2) & ")"
End Select
End Property
Public Property Get RequestTime
RequestTime = DateDiff("s", requestStartTime, Now)
End Property
End Class