Skip to content

Commit

Permalink
General improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarrus1 committed Jun 5, 2021
1 parent c18ca11 commit 044f05f
Show file tree
Hide file tree
Showing 6 changed files with 874 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Compile plugins
run: |
for file in scripting/SurfTimer-discord*.sp
for file in scripting/SurfTimer-discord.sp
do
echo -e "\nCompiling $file..."
spcomp -E -w234 -O2 -v2 -i include $file
Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
# SurfTimer-discord


![Downloads](https://img.shields.io/github/downloads/Sarrus1/SurfTimer-discord/total?style=flat-square) ![Last commit](https://img.shields.io/github/last-commit/Sarrus1/SurfTimer-discord?style=flat-square) ![Open issues](https://img.shields.io/github/issues/Sarrus1/SurfTimer-discord?style=flat-square) ![Closed issues](https://img.shields.io/github/issues-closed/Sarrus1/SurfTimer-discord?style=flat-square) ![Size](https://img.shields.io/github/repo-size/Sarrus1/SurfTimer-discord?style=flat-square) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Sarrus1/SurfTimer-discord/Compile%20with%20SourceMod?style=flat-square)

## Description ##
## Description

Sends nice Discord embeded messages when a new map record is set.
The messages will look like this:

![Preview](https://raw.githubusercontent.com/Sarrus1/SurfTimer-discord/master/img/desc.png)

## Requirements

## Requirements ##
- Sourcemod and Metamod
- [SurfTimer-Official (Sad's Fork)](https://github.com/qawery-just-sad/Surftimer-Official)
- [SMJansson](https://forums.alliedmods.net/showthread.php?t=184604)
- [SteamWorks](https://forums.alliedmods.net/showthread.php?t=229556)

## Installation

## Installation ##
1. Grab the latest release from the release page and unzip it in your sourcemod folder.
2. Restart the server or type `sm plugins load SurfTimer-discord` in the console to load the plugin.
3. The config file will be automatically generated in cfg/sourcemod/
3. The config file will be automatically generated at `cfg/sourcemod/SurfTimer-discord.cfg`
4. In the config file, configure your Discord Webhook and your Steam API key (optional, you can get it [here](https://steamcommunity.com/dev/apikey)).

## Configuration

## Configuration ##
- You can modify the phrases in addons/sourcemod/translations/SurfTimer-discord.phrases.txt.
- Once the plugin has been loaded, you can modify the cvars in cfg/sourcemod/SurfTimer-discord.cfg.

## Usage

## Usage ##
- You can use the `sm_ck_discordtest` command to test the messages.
Binary file added img/desc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/SurfTimer-discord.smx
Binary file not shown.
21 changes: 9 additions & 12 deletions scripting/SurfTimer-discord.sp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <discord>
#include <steamworks>
#include <smjansson>
#include <colorvariables>
#pragma newdecls required
#pragma semicolon 1

Expand All @@ -19,7 +20,6 @@ public Plugin myinfo =
};

ConVar g_cvWebhook;
ConVar g_cvThumbnailUrlRoot;
ConVar g_cvMainUrlRoot;
ConVar g_cvMention;
ConVar g_cvBotUsername;
Expand All @@ -43,7 +43,6 @@ public void OnPluginStart()
g_cvMention = CreateConVar("sm_surftimer_discord_mention", "@here", "Optional discord mention to notify users.");
g_cvMainEmbedColor = CreateConVar("sm_surftimer_discord_main_embed_color", "#00ffff", "Color of embed for when main wr is beaten");
g_cvBonusEmbedColor = CreateConVar("sm_surftimer_discord_bonus_embed_color", "#ff0000", "Color of embed for when bonus wr is beaten");
g_cvThumbnailUrlRoot = CreateConVar("sm_surftimer_discord_thumbnail_url_root", "https://raw.githubusercontent.com/Sayt123/SurfMapPics/master/csgo/", "The base url of where the Discord images are stored. Leave blank to disable.");
g_cvMainUrlRoot = CreateConVar("sm_surftimer_discord_main_url_root", "https://raw.githubusercontent.com/Sayt123/SurfMapPics/master/csgo/", "The base url of where the Discord images are stored. Leave blank to disable.");
g_cvBotUsername = CreateConVar("sm_surftimer_discord_username", "SurfTimer BOT", "Username of the bot");
g_cvFooterUrl = CreateConVar("sm_surftimer_discord_footer_url", "https://images-ext-1.discordapp.net/external/tfTL-r42Kv1qP4FFY6sQYDT1BBA2fXzDjVmcknAOwNI/https/images-ext-2.discordapp.net/external/3K6ho0iMG_dIVSlaf0hFluQFRGqC2jkO9vWFUlWYOnM/https/images-ext-2.discordapp.net/external/aO9crvExsYt5_mvL72MFLp92zqYJfTnteRqczxg7wWI/https/discordsl.com/assets/img/img.png", "The url of the footer icon, leave blank to disable.");
Expand Down Expand Up @@ -85,8 +84,10 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n

public Action CommandDiscordTest(int client, int args)
{
CPrintToChat(client, "{blue}[SurfTimer-Discord] {green}Sending main record test message.");
surftimer_OnNewRecord(client, 0, "00:00:00", "-00:00:00", -1);
PrintToChat(client, "[SurfTimer-Discord] Sending the message.");
CPrintToChat(client, "{blue}[SurfTimer-Discord] {green}Sending bonus record test message.");
surftimer_OnNewRecord(client, 0, "00:00:00", "-00:00:00", 1);
return Plugin_Handled;
}

Expand Down Expand Up @@ -150,7 +151,7 @@ stock void sendDiscordAnnouncement(int client, int style, char[] szTime, char[]

char szTitle[256];
if(bonusGroup == -1) {
Format(szTitle, sizeof( szTitle ), "__**New World Record**__ | **%s** - **%s**", g_szCurrentMap, style);
Format(szTitle, sizeof( szTitle ), "__**New World Record**__ | **%s** - **%s**", g_szCurrentMap, szPlayerStyle);
} else {
Format(szTitle, sizeof( szTitle ), "__**New Bonus #%i World Record**__ | **%s** - **%s**", bonusGroup, g_szCurrentMap, szPlayerStyle);
}
Expand All @@ -171,15 +172,11 @@ stock void sendDiscordAnnouncement(int client, int style, char[] szTime, char[]

char szUrlMain[1024];
GetConVarString(g_cvMainUrlRoot, szUrlMain, 1024);
char szUrlThumb[1024];
GetConVarString(g_cvThumbnailUrlRoot, szUrlThumb, 1024);
if(StrEqual(g_szPictureURL, ""))
Embed.SetThumb(szUrlThumb);
else
{
Embed.SetImage(szUrlMain);
StrCat(szUrlMain, sizeof szUrlMain, g_szCurrentMap);
StrCat(szUrlMain, sizeof szUrlMain, ".jpg");
Embed.SetImage(szUrlMain);
if(!StrEqual(g_szPictureURL, ""))
Embed.SetThumb(g_szPictureURL);
}

char szFooterUrl[1024];
GetConVarString(g_cvFooterUrl, szFooterUrl, sizeof szFooterUrl);
Expand Down
Loading

0 comments on commit 044f05f

Please sign in to comment.