Refactor queueing messages
This commit is contained in:
		@@ -39,14 +39,28 @@ Message = {
 | 
				
			|||||||
	end,
 | 
						end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	---@param stinky Stinky
 | 
						---@param stinky Stinky
 | 
				
			||||||
	---@return nil
 | 
						QueueNotifyGuild = function(stinky)
 | 
				
			||||||
	QueueNotifyAddonGuild = function(stinky)
 | 
							if not stinkyNotifyGuild then return end
 | 
				
			||||||
		if not stinkyNotifyAddonGuild then return end
 | 
							local message = Message.new(stinky:FormMessage(), nil, "GUILD")
 | 
				
			||||||
		local message = Message.new(stinky:FormAddonMessage(), stinky.name, "GUILD", true)
 | 
							table.insert(aura_env.messageQueue, message)
 | 
				
			||||||
 | 
						end,
 | 
				
			||||||
 | 
						---@param stinky Stinky
 | 
				
			||||||
 | 
						QueueNotifyWhisper = function(stinky)
 | 
				
			||||||
 | 
							if not stinkyNotifyWhisper then return end
 | 
				
			||||||
 | 
							local text = stinky:FormMessage()
 | 
				
			||||||
 | 
							for _, to in ipairs(toNotify) do
 | 
				
			||||||
 | 
								local message = Message.new(text, to, "WHISPER")
 | 
				
			||||||
 | 
								table.insert(aura_env.messageQueue, message)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						---@param stinky Stinky
 | 
				
			||||||
 | 
						QueueNotifyAddonGuild = function(stinky)
 | 
				
			||||||
 | 
							if not stinkyNotifyAddonGuild then return end
 | 
				
			||||||
 | 
							local message = Message.new(stinky:FormAddonMessage(), nil, "GUILD", true)
 | 
				
			||||||
		table.insert(aura_env.messageQueue, message)
 | 
							table.insert(aura_env.messageQueue, message)
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
	---@param stinky Stinky
 | 
						---@param stinky Stinky
 | 
				
			||||||
	---@return nil
 | 
					 | 
				
			||||||
	QueueNotifyAddonWhisper = function(stinky)
 | 
						QueueNotifyAddonWhisper = function(stinky)
 | 
				
			||||||
		if not stinkyNotifyAddonWhisper then return end
 | 
							if not stinkyNotifyAddonWhisper then return end
 | 
				
			||||||
		local text = stinky:FormMessage()
 | 
							local text = stinky:FormMessage()
 | 
				
			||||||
@@ -56,23 +70,51 @@ Message = {
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	---@param stinky Stinky
 | 
						---@param faction string
 | 
				
			||||||
	---@return nil
 | 
						---@param source string
 | 
				
			||||||
	QueueNotifyGuild = function(stinky)
 | 
						---@param destination string
 | 
				
			||||||
		if not stinkyNotifyGuild then return end
 | 
						---@param spellName string
 | 
				
			||||||
		local message = Message.new(stinky:FormMessage(), stinky.name, "GUILD")
 | 
						QueueNotifyKilledAddonGuild = function(faction, source, destination, spellName)
 | 
				
			||||||
 | 
							if not killNotifyAddonGuild then return end
 | 
				
			||||||
 | 
							local text = string.format("%s|%s|%s|%s", faction, source, destination, spellName)
 | 
				
			||||||
 | 
							local message = Message.new(text, nil, "GUILD", true)
 | 
				
			||||||
		table.insert(aura_env.messageQueue, message)
 | 
							table.insert(aura_env.messageQueue, message)
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
	---@param stinky Stinky
 | 
						---@param faction string
 | 
				
			||||||
	---@return nil
 | 
						---@param source string
 | 
				
			||||||
	QueueNotifyWhisper = function(stinky)
 | 
						---@param destination string
 | 
				
			||||||
		if not stinkyNotifyWhisper then return end
 | 
						---@param spellName string
 | 
				
			||||||
		local text = stinky:FormMessage()
 | 
						QueueNotifyKilledAddonWhisper = function(faction, source, destination, spellName)
 | 
				
			||||||
 | 
							if not killNotifyAddonWhisper then return end
 | 
				
			||||||
 | 
							local text = string.format("%s|%s|%s|%s", faction, source, destination, spellName)
 | 
				
			||||||
		for _, to in ipairs(toNotify) do
 | 
							for _, to in ipairs(toNotify) do
 | 
				
			||||||
			local message = Message.new(text, to, "WHISPER")
 | 
								local message = Message.new(text, to, "WHISPER", true)
 | 
				
			||||||
			table.insert(aura_env.messageQueue, message)
 | 
								table.insert(aura_env.messageQueue, message)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						---@param faction string
 | 
				
			||||||
 | 
						---@param source string
 | 
				
			||||||
 | 
						---@param destination string
 | 
				
			||||||
 | 
						---@param spellName string
 | 
				
			||||||
 | 
						QueueNotifyKilledGuild = function(faction, source, destination, spellName)
 | 
				
			||||||
 | 
							if not killNotifyGuild then return end
 | 
				
			||||||
 | 
							local text = string.format("%s %s убил %s с помощью %s", faction, source, destination, spellName)
 | 
				
			||||||
 | 
							local message = Message.new(text, nil, "GUILD", true)
 | 
				
			||||||
 | 
							table.insert(aura_env.messageQueue, message)
 | 
				
			||||||
 | 
						end,
 | 
				
			||||||
 | 
						---@param faction string
 | 
				
			||||||
 | 
						---@param source string
 | 
				
			||||||
 | 
						---@param destination string
 | 
				
			||||||
 | 
						---@param spellName string
 | 
				
			||||||
 | 
						QueueNotifyKilledWhisper = function(faction, source, destination, spellName)
 | 
				
			||||||
 | 
							if not killNotifyWhisper then return end
 | 
				
			||||||
 | 
							local text = string.format("%s %s убил %s с помощью %s", faction, source, destination, spellName)
 | 
				
			||||||
 | 
							for _, to in ipairs(toNotify) do
 | 
				
			||||||
 | 
								local message = Message.new(text, to, "WHISPER", true)
 | 
				
			||||||
 | 
								table.insert(aura_env.messageQueue, message)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
---@class Stinky
 | 
					---@class Stinky
 | 
				
			||||||
@@ -178,15 +220,11 @@ aura_env.RegisterKill = function(source, destination, spellName, overkill)
 | 
				
			|||||||
		faction = WeakAurasSaved.Cyka.PlayerFactionCache[source]
 | 
							faction = WeakAurasSaved.Cyka.PlayerFactionCache[source]
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local msg = string.format("%s %s убил %s с помощью %s с переполнением %d",
 | 
						Message.QueueNotifyKilledGuild(faction, source, destination, spellName)
 | 
				
			||||||
		faction, source, destination, spellName, overkill)
 | 
						Message.QueueNotifyKilledWhisper(faction, source, destination, spellName)
 | 
				
			||||||
 | 
						Message.QueueNotifyKilledAddonGuild(faction, source, destination, spellName)
 | 
				
			||||||
 | 
						Message.QueueNotifyKilledAddonWhisper(faction, source, destination, spellName)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if killNotifyWhisper then
 | 
					 | 
				
			||||||
		for k, v in pairs(toNotify) do
 | 
					 | 
				
			||||||
			table.insert(aura_env.messageQueue, Message.new(msg, v, "WHISPER"))
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	table.insert(aura_env.messageQueue, Message.new(msg, source, "GUILD"))
 | 
					 | 
				
			||||||
	recentlyKilled[source] = GetTime()
 | 
						recentlyKilled[source] = GetTime()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user