Quantcast

Fix RollManager/ChatManager sending invalid item links to chat.

F16Gaming [11-28-12 - 16:52]
Fix RollManager/ChatManager sending invalid item links to chat.
Filename
ChatManager.lua
CommandManager.lua
RollManager.lua
diff --git a/ChatManager.lua b/ChatManager.lua
index b39dc76..cc0d2cb 100644
--- a/ChatManager.lua
+++ b/ChatManager.lua
@@ -112,12 +112,14 @@ end
 -- @param isBN Is this message targeted to a BNet friend?
 -- @param smartSay Fallback to SAY instead of local logging if not in group
 --
-function CM:SendMessage(msg, channel, target, isBN, smartSay)
+function CM:SendMessage(msg, channel, target, isBN, smartSay, raw)
 	isBN = isBN or false
 	if not self.Settings.LOCAL_ONLY then
 		-- Sanitize message
 		--msg = msg:gsub("|*", "|") -- First make sure every pipe char is alone (This is probably not needed)
-		msg = tostring(msg):gsub("|", "||") -- Escape the pipe characters
+		if not raw then
+			msg = tostring(msg):gsub("|", "||") -- Escape the pipe characters
+		end
 		msg = ("[%s] %s"):format(C.Name, msg)
 		if channel == "SMART" then
 			if GT:IsRaid() then
@@ -224,7 +226,8 @@ function CM:HandleMessage(msg, sender, channel, target, sourceChannel, isBN, pID
 		}
 	end
 	local player = PM:GetOrCreatePlayer(sender, realm)
-	local result, arg, errArg = CCM:HandleCommand(cmd, t, sourceChannel, player, bnetInfo)
+	local result, arg, errArg, extra = CCM:HandleCommand(cmd, t, sourceChannel, player, bnetInfo)
+	local raw = (extra and type(errArg) == "table") or (errArg and type(arg) == "table") or (arg and type(arg ~= "table"))
 	if isBN then
 		target = pID
 		sender = pID
@@ -243,7 +246,7 @@ function CM:HandleMessage(msg, sender, channel, target, sourceChannel, isBN, pID
 					if type(v[2]) == "table" then
 						s = s:format(unpack(v[2]))
 					end
-					self:SendMessage(s, channel, target, isBN)
+					self:SendMessage(s, channel, target, isBN, nil, raw)
 				end
 			end
 		elseif result == "RAW_TABLE_OUTPUT" then
@@ -252,20 +255,20 @@ function CM:HandleMessage(msg, sender, channel, target, sourceChannel, isBN, pID
 				return
 			end
 			for _,v in ipairs(arg) do
-				self:SendMessage(tostring(v), channel, target, isBN)
+				self:SendMessage(tostring(v), channel, target, isBN, nil, raw)
 			end
 		else
 			local s = l[result]
 			if type(arg) == "table" then
 				s = s:format(unpack(arg))
 			end
-			self:SendMessage(s, channel, target, isBN)
+			self:SendMessage(s, channel, target, isBN, nil, raw)
 		end
 	elseif arg then
 		local s = l[arg]
 		if type(errArg) == "table" then
 			s = s:format(unpack(errArg))
 		end
-		self:SendMessage(s, "WHISPER", sender, isBN)
+		self:SendMessage(s, "WHISPER", sender, isBN, nil, raw)
 	end
 end
diff --git a/CommandManager.lua b/CommandManager.lua
index ba26567..bdafde2 100644
--- a/CommandManager.lua
+++ b/CommandManager.lua
@@ -979,7 +979,7 @@ CM:Register({"roll", "r"}, PM.Access.Groups.Op.Level, function(args, sender, isC
 	args[1] = args[1]:lower()
 	if args[1]:match("^sta") then
 		if #args < 2 then
-			return false, "CM_LOOT_START_USAGE"
+			return false, "CM_ROLL_START_USAGE"
 		end
 		local time = tonumber(args[2])
 		local item
@@ -1018,7 +1018,7 @@ CM:Register({"roll", "r"}, PM.Access.Groups.Op.Level, function(args, sender, isC
 		end
 	elseif args[1]:match("^se") then -- Set
 		if #args < 3 then
-			return false, "CM_LOOT_SET_USAGE"
+			return false, "CM_ROLL_SET_USAGE"
 		end
 		args[2] = args[2]:lower()
 		if args[2]:match("^mi") then
@@ -1028,11 +1028,11 @@ CM:Register({"roll", "r"}, PM.Access.Groups.Op.Level, function(args, sender, isC
 		elseif args[2]:match("^t") then
 			return RM:SetTime(tonumber(args[3]))
 		else
-			return false, "CM_LOOT_SET_USAGE"
+			return false, "CM_ROLL_SET_USAGE"
 		end
 	end
-	return false, "CM_LOOT_USAGE"
-end, "CM_LOOT_HELP")
+	return false, "CM_ROLL_USAGE"
+end, "CM_ROLL_HELP")

 CM:Register({"raidwarning", "rw", "raid_warning"}, PM.Access.Groups.User.Level, function(args, sender, isChat, bnetInfo)
 	if not GT:IsRaid() then
diff --git a/RollManager.lua b/RollManager.lua
index c5bc5f1..f1e8114 100644
--- a/RollManager.lua
+++ b/RollManager.lua
@@ -150,7 +150,7 @@ function RM:StartRoll(sender, item, time)
 	if item then
 		self.Item = item
 		RollTimer.Frame:SetScript("OnUpdate", RollTimerUpdate)
-		return "RM_START_SUCCESSITEM", {self.Sender, self.Item, time, self.Settings.MIN_ROLL, self.Settings.MAX_ROLL}
+		return "RM_START_SUCCESSITEM", {self.Sender, self.Item, time, self.Settings.MIN_ROLL, self.Settings.MAX_ROLL}, true
 	else
 		RollTimer.Frame:SetScript("OnUpdate", RollTimerUpdate)
 		return "RM_START_SUCCESS", {self.Sender, time, self.Settings.MIN_ROLL, self.Settings.MAX_ROLL}