This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChat.lua
85 lines (75 loc) · 2.77 KB
/
Chat.lua
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
--[[--
@module MyDungeonsBook
]]
local L = LibStub("AceLocale-3.0"):GetLocale("MyDungeonsBook");
local function isActiveChallengeId(challengeId)
return challengeId == "active" or challengeId == "a";
end
--[[--
Parse chat slash command `/mdb ...` or `/mydungeonsbook ...`.
@local
@param[type=string] msg some chat message
]]
function MyDungeonsBook:ParseChatCommand(msg)
local type, challengeId, resource, subResourceOrAction, actionOrNothing = self:GetArgs(msg, 10);
if (type == "challenge" or type == "c") then
return self:ParseChallengeChatCommand(challengeId, resource, subResourceOrAction, actionOrNothing);
end
if (type == "testcomm" or type == "tc") then
local _, target, message = self:GetArgs(msg, 10);
return self:ParseTestCommChatCommand(target, message);
end
if (type == "help" or type == "h") then
local tpl = "|c0070DE00%s|r - %s";
self:Print(string.format(tpl, "[..]", L["alias for previous word"]));
self:Print(string.format(tpl, "/mdb challenge[c] active[a] roster[r] {{unitId}} update[u]", L["update info about party member for current challenge. unitId must be 'player' or 'party1..4'."]));
self:Print(string.format(tpl, "/mdb testcomm[tc] {{unitId}} {{message}}", L["send some message via comm to other MDB user. unitId must be 'party1..4'."]));
self:Print(string.format(tpl, "/mdb help[h]", L["print this text."]));
return;
end
self:MainFrame_Show();
end
--[[--
Parse chat command related to Challenges (e.g. `/mdb c ...`).
@local
@param[type=string|number] challengeId
@param[type=string] resource
@param[type=string] subResourceOrAction
@param[type=string] actionOrNothing
]]
function MyDungeonsBook:ParseChallengeChatCommand(challengeId, resource, subResourceOrAction, actionOrNothing, ...)
if (resource == "roster" or resource == "r") then
return self:ParseRosterChatCommand(challengeId, resource, subResourceOrAction, actionOrNothing, ...);
end
end
--[[--
Parse chat command related to Challenge's Roster (e.g. `/mdb c a r ...`).
@local
@param[type=string|number] challengeId
@param[type=string] _
@param[type=string] subResource player or party1..4
@param[type=string] action
]]
function MyDungeonsBook:ParseRosterChatCommand(challengeId, _, subResource, action)
if (isActiveChallengeId(challengeId) and self.db.char.activeChallengeId) then
for _, unitId in pairs(self:GetPartyRoster()) do
if (unitId == subResource) then
if (action == "update" or action == "u") then
NotifyInspect(unitId);
end
end
end
end
end
--[[--
Send some message via comm
@param[type=unitId] target
@param[type=string] message
]]
function MyDungeonsBook:ParseTestCommChatCommand(target, message)
if (not UnitExists(target)) then
self:DebugPrint(string.format("Unit '%s' does not exists", target));
return;
end
self:Message_TestMessage_Send(target, message);
end