Print status messages to current chat tab.

Sasky [06-25-14 - 08:37]
Print status messages to current chat tab.
Filename
AutoInvite.lua
AutoInvite.txt
diff --git a/AutoInvite.lua b/AutoInvite.lua
index 5b0796d..7b7715b 100644
--- a/AutoInvite.lua
+++ b/AutoInvite.lua
@@ -26,6 +26,7 @@ AutoInvite.AddonId = "AutoInvite"
 local function b(v) if v then return "T" else return "F" end end
 local function nn(val) if val == nil then return "NIL" else return val end end
 local function dbg(msg) if AutoInvite.debug then d("|c999999" .. msg) end end
+local function echo(msg) CHAT_SYSTEM.primaryContainer.currentBuffer:AddMessage("|CFFFF00"..msg) end

 AutoInvite.isCyrodiil = function(unit)
     if unit == nil then unit = "player" end
@@ -51,7 +52,7 @@ AutoInvite.guildLookup = function(channel, acctName)
             -- Might use zone check to NOT auto-invite people outside current zone if leader in Cyrodiil

             if not hasChar then
-                d("Could not find player name for " .. acctName .. ". Please manually invite.")
+                echo("Could not find player name for " .. acctName .. ". Please manually invite.")
                 return ""
             end

@@ -61,8 +62,8 @@ AutoInvite.guildLookup = function(channel, acctName)
                 dbg("In Cyrodiil? " .. b(AutoInvite.isCyrodiil()) .. " / Zone: " .. zone)

                 if AutoInvite.isCyrodiil() and zone ~= "Cyrodiil" then
-                    d("Player " .. charName .. " is not in Cyrodiil but in " .. zone)
-                    d("Blocking invite to prevent crashes.")
+                    echo("Player " .. charName .. " is not in Cyrodiil but in " .. zone)
+                    echo("Blocking invite to prevent crashes.")
                     return ""
                 end
             end
@@ -106,7 +107,7 @@ AutoInvite.callback = function(_, messageType, from, message)

     --TODO: Switch to queue-based with timeouts so don't send out too many invites
 	if GetGroupSize() >= AutoInvite.cfg.maxSize then
-		d("Group full. Disabling AutoInvite")
+        echo("Group full. Disabling AutoInvite")
         AutoInvite.stopListening()
 	end

@@ -119,7 +120,7 @@ AutoInvite.callback = function(_, messageType, from, message)
         --TODO: Add friends list lookup

 		from = from:gsub("%^.+", "")
-		d("Sending invite to " .. from)
+        echo("Sending invite to " .. from)
 		GroupInvite(from)
 		GroupInviteByName(from)
 	end
@@ -129,6 +130,7 @@ end

 AutoInvite.playerLeave = function()
     if AutoInvite.enabled and AutoInvite.cfg.restart and GetGroupSize() < AutoInvite.cfg.maxSize then
+        echo("Now space in group. Restarted listening.")
         AutoInvite.startListening()
     end

@@ -149,6 +151,7 @@ end

 function AutoInvite.disbandEvent()
     if AutoInvite.enabled and AutoInvite.cfg.restart then
+        echo("Group disbanded. Restarted listening.")
         AutoInvite.startListening()
     end
 end
@@ -161,7 +164,7 @@ function AutoInvite.kickCheck()
     for p,t in pairs(AutoInvite.kickTable) do
         local offTime = GetDiffBetweenTimeStamps(now, t)
         if offTime > AutoInvite.cfg.kickDelay then
-            dbg("  KICK: " .. p .. " offline for " .. offTime)
+            echo("  KICK: " .. p .. " offline for " .. offTime)
             AutoInvite.kickByName(p)
         else
             dbg(p .. " offline for " .. offTime .. " / " .. AutoInvite.cfg.kickDelay)
@@ -199,7 +202,7 @@ AutoInvite.startListening = function()
     end

     --First check. When option, will have to check option for disable
-	d("AutoInvite listening on string '" .. AutoInvite.cfg.watchStr .. "'")
+	echo("AutoInvite listening on string '" .. AutoInvite.cfg.watchStr .. "'")
 end

 ------------------------------------------------
@@ -209,10 +212,10 @@ end

 -- print command usage
 AutoInvite.help = function()
-    d("AutoInvite - command '/ai <str>'. Usage")
-    d("  '/ai foo' - autoInvite on 'foo' command'")
-    d("  '/ai help' - show this menu")
-    d("  '/ai' - turn off autoInvite (auto on group full)")
+    echo("AutoInvite - command '/ai <str>'. Usage")
+    echo("  '/ai foo' - autoInvite on 'foo' command'")
+    echo("  '/ai help' - show this menu")
+    echo("  '/ai' - turn off autoInvite (auto on group full)")
     return
 end

@@ -223,7 +226,7 @@ SLASH_COMMANDS["/ai"] = function(str)
             AutoInvite.help()
             return
         end
-        d("Disabling AutoInvite")
+        echo("Disabling AutoInvite")
         AutoInvite.disable()
         return
     end
@@ -233,11 +236,6 @@ SLASH_COMMANDS["/ai"] = function(str)
     AutoInviteUI.refresh()
 end

-
-SLASH_COMMANDS["/zdb9"] = function()
-    d("In Cyrodiil? " .. b(AutoInvite.isCyrodiil()))
-end
-
 ------------------------------------------------
 --- Initialization
 ------------------------------------------------
@@ -280,7 +278,7 @@ SLASH_COMMANDS["/aik"] = function()
 end

 SLASH_COMMANDS["/aidebug"] = function()
-    d("|cFF0000Beginning debug mode for AutoInvite.")
+    echo("|cFF0000Beginning debug mode for AutoInvite.")
     AutoInvite.debug = true
 end

@@ -290,10 +288,10 @@ SLASH_COMMANDS["/aikick"] = function()
     for p,t in pairs(AutoInvite.kickTable) do
         local offTime = now - t
         if offTime > AutoInvite.cfg.kickDelay then
-            d("  KICK: " .. p .. " offline for " .. now - t)
+            echo("  KICK: " .. p .. " offline for " .. now - t)
             GroupKickByName(p)
         else
-            d("  " .. p .. " offline for " .. now - t)
+            dbg("  " .. p .. " offline for " .. now - t)
         end
     end
 end
diff --git a/AutoInvite.txt b/AutoInvite.txt
index 46da4b7..da0db49 100644
--- a/AutoInvite.txt
+++ b/AutoInvite.txt
@@ -1,6 +1,6 @@
 ## APIVersion: 100007
 ## Title: AutoInvite
-## Version: 1.3.2
+## Version: 1.4.0
 ## Author: Sasky
 ## SavedVariables: AutoInviteSettings
 ## OptionalDependsOn: LibAddonMenu-2.0