forked from CFC-Servers/cfc_chat_transit
Remove lua from main branch
This commit is contained in:
parent
d0688171ae
commit
70df976f0a
@ -1 +0,0 @@
|
||||
return include("cfc_chat_transit/client/init.lua")
|
@ -1,6 +0,0 @@
|
||||
require("steamlookup")
|
||||
include("cfc_chat_transit/server/init.lua")
|
||||
include("cfc_chat_transit/server/remote_messages.lua")
|
||||
AddCSLuaFile("cfc_chat_transit/client/init.lua")
|
||||
AddCSLuaFile("cfc_chat_transit/client/menu.lua")
|
||||
return AddCSLuaFile("cfc_chat_transit/client/receive_remote_message.lua")
|
@ -1,2 +0,0 @@
|
||||
ChatTransit = { }
|
||||
return include("receive_remote_message.lua")
|
@ -1,31 +0,0 @@
|
||||
local alertPreference
|
||||
alertPreference = function(val)
|
||||
net.Start("CFC_ChatTransit_RemoteMessagePreference")
|
||||
net.WriteBool(val)
|
||||
return net.SendToServer()
|
||||
end
|
||||
local initHookName = "CFC_ChatTransit_AlertRemoteMessagePreference"
|
||||
hook.Add("Think", initHookName, function()
|
||||
hook.Remove("Think", initHookName)
|
||||
alertPreference(ChatTransit.shouldReceiveRemoteMessages:GetBool())
|
||||
return nil
|
||||
end)
|
||||
local populatePanel
|
||||
populatePanel = function(panel)
|
||||
local label = "Should show remote messages"
|
||||
do
|
||||
local _with_0 = panel:CheckBox(label, "cfc_chat_transit_remote_messages")
|
||||
_with_0.OnChange = function(_, val)
|
||||
return ChatTransit.alertPreference(val)
|
||||
end
|
||||
return _with_0
|
||||
end
|
||||
end
|
||||
hook.Add("AddToolMenuCategories", "CFC_ChatTransit_MenuCategory", function()
|
||||
return AddToolCategory("Options", "CFC", "CFC")
|
||||
end)
|
||||
return hook.Add("PopulateToolMenu", "CFC_ChatTransit_MenuOption", function()
|
||||
return AddToolMenuOption("Options", "CFC", "should_receive_remote_messages", "Remote Messages", "", "", function(panel)
|
||||
return populatePanel(panel)
|
||||
end)
|
||||
end)
|
@ -1,73 +0,0 @@
|
||||
local Start, Receive, ReadBool, ReadColor, ReadString, WriteBool, SendToServer
|
||||
do
|
||||
local _obj_0 = net
|
||||
Start, Receive, ReadBool, ReadColor, ReadString, WriteBool, SendToServer = _obj_0.Start, _obj_0.Receive, _obj_0.ReadBool, _obj_0.ReadColor, _obj_0.ReadString, _obj_0.WriteBool, _obj_0.SendToServer
|
||||
end
|
||||
local AddToolCategory, AddToolMenuOption
|
||||
do
|
||||
local _obj_0 = spawnmenu
|
||||
AddToolCategory, AddToolMenuOption = _obj_0.AddToolCategory, _obj_0.AddToolMenuOption
|
||||
end
|
||||
local shouldReceiveRemoteMessages = CreateConVar("cfc_chat_transit_remote_messages", 1, FCVAR_ARCHIVE, "Should receive remote messges in chat", 0, 1)
|
||||
local colors = {
|
||||
white = Color(255, 255, 255),
|
||||
blurple = Color(142, 163, 247)
|
||||
}
|
||||
Receive("CFC_ChatTransit_RemoteMessageReceive", function()
|
||||
if not (shouldReceiveRemoteMessages:GetBool()) then
|
||||
return
|
||||
end
|
||||
local author = ReadString()
|
||||
local authorColor = ReadColor()
|
||||
local message = ReadString()
|
||||
if not (author) then
|
||||
return
|
||||
end
|
||||
if not (authorColor) then
|
||||
return
|
||||
end
|
||||
if not (message) then
|
||||
return
|
||||
end
|
||||
local addTextParams = {
|
||||
colors.blurple,
|
||||
"[Discord] ",
|
||||
authorColor,
|
||||
author,
|
||||
colors.white,
|
||||
": " .. tostring(message)
|
||||
}
|
||||
hook.Run("CFC_ChatTransit_RemoteMessageReceive", addTextParams)
|
||||
return chat.AddText(unpack(addTextParams))
|
||||
end)
|
||||
local alertPreference
|
||||
alertPreference = function(val)
|
||||
Start("CFC_ChatTransit_RemoteMessagePreference")
|
||||
WriteBool(val)
|
||||
return SendToServer()
|
||||
end
|
||||
local initHookName = "CFC_ChatTransit_AlertRemoteMessagePreference"
|
||||
hook.Add("Think", initHookName, function()
|
||||
hook.Remove("Think", initHookName)
|
||||
alertPreference(shouldReceiveRemoteMessages:GetBool())
|
||||
return nil
|
||||
end)
|
||||
local populatePanel
|
||||
populatePanel = function(panel)
|
||||
local label = "Should show remote messages"
|
||||
do
|
||||
local _with_0 = panel:CheckBox(label, "cfc_chat_transit_remote_messages")
|
||||
_with_0.OnChange = function(_, val)
|
||||
return alertPreference(val)
|
||||
end
|
||||
return _with_0
|
||||
end
|
||||
end
|
||||
hook.Add("AddToolMenuCategories", "CFC_ChatTransit_MenuCategory", function()
|
||||
return AddToolCategory("Options", "CFC", "CFC")
|
||||
end)
|
||||
return hook.Add("PopulateToolMenu", "CFC_ChatTransit_MenuOption", function()
|
||||
return AddToolMenuOption("Options", "CFC", "should_receive_remote_messages", "Remote Messages", "", "", function(panel)
|
||||
return populatePanel(panel)
|
||||
end)
|
||||
end)
|
@ -1,90 +0,0 @@
|
||||
local TableToJSON
|
||||
TableToJSON = util.TableToJSON
|
||||
local HTTP = HTTP
|
||||
local avatarServiceAddress = CreateConVar("cfc_avatar_service_address", "", FCVAR_ARCHIVE + FCVAR_PROTECTED)
|
||||
local AvatarService
|
||||
do
|
||||
local _class_0
|
||||
local _base_0 = {
|
||||
getAvatar = function(self, steamID64)
|
||||
local url = steamID64 and "https://avatarservice.cfcservers.org/avatars/" .. tostring(steamID64) .. ".png" or nil
|
||||
if self.processedIds[steamID64] then
|
||||
url = url and tostring(url) .. "?processed=true"
|
||||
end
|
||||
return url
|
||||
end,
|
||||
processAvatar = function(self, avatarUrl, outlineColor, steamID64)
|
||||
local body = TableToJSON({
|
||||
avatarUrl = avatarUrl,
|
||||
outlineColor = outlineColor,
|
||||
steamID = steamID64
|
||||
})
|
||||
self.logger:debug("Sending data to outliner: ", body)
|
||||
local failed
|
||||
do
|
||||
local _base_1 = self.logger
|
||||
local _fn_0 = _base_1.error
|
||||
failed = function(...)
|
||||
return _fn_0(_base_1, ...)
|
||||
end
|
||||
end
|
||||
local success
|
||||
success = function(code, body)
|
||||
self.logger:debug("Avatar request succeeded with code: " .. tostring(code) .. " | Body: " .. tostring(body))
|
||||
self.processedIds[steamID64] = true
|
||||
end
|
||||
return HTTP({
|
||||
success = success,
|
||||
failed = failed,
|
||||
body = body,
|
||||
url = self.outlinerUrl,
|
||||
method = "POST",
|
||||
type = "application/json"
|
||||
})
|
||||
end,
|
||||
outlineAvatar = function(self, ply, data)
|
||||
self.logger:debug("Received request to outline avatar for ply: " .. tostring(ply:Nick()))
|
||||
local avatar = data.response.players[1].avatarfull
|
||||
local outlineColor = ChatTransit:GetTeamColor(ply:Team())
|
||||
local steamID64 = ply:SteamID64()
|
||||
return self:processAvatar(avatar, outlineColor, steamID64)
|
||||
end
|
||||
}
|
||||
_base_0.__index = _base_0
|
||||
_class_0 = setmetatable({
|
||||
__init = function(self, logger)
|
||||
self.logger = logger:scope("AvatarService")
|
||||
self.outlinerUrl = tostring(avatarServiceAddress:GetString()) .. "/outline"
|
||||
self.processedIds = { }
|
||||
end,
|
||||
__base = _base_0,
|
||||
__name = "AvatarService"
|
||||
}, {
|
||||
__index = _base_0,
|
||||
__call = function(cls, ...)
|
||||
local _self_0 = setmetatable({}, _base_0)
|
||||
cls.__init(_self_0, ...)
|
||||
return _self_0
|
||||
end
|
||||
})
|
||||
_base_0.__class = _class_0
|
||||
AvatarService = _class_0
|
||||
end
|
||||
hook.Add("InitPostEntity", "CFC_ChatTrahsit_AvatarServiceInit", function()
|
||||
ChatTransit.AvatarService = AvatarService(ChatTransit.Logger)
|
||||
end)
|
||||
return hook.Add("CFC_SteamLookup_SuccessfulPlayerData", "CFC_ChatTransit_AvatarService", function(dataName, ply, data)
|
||||
if not (dataName == "PlayerSummary") then
|
||||
return
|
||||
end
|
||||
if not (data) then
|
||||
return
|
||||
end
|
||||
local success, err = pcall(function()
|
||||
return ChatTransit.AvatarService:outlineAvatar(ply, data)
|
||||
end)
|
||||
if not (success) then
|
||||
ErrorNoHaltWithStack(err, dataName, ply)
|
||||
end
|
||||
return nil
|
||||
end)
|
@ -1,89 +0,0 @@
|
||||
require("gwsockets")
|
||||
require("logger")
|
||||
ChatTransit = {
|
||||
Logger = Logger("ChatTransit")
|
||||
}
|
||||
include("cfc_chat_transit/server/avatar_service.lua")
|
||||
include("cfc_chat_transit/server/player_count.lua")
|
||||
local Read
|
||||
Read = file.Read
|
||||
local GetColor
|
||||
GetColor = team.GetColor
|
||||
local TableToJSON
|
||||
TableToJSON = util.TableToJSON
|
||||
local logger = ChatTransit.Logger
|
||||
local relayHost = CreateConVar("cfc_relay_host", "", FCVAR_NONE)
|
||||
local loadHook = "ChatTransit_WebsocketLoad"
|
||||
hook.Add("Think", loadHook, function()
|
||||
hook.Remove("Think", loadHook)
|
||||
ChatTransit.WebSocket = GWSockets.createWebSocket("wss://" .. tostring(relayHost:GetString()) .. "/relay", false)
|
||||
ChatTransit.Realm = CreateConVar("cfc_realm", "unknown", FCVAR_REPLICATED + FCVAR_ARCHIVE, "The Realm Name")
|
||||
do
|
||||
local _with_0 = ChatTransit.WebSocket
|
||||
_with_0.reconnectTimerName = "CFC_ChatTransit_WebsocketReconnect"
|
||||
_with_0.onConnected = function(self)
|
||||
logger:info("Established websocket connection")
|
||||
return timer.Remove(_with_0.reconnectTimerName)
|
||||
end
|
||||
_with_0.onDisconnected = function(self)
|
||||
logger:warn("Lost websocket connection!")
|
||||
if timer.Exists(_with_0.reconnectTimerName) then
|
||||
return logger:warn("Will retry " .. tostring(timer.RepsLeft(_with_0.reconnectTimerName)) .. " more times")
|
||||
end
|
||||
return timer.Create(_with_0.reconnectTimerName, 2, 30, function()
|
||||
return _with_0:open()
|
||||
end)
|
||||
end
|
||||
_with_0.onError = function(self, message)
|
||||
return logger:error("Websocket Error!", message)
|
||||
end
|
||||
_with_0:open()
|
||||
end
|
||||
return nil
|
||||
end)
|
||||
ChatTransit.Send = function(self, data)
|
||||
logger:debug("Sending '" .. tostring(data.Type) .. "'")
|
||||
local steamID64 = data.Data.SteamId
|
||||
data.Data.Avatar = data.Data.Avatar or ChatTransit.AvatarService:getAvatar(steamID64)
|
||||
data.Realm = self.Realm:GetString()
|
||||
data.Data.SteamId = data.Data.SteamId or ""
|
||||
return self.WebSocket:write(TableToJSON(data))
|
||||
end
|
||||
ChatTransit.TeamColorCache = { }
|
||||
ChatTransit.GetTeamColor = function(self, teamName)
|
||||
if self.TeamColorCache[teamName] then
|
||||
return self.TeamColorCache[teamName]
|
||||
end
|
||||
local teamColor = tostring(GetColor(teamName))
|
||||
self.TeamColorCache[teamName] = teamColor
|
||||
return teamColor
|
||||
end
|
||||
ChatTransit.guard = function(f, delay)
|
||||
return function(...)
|
||||
local args = {
|
||||
...
|
||||
}
|
||||
local action
|
||||
action = function()
|
||||
local success, err = pcall(function()
|
||||
return f(unpack(args))
|
||||
end)
|
||||
if not (success) then
|
||||
return ErrorNoHaltWithStack(err)
|
||||
end
|
||||
end
|
||||
if delay then
|
||||
timer.Simple(delay, action)
|
||||
else
|
||||
action()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
logger:info("Loading modules...")
|
||||
local _list_0 = file.Find("cfc_chat_transit/server/modules/*.lua", "LUA")
|
||||
for _index_0 = 1, #_list_0 do
|
||||
local f = _list_0[_index_0]
|
||||
logger:info("Loading modules/" .. tostring(f))
|
||||
include("modules/" .. tostring(f))
|
||||
end
|
@ -1,37 +0,0 @@
|
||||
local guard
|
||||
guard = ChatTransit.guard
|
||||
local isstring
|
||||
isstring = _G.isstring
|
||||
ChatTransit.AnticrashEvent = function(self, eventText)
|
||||
if not (isstring(eventText)) then
|
||||
eventText = "Heavy lag detected!"
|
||||
end
|
||||
return self:Send({
|
||||
Type = "anticrash_event",
|
||||
Data = {
|
||||
Content = eventText,
|
||||
SteamName = "CFC Anticrash"
|
||||
}
|
||||
})
|
||||
end
|
||||
hook.Add("z_anticrash_LagDetect", "CFC_ChatTransit_AnticrashEventListener", guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.AnticrashEvent
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)()))
|
||||
hook.Add("z_anticrash_LagStuck", "CFC_ChatTransit_AnticrashEventListener", guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.AnticrashEvent
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)()))
|
||||
return hook.Add("z_anticrash_CrashPrevented", "CFC_ChatTransit_AnticrashEventListener", guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.AnticrashEvent
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)()))
|
@ -1,34 +0,0 @@
|
||||
local guard
|
||||
guard = ChatTransit.guard
|
||||
ChatTransit.ReceiveMessage = function(self, ply, text, teamChat)
|
||||
local shouldRelay = hook.Run("CFC_ChatTransit_ShouldRelayChatMessage", ply, text, teamChat)
|
||||
if shouldRelay == false then
|
||||
return
|
||||
end
|
||||
if teamChat then
|
||||
return
|
||||
end
|
||||
if not (text) then
|
||||
return
|
||||
end
|
||||
if text == "" then
|
||||
return
|
||||
end
|
||||
return self:Send({
|
||||
Type = "message",
|
||||
Data = {
|
||||
Type = "message",
|
||||
Content = text,
|
||||
SteamName = ply:Nick(),
|
||||
SteamId = ply:SteamID64(),
|
||||
IrisId = "none"
|
||||
}
|
||||
})
|
||||
end
|
||||
return hook.Add("PlayerSay", "CFC_ChatTransit_MessageListener", guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.ReceiveMessage
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)()), HOOK_MONITOR_LOW)
|
@ -1,48 +0,0 @@
|
||||
local delay, guard
|
||||
do
|
||||
local _obj_0 = ChatTransit
|
||||
delay, guard = _obj_0.delay, _obj_0.guard
|
||||
end
|
||||
local SteamIDTo64
|
||||
SteamIDTo64 = util.SteamIDTo64
|
||||
ChatTransit.PlayerConnect = function(self, data)
|
||||
local bot, name, steamId
|
||||
bot, name, steamId = data.bot, data.name, data.networkid
|
||||
bot = tobool(bot)
|
||||
if bot then
|
||||
steamId = nil
|
||||
end
|
||||
return self:Send({
|
||||
Type = "connect",
|
||||
Data = {
|
||||
SteamName = name,
|
||||
SteamId = steamId and SteamIDTo64(steamId),
|
||||
PlayerCountCurrent = ChatTransit.playerCount,
|
||||
PlayerCountMax = game:MaxPlayers()
|
||||
}
|
||||
})
|
||||
end
|
||||
ChatTransit.PlayerInitialSpawn = function(self, ply)
|
||||
return self:Send({
|
||||
Type = "spawn",
|
||||
Data = {
|
||||
SteamName = ply:Nick(),
|
||||
SteamId = ply:SteamID64()
|
||||
}
|
||||
})
|
||||
end
|
||||
gameevent.Listen("player_connect")
|
||||
hook.Add("player_connect", "CFC_ChatTransit_SpawnListener", guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.PlayerConnect
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)(), 0))
|
||||
return hook.Add("PlayerInitialSpawn", "CFC_ChatTransit_SpawnListener", guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.PlayerInitialSpawn
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)()))
|
@ -1,32 +0,0 @@
|
||||
local delay, guard
|
||||
do
|
||||
local _obj_0 = ChatTransit
|
||||
delay, guard = _obj_0.delay, _obj_0.guard
|
||||
end
|
||||
local GetBySteamID
|
||||
GetBySteamID = player.GetBySteamID
|
||||
local SteamIDTo64
|
||||
SteamIDTo64 = util.SteamIDTo64
|
||||
ChatTransit.PlayerDisconnected = function(self, data)
|
||||
local name, reason, steamId
|
||||
name, reason, steamId = data.name, data.reason, data.networkid
|
||||
local ply = GetBySteamID(steamId)
|
||||
return self:Send({
|
||||
Type = "disconnect",
|
||||
Data = {
|
||||
SteamName = ply and ply:Nick() or name,
|
||||
SteamId = ply and ply:SteamID64() or SteamIDTo64(steamId),
|
||||
PlayerCountCurrent = ChatTransit.playerCount,
|
||||
PlayerCountMax = game:MaxPlayers(),
|
||||
Content = reason
|
||||
}
|
||||
})
|
||||
end
|
||||
gameevent.Listen("player_disconnect")
|
||||
return hook.Add("player_disconnect", "CFC_ChatTransit_DisconnectListener", guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.PlayerDisconnected
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)(), 0))
|
@ -1,17 +0,0 @@
|
||||
local guard
|
||||
guard = ChatTransit.guard
|
||||
ChatTransit.PvPEvent = function(self, ply, newMode)
|
||||
local eventText = tostring(ply:Nick()) .. " has entered " .. tostring(newMode) .. " mode"
|
||||
return self:Send({
|
||||
Type = "pvp_status_change",
|
||||
Data = {
|
||||
Content = eventText
|
||||
}
|
||||
})
|
||||
end
|
||||
hook.Add("CFC_PvP_PlayerEnterPvp", "CFC_ChatTransit_Relay", guard(function(ply)
|
||||
return ChatTransit:PvPEvent(ply, "PvP")
|
||||
end))
|
||||
return hook.Add("CFC_PvP_PlayerExitPvp", "CFC_ChatTransit_Relay", guard(function(ply)
|
||||
return ChatTransit:PvPEvent(ply, "Build")
|
||||
end))
|
@ -1,26 +0,0 @@
|
||||
local guard
|
||||
guard = ChatTransit.guard
|
||||
local GetMap
|
||||
GetMap = game.GetMap
|
||||
ChatTransit.MapStartup = function(self, data)
|
||||
local eventText = ""
|
||||
local map = GetMap()
|
||||
if SysTime() > 500 then
|
||||
eventText = "Map switched to " .. map
|
||||
else
|
||||
eventText = "Server restarted! Current map is " .. map
|
||||
end
|
||||
return self:Send({
|
||||
Type = "map_init",
|
||||
Data = {
|
||||
Content = eventText
|
||||
}
|
||||
})
|
||||
end
|
||||
return hook.Add("InitPostEntity", "CFC_ChatTransit_StartListener", timer.Simple(1, guard((function()
|
||||
local _base_0 = ChatTransit
|
||||
local _fn_0 = _base_0.MapStartup
|
||||
return function(...)
|
||||
return _fn_0(_base_0, ...)
|
||||
end
|
||||
end)())))
|
@ -1,40 +0,0 @@
|
||||
_Msg = Msg
|
||||
local guard
|
||||
guard = ChatTransit.guard
|
||||
local isstring
|
||||
isstring = _G.isstring
|
||||
local Replace
|
||||
Replace = string.Replace
|
||||
ChatTransit.ReceiveULXAction = function(self, msg)
|
||||
msg = Replace(msg, "\n", "")
|
||||
self.Logger:debug("Received global ULX message", msg)
|
||||
return self:Send({
|
||||
Type = "ulx_action",
|
||||
Data = {
|
||||
Type = "ulx_action",
|
||||
Content = msg
|
||||
}
|
||||
})
|
||||
end
|
||||
local M
|
||||
M = function(...)
|
||||
_Msg(...)
|
||||
return ChatTransit:ReceiveULXAction(...)
|
||||
end
|
||||
return hook.Add("InitPostEntity", "ChatTransit_WrapUlxLog", guard(function()
|
||||
if not (ulx) then
|
||||
return
|
||||
end
|
||||
ulx._ChatTransit_fancyLogAdmin = ulx._ChatTransit_fancyLogAdmin or ulx.fancyLogAdmin
|
||||
ulx.fancyLogAdmin = function(...)
|
||||
local args = {
|
||||
...
|
||||
}
|
||||
if not (isstring(args[2])) then
|
||||
return ulx._ChatTransit_fancyLogAdmin(...)
|
||||
end
|
||||
Msg = M
|
||||
ulx._ChatTransit_fancyLogAdmin(...)
|
||||
Msg = _Msg
|
||||
end
|
||||
end))
|
@ -1,42 +0,0 @@
|
||||
local IsValid
|
||||
IsValid = _G.IsValid
|
||||
local guard
|
||||
guard = ChatTransit.guard
|
||||
local proxVoice
|
||||
local proxVoiceEnabled
|
||||
proxVoiceEnabled = function()
|
||||
proxVoice = proxVoice or GetConVar("force_proximity_voice")
|
||||
if not (proxVoice) then
|
||||
return false
|
||||
end
|
||||
return proxVoice:GetBool()
|
||||
end
|
||||
ChatTransit.ReceiveVoiceTranscript = function(self, steamID64, data)
|
||||
if proxVoiceEnabled() then
|
||||
return
|
||||
end
|
||||
local ply = player.GetBySteamID64(steamID64)
|
||||
if not (IsValid(ply)) then
|
||||
return
|
||||
end
|
||||
if ply.ulx_gagged then
|
||||
return
|
||||
end
|
||||
if ply:GetInfoNum("proximity_voice_enabled", 0) ~= 0 then
|
||||
return
|
||||
end
|
||||
local shouldRelay = hook.Run("CFC_ChatTransit_ShouldRelayTranscript", ply, transcript)
|
||||
if shouldRelay == false then
|
||||
return
|
||||
end
|
||||
return self:Send({
|
||||
Type = "voice_transcript",
|
||||
Data = {
|
||||
Type = "voice_transcript",
|
||||
Content = data,
|
||||
SteamName = ply:Nick(),
|
||||
SteamId = ply:SteamID64(),
|
||||
IrisId = "none"
|
||||
}
|
||||
})
|
||||
end
|
@ -1,19 +0,0 @@
|
||||
ChatTransit.playerCount = 0
|
||||
local increment
|
||||
increment = function()
|
||||
ChatTransit.playerCount = ChatTransit.playerCount + 1
|
||||
end
|
||||
local decrement
|
||||
decrement = function()
|
||||
ChatTransit.playerCount = ChatTransit.playerCount - 1
|
||||
end
|
||||
hook.Add("ClientSignOnStateChanged", "ChatTransit_PlayerCount", function(_, oldstate)
|
||||
if not (oldstate == 7) then
|
||||
return
|
||||
end
|
||||
return increment()
|
||||
end)
|
||||
gameevent.Listen("player_connect")
|
||||
hook.Add("player_connect", "ChatTransit_PlayerCount", increment)
|
||||
gameevent.Listen("player_disconnect")
|
||||
return hook.Add("player_disconnect", "ChatTransit_PlayerCount", decrement)
|
@ -1,58 +0,0 @@
|
||||
local IsValid
|
||||
IsValid = _G.IsValid
|
||||
local AddNetworkString
|
||||
AddNetworkString = util.AddNetworkString
|
||||
local Start, Receive, ReadBool, WriteColor, WriteString, Send
|
||||
do
|
||||
local _obj_0 = net
|
||||
Start, Receive, ReadBool, WriteColor, WriteString, Send = _obj_0.Start, _obj_0.Receive, _obj_0.ReadBool, _obj_0.WriteColor, _obj_0.WriteString, _obj_0.Send
|
||||
end
|
||||
local ToColor
|
||||
ToColor = string.ToColor
|
||||
AddNetworkString("CFC_ChatTransit_RemoteMessagePreference")
|
||||
AddNetworkString("CFC_ChatTransit_RemoteMessageReceive")
|
||||
local recipients = RecipientFilter()
|
||||
local adminRecipients = RecipientFilter()
|
||||
local shouldTransmit = CreateConVar("cfc_chat_transit_should_transmit_remote", 1, FCVAR_ARCHIVE, "Should transmit remote messages", 0, 1)
|
||||
local adminOnly = CreateConVar("cfc_chat_transit_transmit_admin_only", 1, FCVAR_ARCHIVE, "Should only transmit to Admins?", 0, 1)
|
||||
Receive("CFC_ChatTransit_RemoteMessagePreference", function(_, ply)
|
||||
local shouldReceive = ReadBool()
|
||||
if shouldReceive then
|
||||
recipients:AddPlayer(ply)
|
||||
if adminOnly:GetBool() and ply:IsAdmin() then
|
||||
adminRecipients:AddPlayer(ply)
|
||||
end
|
||||
return
|
||||
end
|
||||
recipients:RemovePlayer(ply)
|
||||
return adminRecipients:RemovePlayer(ply)
|
||||
end)
|
||||
local broadcastMessage
|
||||
broadcastMessage = function(ply, cmd, args, argStr)
|
||||
if not (shouldTransmit:GetBool()) then
|
||||
return
|
||||
end
|
||||
if IsValid(ply) then
|
||||
return
|
||||
end
|
||||
local author = rawget(args, 1)
|
||||
local authorColor = rawget(args, 2)
|
||||
local message = rawget(args, 3)
|
||||
if not (author) then
|
||||
return
|
||||
end
|
||||
if not (authorColor) then
|
||||
return
|
||||
end
|
||||
if not (message) then
|
||||
return
|
||||
end
|
||||
authorColor = ToColor(authorColor)
|
||||
local sendingTo = adminOnly:GetBool() and adminRecipients or recipients
|
||||
Start("CFC_ChatTransit_RemoteMessageReceive")
|
||||
WriteString(author)
|
||||
WriteColor(authorColor)
|
||||
WriteString(message)
|
||||
return Send(sendingTo)
|
||||
end
|
||||
return concommand.Add("chat_transit", broadcastMessage)
|
Loading…
Reference in New Issue
Block a user