ovolkov@0
|
1 local aName, aEnv = ...
|
ovolkov@0
|
2
|
ovolkov@0
|
3 local strchar = string.char
|
ovolkov@0
|
4 local strbyte = string.byte
|
ovolkov@0
|
5 local random = random
|
ovolkov@0
|
6 local strsub = strsub
|
ovolkov@0
|
7 local tonumber = tonumber
|
ovolkov@0
|
8
|
ovolkov@0
|
9 local function UniqSlashID(base, maxNumber)
|
ovolkov@0
|
10 local clear = true
|
ovolkov@0
|
11 for idx = 1, maxNumber do
|
ovolkov@0
|
12 if _G["SLASH_" .. base .. idx] then clear = false break end
|
ovolkov@0
|
13 end
|
ovolkov@0
|
14 if SlashCmdList[base] then clear = false end
|
ovolkov@0
|
15 if clear then return base end
|
ovolkov@0
|
16 return UniqSlashID(base .. (strchar(random(strbyte('a'), strbyte('z')))), maxNumber)
|
ovolkov@0
|
17 end
|
ovolkov@0
|
18
|
ovolkov@0
|
19 local slashID
|
ovolkov@0
|
20
|
ovolkov@0
|
21 slashID=UniqSlashID("LFGActivityFilter", 1)
|
ovolkov@0
|
22 _G["SLASH_" .. slashID .. "1"] = "/lfgaf"
|
ovolkov@0
|
23 SlashCmdList[slashID] = function(activities)
|
ovolkov@0
|
24 wipe(aEnv.LFGFilter_Allow_Activity)
|
ovolkov@0
|
25 local count = 0
|
ovolkov@0
|
26 for activity in string.gmatch(activities, "[^ ]+") do
|
ovolkov@0
|
27 local activity_id = tonumber(activity)
|
ovolkov@0
|
28 local activity_name
|
ovolkov@0
|
29 if activity_id then activity_name = C_LFGList.GetActivityInfo(activity_id) end
|
ovolkov@0
|
30 if activity_name then
|
ovolkov@0
|
31 print("Adding wanted activity to filter: ", activity_name)
|
ovolkov@0
|
32 aEnv.LFGFilter_Allow_Activity[activity_id] = true
|
ovolkov@0
|
33 count = count + 1
|
ovolkov@0
|
34 else
|
ovolkov@0
|
35 print("Can't parse activity ID or it doesn't match known activity: ", activity_id)
|
ovolkov@0
|
36 end
|
ovolkov@0
|
37 end
|
ovolkov@0
|
38 aEnv.LFGFilter_Allow_Activity.count = count
|
ovolkov@0
|
39 if count > 0 then
|
ovolkov@0
|
40 print("Activities in filter: ", count)
|
ovolkov@0
|
41 else
|
ovolkov@0
|
42 print("Filters removed.")
|
ovolkov@0
|
43 end
|
ovolkov@0
|
44 end
|
ovolkov@0
|
45
|
ovolkov@0
|
46 slashID=UniqSlashID("LFGActivityList", 1)
|
ovolkov@0
|
47 _G["SLASH_" .. slashID .. "1"] = "/lfgal"
|
ovolkov@0
|
48 SlashCmdList[slashID] = function()
|
ovolkov@0
|
49 for activity_id = 1, 10000 do
|
ovolkov@0
|
50 local activity_name = C_LFGList.GetActivityInfo(activity_id)
|
ovolkov@0
|
51 if activity_name then
|
ovolkov@0
|
52 print(activity_id, activity_name)
|
ovolkov@0
|
53 end
|
ovolkov@0
|
54 end
|
ovolkov@0
|
55 end |