3.3.0 whisper only option

git [05-27-18 - 12:58]
3.3.0 whisper only option
Filename
00_startup.lua
DASContextMenu.lua
DASHelper.lua
DASMenu.lua
DASUserSettingsAdapter.lua
DailyAutoShare.txt
DasChatMessage.lua
DasGui.lua
DasGuiStringBuilder.lua
diff --git a/00_startup.lua b/00_startup.lua
index 540e571..1eb5ecd 100644
--- a/00_startup.lua
+++ b/00_startup.lua
@@ -3,7 +3,7 @@ DAS                         = DailyAutoShare
 local DailyAutoShare        = DailyAutoShare

 DAS.name                    = "DailyAutoshare"
-DAS.version                 = "3.2.2"
+DAS.version                 = "3.3.0"
 DAS.author                  = "manavortex"
 DAS.settings                = {}
 DAS.globalSettings          = {}
@@ -127,6 +127,8 @@ local defaults = {
 	guildInviteText,
     questShareString            = "I can give a DailyAutoShare for <<1>>, type <<2>> for an instant invite",
 	listenInGuilds,
+    whisperOnly                 = false,
+    whisperString               = "whisper + for an instant invite",
     ["tracked"] = {
 		[684] = true,
 		[823] = true,
@@ -250,9 +252,7 @@ local function OnGroupTypeChanged(eventCode, unitTag)
         return
     end

-    if DAS.GetStopInviteOnDegroup() then
-        DAS.SetAutoInvite(false)
-    end
+    if DAS.GetStopInviteOnDegroup() then DAS.SetAutoInvite(false) end

 end

@@ -293,7 +293,6 @@ local function OnChatMessage(eventCode, channelType, fromName, messageText, _, f
     return DAS.OnChatMessage(eventCode, channelType, fromName, messageText, _, fromDisplayName)
 end

-
 local function OnPlayerActivated(eventCode)
 	local active 		= DAS.GetActiveIn()
 	DAS.SetHidden(not active)
@@ -343,17 +342,20 @@ local function deleteYesterdaysLog()
 	end
 end

-local QUEST_TRACKER = QUEST_TRACKER or FOCUSED_QUEST_TRACKER
-local function hookQuestTracker()
-    -- pts fix
-
-	local function refreshLabels()
-		DAS.RefreshLabels(false, true)
-	end
-
-    if nil ~= QUEST_TRACKER then
-        ZO_PreHook(QUEST_TRACKER, "ForceAssist", refreshLabels)
-    end
+local alreadyRefreshing = false
+local function questRefresh()
+    alreadyRefreshing = false
+    DAS.RefreshControl(true)
+end
+local function queueQuestRefresh()
+    if alreadyRefreshing then return end
+    alreadyRefreshing = true
+    zo_callLater(questRefresh, 600)
+end
+
+local function hookQuestTracker()
+    ZO_PreHook(FOCUSED_QUEST_TRACKER, "ForceAssist", DAS.questTrackerUpdate)
+
 end

 --==============================
diff --git a/DASContextMenu.lua b/DASContextMenu.lua
index 6eccba8..4f87dd0 100644
--- a/DASContextMenu.lua
+++ b/DASContextMenu.lua
@@ -51,11 +51,12 @@ end
 local function abandonQuest()
     AbandonQuest(journalIndex)
     DAS.LogQuest(questName, false)
-    DAS.RefreshLabels(true)
+    DAS.questCacheNeedsRefresh = true
+    DAS.RefreshLabelsWithDelay()
 end
 local function toggleQuest()
     DAS.ToggleQuest(currentControl)
-    zo_callLater(DAS.RefreshLabels, 500)
+    DAS.RefreshLabelsWithDelay()
 end
 local function toggleSubList()
     DasSubList:SetHidden(not DasSubList:IsHidden())
diff --git a/DASHelper.lua b/DASHelper.lua
index c6a7324..c6930d8 100644
--- a/DASHelper.lua
+++ b/DASHelper.lua
@@ -8,12 +8,10 @@ function DAS.GetArrayEntry(array, key)
 	end
 end
 function DAS.SetChatListenerStatus(status)
-
     DAS.channelTypes[CHAT_CHANNEL_SAY ]     = status
     DAS.channelTypes[CHAT_CHANNEL_YELL]     = status
-    DAS.channelTypes[CHAT_CHANNEL_ZONE]     = status
+    DAS.channelTypes[CHAT_CHANNEL_ZONE]     = status and not DAS.GetWhisperOnly()
     DAS.channelTypes[CHAT_CHANNEL_WHISPER]  = status
-
 end

 -- DAS_STATUS_COMPLETE 	= 0,
@@ -22,10 +20,13 @@ end
 -- DAS_STATUS_TRACKED 	= 3
 local refreshedRecently = false
 function refreshQuestLogs(forceOverride)
-
-	forceOverride 			= forceOverride or DAS.QuestIndexTable == {} or DAS.QuestNameTable == {}
+
+	forceOverride 			= forceOverride or DAS.questCacheNeedsRefresh or DAS.QuestIndexTable == {} or DAS.QuestNameTable == {}
 	if forceOverride 		then refreshedRecently = false end
 	if refreshedRecently 	then return end
+
+    DAS.questCacheNeedsRefresh = false
+
 	DAS.QuestIndexTable		= {}
 	DAS.QuestNameTable		= {}
 	for i=1, 25 do
diff --git a/DASMenu.lua b/DASMenu.lua
index 9d8c18c..d5c5704 100644
--- a/DASMenu.lua
+++ b/DASMenu.lua
@@ -351,7 +351,13 @@ function DAS.CreateMenu(savedVars, defaults)
 				},
 			},
 		},
