From 363233b04475c855dc0a7a5acba3a2926b459188 Mon Sep 17 00:00:00 2001 From: jenz Date: Thu, 5 Feb 2026 17:31:35 +0100 Subject: [PATCH] this time comitting without api, and tokens by accident --- Discord_UNLOZE/scripting/live_chat_stoat.sp | 119 ++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Discord_UNLOZE/scripting/live_chat_stoat.sp diff --git a/Discord_UNLOZE/scripting/live_chat_stoat.sp b/Discord_UNLOZE/scripting/live_chat_stoat.sp new file mode 100644 index 0000000..a446be8 --- /dev/null +++ b/Discord_UNLOZE/scripting/live_chat_stoat.sp @@ -0,0 +1,119 @@ +#pragma semicolon 1 + +#include +#include +#include +#include +#include + +#define API_URL "" +#define BOT_TOKEN "" + +public Plugin myinfo = +{ + name = "livechat stoat", + author = "jenz", + description = "", + version = "1.0.0", + url = "www.unloze.com" +} + +public void OnPluginStart() +{ + AddCommandListener(CommandListener_SmChat_stoat, "say"); + RegServerCmd("sm_printtoallchat_stoat", Command_PrintToAllChat_stoat, "Discord Integration"); +} + +public Action CommandListener_SmChat_stoat(int client, const char[] sCommand, int argc) +{ + if (client <= 0) + return Plugin_Continue; + + char sText[256]; + char sUsername[32]; + + GetCmdArgString(sText, sizeof(sText)); + GetClientName(client, sUsername, sizeof(sUsername)); + + if (FindCharInString(sText, '!') > 0) + { + return Plugin_Continue; + } + if (FindCharInString(sText, '/') > 0) + { + return Plugin_Continue; + } + + if (sText[0] == '/') + { + return Plugin_Continue; + } + if (sText[0] == '!') + { + return Plugin_Continue; + } + + //LogMessage("sText: %s. sText[0]: %c", sText, sText[0]); + + SendToStoat(sUsername, sText, ""); + + return Plugin_Continue; +} + +void SendToStoat(const char[] name, const char[] msg, const char[] channel_id) { + char formatted_api[1024]; + Format(formatted_api, sizeof(formatted_api), "%s%s%s", API_URL, channel_id, "/messages"); + + HTTPRequest request = new HTTPRequest(formatted_api); + request.SetHeader("x-bot-token", BOT_TOKEN); + request.SetHeader("Content-Type", "application/json"); + + char content[1024]; + Format(content, sizeof(content), "**%s**: %s", name, msg); + + JSONObject data = new JSONObject(); + data.SetString("content", content); + + request.Post(data, OnHTTPResponse); + delete data; +} + +void OnHTTPResponse(HTTPResponse response, any value) { +} + +public Action Command_PrintToAllChat_stoat(int args) +{ + char sArgs[1024]; + char sArgs2[1024]; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + GetCmdArg(2, sArgs2, sizeof(sArgs2)); + + CPrintToChatAll("{azure}[Stoat] (ALL) %s: {white}%s", sArgs, sArgs2); + + return Plugin_Handled; +} + +public void GetDiscordToStoat(const char[] username, const char[] message, int type) +{ + //type = 1. ADMINLOGS + //type = 2. ADMIN LOGS BHOPPING ZE + //type = 3. AMDIN LOGS entwatch + //type = 4. admin logs ze ban evasion + if (type == 1) + { + SendToStoat(username, message, ""); + } + else if (type == 2) + { + SendToStoat(username, message, ""); + } + else if (type == 3) + { + SendToStoat(username, message, ""); + } + else if (type == 4) + { + SendToStoat(username, message, ""); + } +}