this time comitting without api, and tokens by accident
This commit is contained in:
parent
cd4937521b
commit
363233b044
119
Discord_UNLOZE/scripting/live_chat_stoat.sp
Normal file
119
Discord_UNLOZE/scripting/live_chat_stoat.sp
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
#pragma semicolon 1
|
||||||
|
|
||||||
|
#include <ripext>
|
||||||
|
#include <basecomm>
|
||||||
|
#include <multicolors>
|
||||||
|
#include <sourcemod>
|
||||||
|
#include <Discord_UNLOZE>
|
||||||
|
|
||||||
|
#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, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user