-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPairing.lua
More file actions
39 lines (34 loc) · 869 Bytes
/
Pairing.lua
File metadata and controls
39 lines (34 loc) · 869 Bytes
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
local ADDON_NAME, ns = ...
local Pairing = {}
ns.Pairing = Pairing
local addon
function Pairing:Initialize(parent)
addon = parent
end
local function normalize(name)
if not name or name == "" then
return nil, "empty"
end
name = name:gsub("%s+", "")
local char, realm = name:match("^([^%-]+)%-(.+)$")
if not char or not realm then
return nil, "expected format: Charname-Realm"
end
-- WoW's whisper API expects the realm part as written (spaces stripped).
return char .. "-" .. realm
end
function Pairing:SetPartner(name)
if name == nil then
addon.db.global.partner = nil
return true, nil
end
local normalized, err = normalize(name)
if not normalized then
return false, nil, err
end
addon.db.global.partner = normalized
return true, normalized
end
function Pairing:GetPartner()
return addon.db.global.partner
end