sapphonie / StAC-tf2

steph's anticheat (StAC). a built-from-scratch sourcemod based solution to cheating in Team Fortress 2.
https://sappho.io
GNU General Public License v3.0
120 stars 23 forks source link

Discord Translations #53

Closed MAGNAT2645 closed 3 years ago

MAGNAT2645 commented 3 years ago

StacDetectionDiscordNotify and StacGeneralPlayerDiscordNotify should be translatable (especially title and name keys).

For example:

    "discord_detection_title"
    {
        "en"        "StAC Detection!"
        "ru"        "Обнаружение от StAC!"
    }

    "discord_message_title"
    {
        "en"        "StAC Message"
        "ru"        "Сообщение от StAC"
    }

    "discord_player_field"
    {
        "en"        "Player"
        "ru"        "Игрок"
    }

    "discord_detection_type_field"
    {
        "en"        "Detection type"
        "ru"        "Тип обнаружения"
    }

    "discord_detection_count_field"
    {
        "en"        "Detections"
        "ru"        "Обнаружений"
    }

    "discord_message_field"
    {
        "en"        "Message"
        "ru"        "Сообщение"
    }

    "discord_hostname_field"
    {
        "en"        "Hostname"
        "ru"        "Сервер"
    }

    "discord_hostip_field"
    {
        "en"        "Host IP"
        "ru"        "IP сервера"
    }

    "discord_demo_field"
    {
        "en"        "Current Demo Recording"
        "ru"        "Текущее демо"
    }

    "discord_unix_timestamp_field"
    {
        "en"        "Unix timestamp of detection"
        "ru"        "Unix-отметка времени обнаружения"
    }

Snippet:

void StacDetectionDiscordNotify(int userid, char[] type, int detections)
{
    static char detectionTemplate[1024] = \
    "{ \"embeds\": [ { \"title\": \"%t\", \"color\": 16738740, \"fields\": [ { \"name\": \"%t\", \"value\": \"%N\" } , { \"name\": \"SteamID\", \"value\": \"%s\" }, { \"name\": \"%t\", \"value\": \"%s\" }, { \"name\": \"%t\", \"value\": \"%i\" }, { \"name\": \"%t\", \"value\": \"%s\" }, { \"name\": \"%t\", \"value\": \"%s\" } , { \"name\": \"%t\", \"value\": \"%s\" } , { \"name\": \"%t\", \"value\": \"%i\" } ] } ] }";

    if (!DISCORD)
    {
        return;
    }

    char msg[1024];

    int Cl = GetClientOfUserId(userid);
    char ClName[64];
    GetClientName(Cl, ClName, sizeof(ClName));
    Discord_EscapeString(ClName, sizeof(ClName));
    GetDemoName();
    // we technically store the url in this so it has to be bigger
    char steamid[96];
    // ok we store these on client connect & auth, this shouldn't be null
    if (!IsActuallyNullString(SteamAuthFor[Cl]))
    {
        // make this a clickable link in discord
        Format(steamid, sizeof(steamid), "[%s](https://steamid.io/lookup/%s)", SteamAuthFor[Cl], SteamAuthFor[Cl]);
    }
    // if it is, that means the plugin reloaded or steam is being fussy.
    else
    {
        steamid = "N/A";
    }

    SetGlobalTransTarget( LANG_SERVER ); // new

    Format
    (
        msg,
        sizeof(msg),
        detectionTemplate,
        "discord_detection_title" // new
        "discord_player_field", // new
        Cl,
        steamid,
        "discord_detection_type_field", // new
        type,
        "discord_detection_count_field", // new
        detections,
        "discord_hostname_field", // new
        hostname,
        "discord_hostip_field", // new
        hostipandport,
        "discord_demo_field", // new
        demoname,
        "discord_unix_timestamp_field", // new
        GetTime()
    );
    SendMessageToDiscord(msg);
}
sapphonie commented 3 years ago

See: #57