Update whosniffer to use named channels
This commit is contained in:
@@ -4,7 +4,11 @@
|
|||||||
---@type sender string
|
---@type sender string
|
||||||
function(event, msg, sender, ...)
|
function(event, msg, sender, ...)
|
||||||
local channelId = select(6, ...)
|
local channelId = select(6, ...)
|
||||||
if channelId ~= aura_env.channelId then
|
local channelName = aura_env.GetChannelName(channelId)
|
||||||
|
if not channelName then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if channelName ~= aura_env.config.channel then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -13,7 +17,7 @@ function(event, msg, sender, ...)
|
|||||||
local msg = aura_env.MakeNotifyMessage(player)
|
local msg = aura_env.MakeNotifyMessage(player)
|
||||||
local message = {
|
local message = {
|
||||||
channel = "CHANNEL",
|
channel = "CHANNEL",
|
||||||
data = channelId,
|
data = aura_env.config.channel,
|
||||||
message = msg
|
message = msg
|
||||||
}
|
}
|
||||||
table.insert(WeakAurasSaved.Cyka.MessageQueue, message)
|
table.insert(WeakAurasSaved.Cyka.MessageQueue, message)
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -6,7 +6,6 @@ if not WeakAurasSaved.Cyka.WhoSniffer then
|
|||||||
end
|
end
|
||||||
|
|
||||||
aura_env.ignored = {"Maritza", "Goodbones"}
|
aura_env.ignored = {"Maritza", "Goodbones"}
|
||||||
local channelId = nil
|
|
||||||
|
|
||||||
---@class aura_env
|
---@class aura_env
|
||||||
---@field raceMap table<string, string>
|
---@field raceMap table<string, string>
|
||||||
@@ -262,13 +261,9 @@ local NotifyAll = function(msg)
|
|||||||
end
|
end
|
||||||
---@param msg string
|
---@param msg string
|
||||||
local NotifyChannel = function(msg)
|
local NotifyChannel = function(msg)
|
||||||
if not channelId then
|
|
||||||
print("cannot notify channel, channelId is nil")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local message = {
|
local message = {
|
||||||
channel = "CHANNEL",
|
channel = "CHANNEL",
|
||||||
data = channelId,
|
data = aura_env.channel,
|
||||||
message = msg
|
message = msg
|
||||||
}
|
}
|
||||||
table.insert(WeakAurasSaved.Cyka.MessageQueue, message)
|
table.insert(WeakAurasSaved.Cyka.MessageQueue, message)
|
||||||
@@ -310,37 +305,6 @@ aura_env.NotifyGone = function(player)
|
|||||||
aura_env.NotifyChannelGone(player)
|
aura_env.NotifyChannelGone(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- CHANNEL fuckery
|
|
||||||
local channel = aura_env.config.channel or "foobar"
|
|
||||||
local password = aura_env.config.channelPassword
|
|
||||||
|
|
||||||
local function FindOrJoinChannel(channelName, password)
|
|
||||||
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
|
|
||||||
|
|
||||||
channelId = GetChannelId(channelName)
|
|
||||||
if not channelId then
|
|
||||||
print(string.format("channel %s not found, joining", channelName))
|
|
||||||
if password then
|
|
||||||
JoinPermanentChannel(channelName, password)
|
|
||||||
else
|
|
||||||
JoinPermanentChannel(channelName)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
channelId = GetChannelId(channelName)
|
|
||||||
return channelId
|
|
||||||
end
|
|
||||||
aura_env.channelId = FindOrJoinChannel(channel, password)
|
|
||||||
print(string.format("channel %s resolved to id %d", channel, channelId))
|
|
||||||
|
|
||||||
---@param player Player
|
---@param player Player
|
||||||
---@return nil
|
---@return nil
|
||||||
aura_env.NotifyChannel = function(player)
|
aura_env.NotifyChannel = function(player)
|
||||||
@@ -355,3 +319,15 @@ aura_env.NotifyChannelGone = function(player)
|
|||||||
player.zone)
|
player.zone)
|
||||||
NotifyChannel(msg)
|
NotifyChannel(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
aura_env.GetChannelName= function(channelId)
|
||||||
|
local channels = {GetChannelList()}
|
||||||
|
for i = 1, #channels, 2 do
|
||||||
|
local id = channels[i]
|
||||||
|
local name = channels[i + 1]
|
||||||
|
if id == channelId then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
Reference in New Issue
Block a user