-
+		{ -- checkbox: Hide UI window
+			type    = "checkbox",
+			name    = "Use whisper only",
+            tooltip = "This will ignore bingo spam in zone chat!",
+			getFunc = function() return DAS.GetWhisperOnly() end,
+			setFunc = function(value) DAS.SetWhisperOnly(value) end
+		},

 		{ -- header: Use global variables?
 			type    = "header",
@@ -371,6 +377,15 @@ function DAS.CreateMenu(savedVars, defaults)
                                 .. "Omit either to remove parameter. Include neither and sound like a fool."),
                     getFunc     = function() return DAS.GetSettings().questShareString end,
                     setFunc     = function(value) DAS.GetSettings().questShareString = value end,
+                },
+                {   -- editbox: Quest share text
+                    type        = "editbox",
+                    isExtraWide = true,
+                    name        = "Whisper only text",
+                    disabled    = not DAS.GetWhisperOnly(),
+                    tooltip     = "Will replace everything after <<1>>, in the string above",
+                    getFunc     = function() return DAS.GetSettings().whisperString end,
+                    setFunc     = function(value) DAS.GetSettings().whisperString = value end,
                 },
 				{   -- editbox: Quest share text
                     type    = "button",
diff --git a/DASUserSettingsAdapter.lua b/DASUserSettingsAdapter.lua
index d09b64f..e46e30b 100644
--- a/DASUserSettingsAdapter.lua
+++ b/DASUserSettingsAdapter.lua
@@ -115,6 +115,14 @@ function DAS.SetAutoAcceptInvite(value)
     end
 end

+function DAS.GetWhisperOnly()
+    return GetSettings().whisperOnly
+end
+function DAS.SetWhisperOnly(value)
+    GetSettings().whisperOnly = value
+end
+
+
 function DAS.GetGroupLeaveOnNewSearch()

 end
diff --git a/DailyAutoShare.txt b/DailyAutoShare.txt
index 4a17bb2..32eadfc 100644
--- a/DailyAutoShare.txt
+++ b/DailyAutoShare.txt
@@ -1,6 +1,6 @@
 ## Title: DailyAutoShare
 ## Author: manavortex
-## Version: 3.2.2
+## Version: 3.3.0
 ## APIVersion: 100023
 ## SavedVariables: DAS_Settings DAS_Globals
 ## OptionalDependsOn: LibStub LibCustomMenu LibAddonMenu-2.0 LibMediaProvider-1.0 pchat
diff --git a/DasChatMessage.lua b/DasChatMessage.lua
index b4f76f3..e658d4c 100644
--- a/DasChatMessage.lua
+++ b/DasChatMessage.lua
@@ -53,30 +53,31 @@ end

 local stringShare = "share"
 local stringQuest = "quest"
+local stringPlusRegex = "%+"
 function DAS.OnChatMessage(eventCode, channelType, fromName, messageText, _, fromDisplayName)

     -- ignore all chat channels that aren't set
     if nil == channelTypes[channelType] then return end

-    local isPlayerName = fromDisplayName:find(DAS.pdn)
+    local isPlayerName = fromDisplayName:find(DAS.pdn)

     -- if we aren't listening, or if we are listening and the message's from us, ignore it
     if not (channelTypes[channelType] or isPlayerName) then return end

     -- if it's a group message, react to the group message
     if (channelType == CHAT_CHANNEL_PARTY) and (messageText:find(stringShare) or messageText:find(stringQuest)) then
-       DAS.TryShareActiveDaily()
-       return
+       return DAS.TryShareActiveDaily()
     end

     --  d(zo_strformat("[OnChatMessage] <<1>>: <<2>>, isPlayerName: <<3>>", fromDisplayName, messageText, tostring(isPlayerName)))

-    local _, result = pcall(string.find, messageText, "%+")
+    local _, result = pcall(string.find, messageText, stringPlusRegex)
     if not (result or #messageText <= 3) then return end

-    if isPlayerName then
+    if result and isPlayerName then
         local groupStatus = IsUnitGrouped(unittagplayer)
-        if groupStatus and not channelTypes[channelType] then
+        -- needs to be == false, ignore channels that aren't on the list
+        if groupStatus and (channelTypes[channelType] == false) then -- NO DON'T REFACTOR MANA
             if not DAS.GetAutoLeave() then return end
             GroupLeave()
             zo_callLater(DAS.TryTriggerAutoAcceptInvite, 5000)
@@ -89,12 +90,9 @@ function DAS.OnChatMessage(eventCode, channelType, fromName, messageText, _, fro
     -- we're not auto inviting, nothing to do
     if not DAS.autoInviting then return end

-
     if #messageText == 1 and messageText == stringPlus then
         table.insert(inviteQueue, fromDisplayName)
-        if not alreadyInviting then
-            popInviteQueue()
-        end
+        if not alreadyInviting then popInviteQueue() end
         return
     end

diff --git a/DasGui.lua b/DasGui.lua
index 7c7c005..fb54248 100644
--- a/DasGui.lua
+++ b/DasGui.lua
@@ -37,7 +37,7 @@ function DAS.RefreshControl(refreshQuestCache)
 	DasList:SetHidden(    stateIsMinimised or stateIsHidden)
 	if stateIsMinimised or stateIsHidden then return end

-	DAS.RefreshLabels(refreshQuestCache)
+    DAS.RefreshLabelsWithDelay()

 end
 local function SetAlpha(control, value)
@@ -302,8 +302,12 @@ function DAS.setLabels(zoneQuests)
     return buttonIndex
 end

+function DAS.RefreshLabelsWithDelay()
+    zo_callLater(DAS.RefreshLabels, 500)
+end
+
 function DAS.RefreshLabels(forceQuestRefresh, forceSkipQuestRefresh)
-
+    forceQuestRefresh = forceQuestRefresh or DAS.questCacheNeedsRefresh
     -- p("DAS.RefreshLabels(" .. tostring(forceQuestRefresh) .. ", " .. tostring(forceSkipQuestRefresh) .. ")")
 	cacheVisibilityStatus()
 	setButtonStates()
@@ -351,7 +355,7 @@ function DAS.RefreshGui(hidden)
 	DasList:SetHidden(minmaxed)
 	DasControl:SetHidden(hidden)
 	DasHandle:SetMovable(not DAS.GetLocked())
-	DAS.RefreshLabels()
+	zo_callLater(DAS.RefreshLabels, 500)
 end

 function DAS.AnchorList()
diff --git a/DasGuiStringBuilder.lua b/DasGuiStringBuilder.lua
index b7fd756..69f813c 100644
--- a/DasGuiStringBuilder.lua
+++ b/DasGuiStringBuilder.lua
@@ -48,29 +48,63 @@ local function generateQuestSpam(questNames)
     return ret
 end

+
+local empty = ""
+local comma = ", "
+local space = " "
+local any = "+any"
+local eitherof = "either of "
+
+local function getQuestNames(activeQuestNames)
+
+    local questNames = empty
+    for _, questName in ipairs(activeQuestNames) do
+        if DAS.IsQuestActive(questName) then
+            questNames = questNames .. questName .. comma
+        end
+    end
+
+    return questNames
+
+end
+
+local varargOne, varargTwo, varargAny = "<<1>>", "<<2>>", "%+any"
+local function whisperify(qsString)
+    local beginIndex, endIndex = string.find(qsString, varargOne)
+    if endIndex then
+        qsString = qsString:sub(0, endIndex+2)
+    end
+    return qsString .. space .. varargTwo
+
+end
+
+
 local function GenerateBingoString(activeQuestNames, verbose)

 	activeQuestNames = getEnglishQuestNames(activeQuestNames)
-
+	local qsString = DAS.GetSettings().questShareString
 	local bingoCodes = {}
-	local bingo, questNames = "", ""
-    local bingoString = (DAS.fullBingoString or ""):gsub("%+any", "")
+    local bingo, questNames = empty, empty
+    local bingoString = (DAS.fullBingoString or empty):gsub(varargAny, empty)
 	if DAS.GetAutoInvite() then
-        local questCount = 0
-		for _, questName in ipairs(activeQuestNames) do
-            questCount = questCount +1
-			if DAS.IsQuestActive(questName) then
-				questNames = questNames .. questName .. ", "
-			end
-		end
-        if #DAS.fullBingoString > 0 then
-            bingo = ((#activeQuestNames > 1 and "either of ") or "") .. bingoString
-		end
-        return zo_strformat(DAS.GetSettings().questShareString, questNames, bingoString)
+        local questNames = getQuestNames(activeQuestNames)
+
+        -- if we're listening for whisper only, adjust spam accordingly
+        if DAS.GetWhisperOnly() then
+            qsString = whisperify(qsString)
+            bingoString = DAS.GetSettings().whisperString
+        else
+
+        -- if we have more than one, insert either of
+            if #bingoString > 0 then
+                bingo = ((#activeQuestNames > 1 and eitherof) or empty) .. bingoString
+            end
+        end
+        return zo_strformat(qsString, questNames, bingoString)
     end

     if NonContiguousCount(DAS.GetShareableLog()) == 0 and #activeQuestNames == 0 then
-        return "+any"
+        return any
     end
     activeQuestNames = DAS.GetOpenQuestNames()
     return generateQuestSpam(activeQuestNames)
@@ -121,7 +155,7 @@ function DAS.SettingsButton(control, mouseButton)
 		end
 	end

-	DAS.RefreshLabels()
+	-- DAS.RefreshLabels()

  end