vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 assert( oRA, "oRA not found!")
2  
3 ------------------------------
4 -- Are you local? --
5 ------------------------------
6  
7 local L = AceLibrary("AceLocale-2.2"):new("oRAPRaidWarn")
8  
9 local blockregexs = {
10 "%*+ .+ %*+$",
11 }
12  
13 ----------------------------
14 -- Localization --
15 ----------------------------
16  
17 L:RegisterTranslations("enUS", function() return {
18 ["rw"] = true,
19 ["raidwarning"] = true,
20 ["Raidwarning"] = true,
21 ["Options for raid warning."] = true,
22 ["Participant/RaidWarn"] = true,
23 ["Bossblock"] = true,
24 ["Block messages from Bossmods."] = true,
25 } end )
26  
27 L:RegisterTranslations("koKR", function() return {
28  
29 ["Raidwarning"] = "공격대 경고",
30 ["Options for raid warning."] = "공격대 경고 설정",
31 ["Participant/RaidWarn"] = "부분/공격대경고",
32 ["Bossblock"] = "보스차단",
33 ["Block messages from Bossmods."] = "보스 모드 관련 메세지 차단",
34 } end )
35  
36 L:RegisterTranslations("zhCN", function() return {
37 ["rw"] = "rw",
38 ["raidwarning"] = "团队警告",
39 ["Raidwarning"] = "团队警告",
40 ["Options for raid warning."] = "团队警告选项",
41 ["Participant/RaidWarn"] = "Participant/RaidWarn",
42 ["Bossblock"] = "阻止bossmod预警",
43 ["Block messages from Bossmods."] = "阻止bossmod预警",
44 } end )
45  
46 L:RegisterTranslations("zhTW", function() return {
47 ["rw"] = "rw",
48 ["raidwarning"] = "團隊警告",
49 ["Raidwarning"] = "團隊警告",
50 ["Options for raid warning."] = "團隊警告選項",
51 ["Participant/RaidWarn"] = "隊員/團隊警告",
52 ["Bossblock"] = "阻擋bossmod預警",
53 ["Block messages from Bossmods."] = "阻擋bossmod的預警訊息",
54 } end )
55  
56 L:RegisterTranslations("frFR", function() return {
57 --["rw"] = true,
58 --["raidwarning"] = true,
59 ["Raidwarning"] = "Avertissement du raid",
60 ["Options for raid warning."] = "Options concernant l'avertissement du raid.",
61 ["Participant/RaidWarn"] = "Participant/Avertissement du raid",
62 ["Bossblock"] = "BloquerBoss",
63 ["Block messages from Bossmods."] = "Bloque les messages provenant des bossmods.",
64 } end )
65  
66 ----------------------------------
67 -- Module Declaration --
68 ----------------------------------
69  
70 oRAPRaidWarn = oRA:NewModule(L["raidwarning"])
71 oRAPRaidWarn.defaults = {
72 bossblock = true,
73 }
74 oRAPRaidWarn.participant = true
75 oRAPRaidWarn.name = L["Participant/RaidWarn"]
76  
77 oRAPRaidWarn.consoleCmd = L["rw"]
78 oRAPRaidWarn.consoleOptions = {
79 type = "group",
80 desc = L["Options for raid warning."],
81 name = L["Raidwarning"],
82 args = {
83 [L["Bossblock"]] = {
84 name = L["Bossblock"], type = "toggle",
85 desc = L["Block messages from Bossmods."],
86 get = function() return oRAPRaidWarn.db.profile.bossblock end,
87 set = function(v)
88 oRAPRaidWarn.db.profile.bossblock = v
89 end,
90 },
91 }
92 }
93  
94  
95 ------------------------------
96 -- Initialization --
97 ------------------------------
98  
99 function oRAPRaidWarn:OnEnable()
100 self.core:RegisterCheck("MS", "oRA_RaidWarnMessage")
101  
102 self:RegisterEvent("oRA_RaidWarnMessage")
103 end
104  
105 function oRAPRaidWarn:OnDisable()
106  
107 self:UnregisterAllEvents()
108  
109 self:UnregisterCheck("MS")
110 end
111  
112  
113 -------------------------------
114 -- Event Handlers --
115 -------------------------------
116  
117 function oRAPRaidWarn:oRA_RaidWarnMessage(msg, author)
118 if not self.core:IsValidRequest(author) then return end
119 msg = self.core:CleanMessage(msg)
120  
121 if not msg then return end
122  
123 _,_, msg = string.find(msg, "^MS (.+)$")
124  
125 if not msg then return end
126  
127 if self.db.profile.bossblock and self:IsSpam(msg) then return end
128  
129 local info = ChatTypeInfo["RAID_WARNING"]
130  
131 PlaySound("RaidWarning")
132  
133 RaidWarningFrame:AddMessage( author .. ": " .. msg, info.r, info.g, info.b, 1.0, UIERRORS_HOLD_TIME)
134 end
135  
136 function oRAPRaidWarn:IsSpam(text)
137 if not text then return end
138 for _,regex in pairs(blockregexs) do if string.find(text, regex) then return true end end
139 end