Quantcast

Add an option to ignore messages from self

James Whitehead II [01-13-11 - 17:28]
Add an option to ignore messages from self
Filename
CaptainsLog.lua
diff --git a/CaptainsLog.lua b/CaptainsLog.lua
index 637f4e9..5ffd31e 100644
--- a/CaptainsLog.lua
+++ b/CaptainsLog.lua
@@ -28,6 +28,9 @@ function addon:Initialize()
             buffersize = {
                 ["*"] = 10,
             },
+            ignoreself = {
+                ["*"] = true,
+            },
             showinfeed = {
                 whisper = true,
                 party = true,
@@ -52,6 +55,7 @@ function addon:Initialize()
         },
     })

+    self.name = UnitName("player")
     self.messages = self.db.char.messages

     self:RegisterEvent("CHAT_MSG_WHISPER")
@@ -167,6 +171,7 @@ end
 function addon:CHAT_MSG_WHISPER(event, msg, sender, ...)
     local mtype = "whisper"
     if not addon.db.profile.log[mtype] then return end
+    if sender == self.name and addon.db.profile.ignoreself[mtype] then return end

     local cname = GetColoredName(event, msg, sender, ...)
     self:Log(mtype, cname, msg)
@@ -176,6 +181,8 @@ end
 function addon:CHAT_MSG_GUILD(event, msg, sender, ...)
     local mtype = "guild"
     if not addon.db.profile.log[mtype] then return end
+    if sender == self.name and addon.db.profile.ignoreself[mtype] then return end
+
     local cname = GetColoredName(event, msg, sender, ...)
     self:Log(mtype, cname, msg)
     self:UpdateFeedText(mtype, cname)
@@ -184,6 +191,8 @@ end
 function addon:CHAT_MSG_PARTY(event, msg, sender, ...)
     local mtype = "party"
     if not addon.db.profile.log[mtype] then return end
+    if sender == self.name and addon.db.profile.ignoreself[mtype] then return end
+
     local cname = GetColoredName(event, msg, sender, ...)
     self:Log(mtype, cname, msg)
     self:UpdateFeedText(mtype, cname)
@@ -192,6 +201,8 @@ end
 function addon:CHAT_MSG_BN_WHISPER(event, msg, sender, ...)
     local mtype = "bnet"
     if not addon.db.profile.log[mtype] then return end
+    if sender == self.name and addon.db.profile.ignoreself[mtype] then return end
+
     self:Log(mtype, sender, msg)
     self:UpdateFeedText(mtype, sender)
 end
@@ -199,6 +210,8 @@ end
 function addon:CHAT_MSG_RAID(event, msg, sender, ...)
     local mtype = "raid"
     if not addon.db.profile.log[mtype] then return end
+    if sender == self.name and addon.db.profile.ignoreself[mtype] then return end
+
     local cname = GetColoredName(event, msg, sender, ...)
     self:Log(mtype, cname, msg)
     self:UpdateFeedText(mtype, cname)