Code format

This commit is contained in:
2025-01-09 10:55:32 +01:00
parent 2e44a1ef31
commit be81a31302
15 changed files with 274 additions and 231 deletions

View File

@@ -11,17 +11,6 @@ function shared.Messenger.Init()
---@field channel string
---@field data string
local function GetChannelId(channelName)
local channels = { GetChannelList() }
for i = 1, #channels, 2 do
local id = channels[i]
local name = channels[i + 1]
if name == channelName then
return id
end
end
end
local function FindOrJoinChannel(channelName, password)
local channelId = GetChannelName(channelName)
if channelId == 0 then
@@ -49,36 +38,37 @@ function shared.Messenger.Init()
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Processing message queue", ModuleName))
end
if not Heimdall_Data.config.messenger.enabled then
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
return
end
---@type Message
local message = shared.messenger.queue[1]
if not message then
if not message then
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Message queue empty", ModuleName))
end
return
return
end
if not message.message or message.message == "" then
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
return
end
if not message.channel or message.channel == "" then
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
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] Processing channel message: '%s' to '%s'", ModuleName, message.message, 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
@@ -94,27 +84,28 @@ function shared.Messenger.Init()
end
table.remove(shared.messenger.queue, 1)
if not message.message or message.message == "" then
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
return
end
if not message.channel or message.channel == "" then
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
return
end
if not message.data or message.data == "" then
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
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))
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
@@ -130,7 +121,8 @@ function shared.Messenger.Init()
end
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Module initialized with interval: %s", ModuleName, Heimdall_Data.config.messenger.interval))
print(string.format("[%s] Module initialized with interval: %s", ModuleName,
Heimdall_Data.config.messenger.interval))
end
print("[Heimdall] Messenger loaded")
end