-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPuggers.lua
More file actions
352 lines (340 loc) · 14.2 KB
/
Copy pathPuggers.lua
File metadata and controls
352 lines (340 loc) · 14.2 KB
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
-- Coded by Iokanaan from Bloodlust @ Archimonde EU
-- Modified for Puggers.eu by Brotard-Magtheridon
-- Menu structure
UnitPopupButtons["PGS"] = {text = "Puggers Link", dist = 0, checkable = nil}
table.insert(UnitPopupMenus["SELF"], #(UnitPopupMenus["SELF"])-1, "PGS")
table.insert(UnitPopupMenus["PARTY"], #(UnitPopupMenus["PARTY"])-1, "PGS")
table.insert(UnitPopupMenus["PLAYER"], #(UnitPopupMenus["PLAYER"])-1, "PGS")
table.insert(UnitPopupMenus["RAID_PLAYER"], #(UnitPopupMenus["RAID_PLAYER"])-1, "PGS")
table.insert(UnitPopupMenus["GUILD"], #(UnitPopupMenus["GUILD"])-1, "PGS")
table.insert(UnitPopupMenus["GUILD_OFFLINE"], #(UnitPopupMenus["GUILD_OFFLINE"])-1, "PGS")
table.insert(UnitPopupMenus["FRIEND"], #(UnitPopupMenus["FRIEND"])-1, "PGS")
table.insert(UnitPopupMenus["FRIEND_OFFLINE"], #(UnitPopupMenus["FRIEND_OFFLINE"])-1, "PGS")
table.insert(UnitPopupMenus["CHAT_ROSTER"], #(UnitPopupMenus["CHAT_ROSTER"])-1, "PGS")
-- Get current region
local function getRegion()
local regionLabel = {"us", "kr", "eu", "tw", "cn"}
local regionId = GetCurrentRegion()
return regionLabel[regionId]
end
-- Create the link
local function buildLink(name,site)
local char, server = string.match(name, "(.-)-(.*)")
if not char then
char = name
server = GetRealmName()
end
server = FixRealmName(server)
serverMythicPlusHelper = server
server = string.gsub(server, "(%l)(%u)", "%1-%2")
server = string.gsub(server, " ", "-")
serverArmory = server
serverWarcraftLogs = server
server = string.gsub(server, "'", "-")
server = string.gsub(server, "’", "-")
serverWarcraftLogs = string.gsub(serverWarcraftLogs, "'", "")
serverWarcraftLogs = string.gsub(serverWarcraftLogs, "’", "")
if server == "" then
DEFAULT_CHAT_FRAME:AddMessage("|CFFFF6060Puggers|r: ".."Out of range!")
else
local region = getRegion()
local url = ""
local role = UnitGroupRolesAssigned(char)
if site == "puggers" then
url = "https://puggers.eu/character/" .. region .. "/" .. server .. "/" .. char
end
return url
end
end
-- Display the link
local function ShowUrl(name,site)
if not name then return end
local url = buildLink(name,site)
if url then
local edit_box = ChatEdit_ChooseBoxForSend()
ChatEdit_ActivateChat(edit_box)
if url then
edit_box:Insert(url)
edit_box:HighlightText()
end
end
end
--Menu interaction
local CURRENT_NAME, CURRENT_SERVER
hooksecurefunc("UnitPopup_ShowMenu", function (dropdownMenu, which, unit, name, userData)
local server = nil
if UIDROPDOWNMENU_MENU_LEVEL == 1 then
if ( unit ) then
name, server = UnitName(unit)
elseif ( name ) then
local n, s = strmatch(name, "^([^-]+)-(.*)")
if ( n ) then
name = n
server = s
end
end
CURRENT_NAME = name
CURRENT_SERVER = server
end
end)
hooksecurefunc("UnitPopup_OnClick", function(self)
local site
local name, realm = UIDROPDOWNMENU_INIT_MENU.name, UIDROPDOWNMENU_INIT_MENU.server
if name == CURRENT_NAME and not realm then realm = CURRENT_SERVER end
if self.value == "PGS" then
site = "puggers"
else return
end
if realm then
ShowUrl(name .. "-" .. realm,site)
else
ShowUrl(name,site)
end
end)
-- LFG tool menu when searching for a group
local LFG_LIST_SEARCH_ENTRY_MENU = {
{
text = nil,
isTitle = true,
notCheckable = true,
},
{
text = WHISPER_LEADER,
func = function(_, name) ChatFrame_SendTell(name) end,
notCheckable = true,
arg1 = nil,
disabled = nil,
tooltipWhileDisabled = 1,
tooltipOnButton = 1,
tooltipTitle = nil,
tooltipText = nil,
},
{
text = "Puggers link",
func = function(_, name) ShowUrl(name,"puggers") end,
notCheckable = true,
arg1 = nil,
disabled = nil,
},
{
text = LFG_LIST_REPORT_GROUP_FOR,
hasArrow = true,
notCheckable = true,
menuList = {
{
text = LFG_LIST_BAD_NAME,
func = function(_, id) C_LFGList.ReportSearchResult(id, "lfglistname") end,
arg1 = nil,
notCheckable = true,
},
{
text = LFG_LIST_BAD_DESCRIPTION,
func = function(_, id) C_LFGList.ReportSearchResult(id, "lfglistcomment") end,
arg1 = nil,
notCheckable = true,
disabled = nil,
},
{
text = LFG_LIST_BAD_VOICE_CHAT_COMMENT,
func = function(_, id) C_LFGList.ReportSearchResult(id, "lfglistvoicechat") end,
arg1 = nil,
notCheckable = true,
disabled = nil,
},
{
text = LFG_LIST_BAD_LEADER_NAME,
func = function(_, id) C_LFGList.ReportSearchResult(id, "badplayername") end,
arg1 = nil,
notCheckable = true,
disabled = nil,
},
},
},
{
text = CANCEL,
notCheckable = true,
},
}
function LFGListUtil_GetSearchEntryMenu(resultID)
local id, activityID, name, comment, voiceChat, iLvl, honorLevel, age, numBNetFriends, numCharFriends, numGuildMates, isDelisted, leaderName, numMembers = C_LFGList.GetSearchResultInfo(resultID)
local _, appStatus, pendingStatus, appDuration = C_LFGList.GetApplicationInfo(resultID)
LFG_LIST_SEARCH_ENTRY_MENU[1].text = name
LFG_LIST_SEARCH_ENTRY_MENU[2].arg1 = leaderName
LFG_LIST_SEARCH_ENTRY_MENU[2].disabled = not leaderName
LFG_LIST_SEARCH_ENTRY_MENU[3].arg1 = leaderName
LFG_LIST_SEARCH_ENTRY_MENU[4].menuList[1].arg1 = resultID
LFG_LIST_SEARCH_ENTRY_MENU[4].menuList[2].arg1 = resultID
LFG_LIST_SEARCH_ENTRY_MENU[4].menuList[2].disabled = (comment == "")
LFG_LIST_SEARCH_ENTRY_MENU[4].menuList[3].arg1 = resultID
LFG_LIST_SEARCH_ENTRY_MENU[4].menuList[3].disabled = (voiceChat == "")
LFG_LIST_SEARCH_ENTRY_MENU[4].menuList[4].arg1 = resultID
LFG_LIST_SEARCH_ENTRY_MENU[4].menuList[4].disabled = not leaderName
return LFG_LIST_SEARCH_ENTRY_MENU
end
-- LFG tool menu when forming a group
local LFG_LIST_APPLICANT_MEMBER_MENU = {
{
text = nil,
isTitle = true,
notCheckable = true,
},
{
text = WHISPER,
func = function(_, name) ChatFrame_SendTell(name) end,
notCheckable = true,
arg1 = nil,
disabled = nil,
},
{
text = "Puggers link",
hasArrow = false,
notCheckable = true,
func = function(_, name) ShowUrl(name,"puggers") end,
notCheckable = true,
arg1 = nil,
disabled = nil,
},
{
text = LFG_LIST_REPORT_FOR,
hasArrow = true,
notCheckable = true,
menuList = {
{
text = LFG_LIST_BAD_PLAYER_NAME,
notCheckable = true,
func = function(_, id, memberIdx) C_LFGList.ReportApplicant(id, "badplayername", memberIdx) end,
arg1 = nil,
arg2 = nil,
},
{
text = LFG_LIST_BAD_DESCRIPTION,
notCheckable = true,
func = function(_, id) C_LFGList.ReportApplicant(id, "lfglistappcomment") end,
arg1 = nil,
},
},
},
{
text = IGNORE_PLAYER,
notCheckable = true,
func = function(_, name, applicantID) AddIgnore(name) C_LFGList.DeclineApplicant(applicantID) end,
arg1 = nil,
arg2 = nil,
disabled = nil,
},
{
text = CANCEL,
notCheckable = true,
},
}
function LFGListUtil_GetApplicantMemberMenu(applicantID, memberIdx)
local name, class, localizedClass, level, itemLevel, tank, healer, damage, assignedRole = C_LFGList.GetApplicantMemberInfo(applicantID, memberIdx)
local id, status, pendingStatus, numMembers, isNew, comment = C_LFGList.GetApplicantInfo(applicantID)
LFG_LIST_APPLICANT_MEMBER_MENU[1].text = name or " "
LFG_LIST_APPLICANT_MEMBER_MENU[2].arg1 = name
LFG_LIST_APPLICANT_MEMBER_MENU[2].disabled = not name or (status ~= "applied" and status ~= "invited")
LFG_LIST_APPLICANT_MEMBER_MENU[3].arg1 = name
LFG_LIST_APPLICANT_MEMBER_MENU[4].menuList[1].arg1 = applicantID
LFG_LIST_APPLICANT_MEMBER_MENU[4].menuList[1].arg2 = memberIdx
LFG_LIST_APPLICANT_MEMBER_MENU[4].menuList[2].arg1 = applicantID
LFG_LIST_APPLICANT_MEMBER_MENU[4].menuList[2].disabled = (comment == "")
LFG_LIST_APPLICANT_MEMBER_MENU[5].arg1 = name
LFG_LIST_APPLICANT_MEMBER_MENU[5].arg2 = applicantID
LFG_LIST_APPLICANT_MEMBER_MENU[5].disabled = not name
return LFG_LIST_APPLICANT_MEMBER_MENU
end
-- Server name fix
function FixRealmName(server)
if server == nil then return end
server = string.gsub(server, "AeriePeak", "Aerie Peak")
server = string.gsub(server, "AltarofStorms", "Altar of Storms")
server = string.gsub(server, "AlteracMountains", "Alterac Mountains")
server = string.gsub(server, "Area52", "Area 52")
server = string.gsub(server, "ArgentDawn", "Argent Dawn")
server = string.gsub(server, "BlackDragonflight", "Black Dragonflight")
server = string.gsub(server, "BlackwaterRaiders", "Blackwater Raiders")
server = string.gsub(server, "BlackwingLair", "Blackwing Lair")
server = string.gsub(server, "Blade'sEdge", "Blade's Edge")
server = string.gsub(server, "BleedingHollow", "Bleeding Hollow")
server = string.gsub(server, "BloodFurnace", "Blood Furnace")
server = string.gsub(server, "BootyBay", "Booty Bay")
server = string.gsub(server, "BoreanTundra", "Borean Tundra")
server = string.gsub(server, "BronzeDragonflight", "Bronze Dragonflight")
server = string.gsub(server, "BurningBlade", "Burning Blade")
server = string.gsub(server, "BurningLegion", "Burning Legion")
server = string.gsub(server, "BurningSteppes", "Burning Steppes")
server = string.gsub(server, "CenarionCircle", "Cenarion Circle")
server = string.gsub(server, "ChamberofAspects", "Chamber of Aspects")
server = string.gsub(server, "Chantséternels", "Chants éternels ")
server = string.gsub(server, "ColinasPardas", "Colinas Pardas")
server = string.gsub(server, "ConfrérieduThorium", "Confrérie du Thorium")
server = string.gsub(server, "ConseildesOmbres", "Conseil des Ombres")
server = string.gsub(server, "CultedelaRivenoire", "Culte de la Rive noire")
server = string.gsub(server, "DarkIron", "Dark Iron")
server = string.gsub(server, "DarkmoonFaire", "Darkmoon Faire")
server = string.gsub(server, "DasKonsortium", "Das Konsortium")
server = string.gsub(server, "DasSyndikat", "Das Syndikat")
server = string.gsub(server, "DefiasBrotherhood", "Defias Brotherhood")
server = string.gsub(server, "DemonSoul", "Demon Soul")
server = string.gsub(server, "DerRatvonDalaran", "Der Rat von Dalaran")
server = string.gsub(server, "DerabyssischeRat", "Der abyssische Rat")
server = string.gsub(server, "DieArguswacht", "Die Arguswacht")
server = string.gsub(server, "DieSilberneHand", "Die Silberne Hand")
server = string.gsub(server, "DieTodeskrallen", "Die Todeskrallen")
server = string.gsub(server, "DieewigeWacht", "Die ewige Wacht")
server = string.gsub(server, "DunModr", "Dun Modr")
server = string.gsub(server, "EarthenRing", "Earthen Ring")
server = string.gsub(server, "EchoIsles", "Echo Isles")
server = string.gsub(server, "EmeraldDream", "Emerald Dream")
server = string.gsub(server, "FestungderStürme", "Festung der Stürme")
server = string.gsub(server, "GrimBatol", "Grim Batol")
server = string.gsub(server, "GrizzlyHills", "Grizzly Hills")
server = string.gsub(server, "HowlingFjord", "Howling Fjord")
server = string.gsub(server, "KhazModan", "Khaz Modan")
server = string.gsub(server, "KirinTor", "Kirin Tor")
server = string.gsub(server, "KulTiras", "Kul Tiras")
server = string.gsub(server, "KultderVerdammten", "Kult der Verdammten")
server = string.gsub(server, "LaCroisadeécarlate", "La Croisade écarlate")
server = string.gsub(server, "LaughingSkull", "Laughing Skull")
server = string.gsub(server, "LesClairvoyants", "Les Clairvoyants")
server = string.gsub(server, "LesSentinelles", "Les Sentinelles")
server = string.gsub(server, "LichKing", "Lich King")
server = string.gsub(server, "Lightning'sBlade", "Lightning's Blade")
server = string.gsub(server, "LosErrantes", "Los Errantes")
server = string.gsub(server, "MarécagedeZangar", "Marécage de Zangar")
server = string.gsub(server, "MoonGuard", "Moon Guard")
server = string.gsub(server, "Pozzodell'Eternità", "Pozzo dell'Eternità")
server = string.gsub(server, "ScarletCrusade", "Scarlet Crusade")
server = string.gsub(server, "ScarshieldLegion", "Scarshield Legion")
server = string.gsub(server, "ShadowCouncil", "Shadow Council")
server = string.gsub(server, "ShatteredHalls", "Shattered Halls")
server = string.gsub(server, "ShatteredHand", "Shattered Hand")
server = string.gsub(server, "SilverHand", "Silver Hand")
server = string.gsub(server, "SistersofElune", "Sisters of Elune")
server = string.gsub(server, "SteamwheedleCartel", "Steamwheedle Cartel")
server = string.gsub(server, "TarrenMill", "Tarren Mill")
server = string.gsub(server, "Templenoir", "Temple noir")
server = string.gsub(server, "TheForgottenCoast", "The Forgotten Coast")
server = string.gsub(server, "TheMaelstrom", "The Maelstrom")
server = string.gsub(server, "TheScryers", "The Scryers")
server = string.gsub(server, "TheSha'tar", "The Sha'tar")
server = string.gsub(server, "TheUnderbog", "The Underbog")
server = string.gsub(server, "TheVentureCo", "The Venture Co")
server = string.gsub(server, "ThoriumBrotherhood", "Thorium Brotherhood")
server = string.gsub(server, "TolBarad", "Tol Barad")
server = string.gsub(server, "Twilight'sHammer", "Twilight's Hammer")
server = string.gsub(server, "TwistingNether", "Twisting Nether")
server = string.gsub(server, "WyrmrestAccord", "Wyrmrest Accord")
server = string.gsub(server, "ZirkeldesCenarius", "Zirkel des Cenarius")
server = string.gsub(server, "Борейскаятундра", "Борейская тундра")
server = string.gsub(server, "ВечнаяПесня", "Вечная Песня")
server = string.gsub(server, "Корольлич", "Король-лич")
server = string.gsub(server, "Пиратскаябухта", "Пиратская бухта")
server = string.gsub(server, "Ревущийфьорд", "Ревущий фьорд")
server = string.gsub(server, "СвежевательДуш", "Свежеватель Душ")
server = string.gsub(server, "СтражСмерти","Страж Смерти")
server = string.gsub(server, "ТкачСмерти", "Ткач Смерти")
server = string.gsub(server, "ЧерныйШрам", "Черный Шрам")
server = string.gsub(server, "Ясеневыйлес", "Ясеневый лес")
return server
end