mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-16 05:07:34 +00:00
sync chat + websocket
This commit is contained in:
parent
5f76915d7c
commit
fc5117b63e
|
@ -5,7 +5,7 @@ if game.SinglePlayer() then return end
|
||||||
//
|
//
|
||||||
|
|
||||||
gmInte = {}
|
gmInte = {}
|
||||||
gmInte.version = "0.2.0"
|
gmInte.version = "0.2.1"
|
||||||
gmInte.config = {
|
gmInte.config = {
|
||||||
["redownloadMaterials"] = false,
|
["redownloadMaterials"] = false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
// WebSocket
|
// WebSocket
|
||||||
//
|
//
|
||||||
|
|
||||||
if (!gmInte.config.websocket) then return end
|
// TODO made a proper system to detect if the server need to be connected to the websocket
|
||||||
|
if (!gmInte.config.syncChat && !gmInte.config.websocket) then
|
||||||
require("gwsockets")
|
gmInte.log("WebSocket is disabled", true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if (!GWSockets) then return gmInte.logError("GWSockets is not installed! Please install it from https://github.com/FredyH/GWSockets") end
|
if (!GWSockets) then return gmInte.logError("GWSockets is not installed! Please install it from https://github.com/FredyH/GWSockets") end
|
||||||
|
|
||||||
|
require("gwsockets")
|
||||||
|
|
||||||
local socket = GWSockets.createWebSocket("wss://ws.gmod-integration.com")
|
local socket = GWSockets.createWebSocket("wss://ws.gmod-integration.com")
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
|
@ -47,7 +51,7 @@ function gmInte.websocketWrite(data)
|
||||||
socket:write(util.TableToJSON(data || {}))
|
socket:write(util.TableToJSON(data || {}))
|
||||||
end
|
end
|
||||||
|
|
||||||
timer.Create("gmInte:WebSocket:CheckConnection", 60, 0, function()
|
timer.Create("gmInte:WebSocket:CheckConnection", 4, 0, function()
|
||||||
if (!socket:isConnected()) then
|
if (!socket:isConnected()) then
|
||||||
socket:open()
|
socket:open()
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,13 +67,11 @@ end
|
||||||
|
|
||||||
function gmInte.playerSay(ply, text, team)
|
function gmInte.playerSay(ply, text, team)
|
||||||
if (!gmInte.config.syncChat) then return end
|
if (!gmInte.config.syncChat) then return end
|
||||||
local triggerInfo = getTriggerInfo(text)
|
|
||||||
if (!triggerInfo && !gmInte.config.chatTriggerAll) then return end
|
|
||||||
|
|
||||||
gmInte.post("/server/user/say",
|
gmInte.post("/server/user/say",
|
||||||
{
|
{
|
||||||
["steamID64"] = ply:SteamID64(),
|
["steamID64"] = ply:SteamID64(),
|
||||||
["message"] = string.sub(text, string.len(triggerInfo.trigger) + 1),
|
["message"] = text,
|
||||||
["name"] = ply:Nick(),
|
["name"] = ply:Nick(),
|
||||||
["usergroup"] = ply:GetUserGroup(),
|
["usergroup"] = ply:GetUserGroup(),
|
||||||
["message_info"] = triggerInfo
|
["message_info"] = triggerInfo
|
||||||
|
|
|
@ -34,33 +34,6 @@ gmInte.config.token = "" // Server Token
|
||||||
*/
|
*/
|
||||||
gmInte.config.websocket = false // If true, the addon will use the websocket instead of the http requests
|
gmInte.config.websocket = false // If true, the addon will use the websocket instead of the http requests
|
||||||
|
|
||||||
// Chat
|
|
||||||
gmInte.config.chatTriggerAll = false // If true, the addon will sync all the messages in the chat
|
|
||||||
gmInte.config.chatTrigger = {
|
|
||||||
/* Example:
|
|
||||||
["/example "] = {
|
|
||||||
["prefix"] = "[Example] ", // The prefix of the message
|
|
||||||
["show_rank"] = false, // If true, the addon will show the rank of the player in the prefix
|
|
||||||
["anonymous"] = false, // If true, the addon will not show the name and the avatar of the player in the message
|
|
||||||
["channel"] = "admin_sync_chat" // If set, the addon will use a custom channel to sync the message (use in multi chat syncronization)
|
|
||||||
},
|
|
||||||
["/admin_chat "] = {
|
|
||||||
["prefix"] = "[Admin Chat]",
|
|
||||||
["show_rank"] = true,
|
|
||||||
["channel"] = "discord_channel_id_admin_chat"
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
["// "] = {
|
|
||||||
["prefix"] = "",
|
|
||||||
["show_rank"] = false,
|
|
||||||
["anonymous"] = false,
|
|
||||||
["custom_id"] = "admin_sync_chat"
|
|
||||||
},
|
|
||||||
["/ano "] = {
|
|
||||||
["anonymous"] = true,
|
|
||||||
},
|
|
||||||
} // Trigger to sync the messages in a discord channel (the key is the trigger and the value is the replacement)
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
gmInte.config.forcePlayerLink = false // If true, the addon will force the players to link their discord account to their steam account before playing
|
gmInte.config.forcePlayerLink = false // If true, the addon will force the players to link their discord account to their steam account before playing
|
||||||
gmInte.config.supportLink = "" // The link of your support (shown when a player do not have the requiments to join the server)
|
gmInte.config.supportLink = "" // The link of your support (shown when a player do not have the requiments to join the server)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user