Fix up the log messages a lil
Unbutcher inviter
This commit is contained in:
@@ -26,7 +26,7 @@ function shared.Messenger.Init()
|
||||
local channelId = GetChannelName(channelName)
|
||||
if channelId == 0 then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel %s not found, joining", ModuleName, channelName))
|
||||
print(string.format("[%s] Channel not found, joining: %s", ModuleName, channelName))
|
||||
end
|
||||
if password then
|
||||
JoinPermanentChannel(channelName, password)
|
||||
@@ -36,7 +36,7 @@ function shared.Messenger.Init()
|
||||
end
|
||||
channelId = GetChannelName(channelName)
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel %s found, id = %s", ModuleName, channelName, channelId))
|
||||
print(string.format("[%s] Channel found with ID: %s (%s)", ModuleName, channelId, channelName))
|
||||
end
|
||||
return channelId
|
||||
end
|
||||
@@ -47,43 +47,81 @@ function shared.Messenger.Init()
|
||||
if not shared.messenger.ticker then
|
||||
local function DoMessage()
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: DoMessage", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.messenger)
|
||||
print(string.format("[%s] Processing message queue", ModuleName))
|
||||
end
|
||||
if not Heimdall_Data.config.messenger.enabled then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Module disabled, skipping message processing", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
if not Heimdall_Data.config.messenger.enabled then return end
|
||||
---@type Message
|
||||
local message = shared.messenger.queue[1]
|
||||
if not message then return end
|
||||
if not message.message or message.message == "" then return end
|
||||
if not message.channel or message.channel == "" then return end
|
||||
if not message then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Message queue empty", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
if not message.message or message.message == "" then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Invalid message: empty content", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
if not message.channel or message.channel == "" then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Invalid message: no channel specified", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel presented as string: %s", ModuleName, message.data))
|
||||
print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message, message.data))
|
||||
end
|
||||
local channelId = GetChannelName(message.data)
|
||||
if channelId == 0 then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel not found, joining %s", ModuleName, message.data))
|
||||
print(string.format("[%s] Channel not found, attempting to join: %s", ModuleName, message.data))
|
||||
end
|
||||
channelId = FindOrJoinChannel(message.data)
|
||||
end
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel resolved to id %s", ModuleName, channelId))
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Channel join result - ID: %s", ModuleName, channelId))
|
||||
end
|
||||
end
|
||||
message.data = tostring(channelId)
|
||||
end
|
||||
|
||||
table.remove(shared.messenger.queue, 1)
|
||||
if not message.message or message.message == "" then return end
|
||||
if not message.channel or message.channel == "" then return end
|
||||
if not message.data or message.data == "" then return end
|
||||
if not message.message or message.message == "" then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Skipping empty message", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
if not message.channel or message.channel == "" then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Skipping message with no channel", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
if not message.data or message.data == "" then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Skipping message with no data", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Sending message: '%s' to %s:%s", ModuleName, message.message, message.channel, message.data))
|
||||
end
|
||||
SendChatMessage(message.message, message.channel, nil, message.data)
|
||||
end
|
||||
local function Tick()
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Tick", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.messenger)
|
||||
local queueSize = #shared.messenger.queue
|
||||
print(string.format("[%s] Queue check - Messages pending: %d", ModuleName, queueSize))
|
||||
end
|
||||
DoMessage()
|
||||
shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1)
|
||||
@@ -91,14 +129,8 @@ function shared.Messenger.Init()
|
||||
Tick()
|
||||
end
|
||||
|
||||
--C_Timer.NewTicker(2, function()
|
||||
-- print("Q")
|
||||
-- table.insert(data.messenger.queue, {
|
||||
-- channel = "CHANNEL",
|
||||
-- data = "Foobar",
|
||||
-- message = "TEST"
|
||||
-- })
|
||||
--end)
|
||||
|
||||
print("Heimdall - Messenger loaded")
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("[%s] Module initialized with interval: %s", ModuleName, Heimdall_Data.config.messenger.interval))
|
||||
end
|
||||
print("[Heimdall] Messenger loaded")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user