SRL Archive - Other Guides

Notification when your bot goes down (via discord)


vodalternatives

2019-05-22 07:35:09

I use to push notification each time now this is super cool. Thanks for the information.

Failure

2019-07-19 14:59:43

Hi and thank you @acow!

I changed it a bit for personal use (and perhaps easier to use)


const DiscordWebhookURL := 'url';

Procedure SendDiscordWebhook(JSON: string);
var
HTTPClient: Integer;
begin
HTTPClient := InitializeHTTPClient(False);
PostHTTPPage(HTTPClient, DiscordWebhookURL, '{"content" : "['+ FormatDateTime('tt', Time) + ']\n' + JSON + '"}'); //Just added current time
FreeHTTPClient(HTTPClient);
end;

Usage

SendDiscordWebhook(+'Not mining'); //Notice the '+' in front

Result
[ATTACH=CONFIG]28665[/ATTACH]

Dan the man

2019-07-21 03:15:46

Hey guys.

I have tried doing the above examples without any luck.

Anyone mind telling me what I am doing wrong?
Not getting any data coming through on the channel at all.

program new;
const
DiscordWebhookURL = 'http://discordapp.com/api/webhooks/602319574863708171/gVoLTLYGghVdhz_XX-6sabstnvOtRdGyOhkhUhpUW0yG0O9TH_74SFgmxTlA99qnyaj8';
DiscordWebhookJSON = '{"content" : "Test"}';

Procedure SendDiscordWebhook(WebhookURL, JSON: string);
var
HTTPClient: Integer;
begin
HTTPClient := InitializeHTTPClient(False);
writeln(HTTPClient);
PostHTTPPage(HTTPClient, WebhookURL, JSON);
writeln(GetHTTPPage(HTTPClient, DiscordWebhookURL));
FreeHTTPClient(HTTPClient);
end;

Procedure Terminator();
begin
SendDiscordWebhook(DiscordWebhookURL, DiscordWebhookJSON);
end;

begin
AddOnTerminate('Terminator'); //whenever the script terminates [safely], the Terminator() procedure will be called
SendDiscordWebhook(DiscordWebhookURL, DiscordWebhookJSON);
//rest of the script
end.


Citrus

2019-07-21 10:31:08

From: Dan the man
Hey guys.

I have tried doing the above examples without any luck.

Anyone mind telling me what I am doing wrong?
Not getting any data coming through on the channel at all.


That's weird. I copy/pasted your code and just replaced the url with my own and it worked perfectly. Tried with your url and it failed. Maybe try to generate a new webhook url?

Dan the man

2019-07-21 11:20:49

From: Citrus
That's weird. I copy/pasted your code and just replaced the url with my own and it worked perfectly. Tried with your url and it failed. Maybe try to generate a new webhook url?


Yeah I tried that on a few different servers I made with the same result. Very unusual. Any other Discord settings I am not thinking of?

Dan the man

2019-07-21 23:51:41

From: Citrus
That's weird. I copy/pasted your code and just replaced the url with my own and it worked perfectly. Tried with your url and it failed. Maybe try to generate a new webhook url?


Would u mind sharing the url that worked for you?
Will allow me to eliminate my Simba client as an issue.

EDIT: If you are having the same issue as me, the problem was Simba 1.2. There is a bug that prevents it from sending the hook. Use Simba 1.3 or 1.1.

acow

2019-07-31 18:17:55

From: Dan the man

EDIT: If you are having the same issue as me, the problem was Simba 1.2. There is a bug that prevents it from sending the hook. Use Simba 1.3 or 1.1.


That's surprising since iirc only simba 1.2 was used for developing this and the video recorder. If you're using 1.2, the version by slacky is probably the one you should be using. https://github.com/slackydev/Simba/releases/download/Simba-1.2.0-rc6_fixes/Simba1206-fixes.x86.exe

if it works for 1.3, which it seems to, that's probably the way to go currently.

Dan the man

2019-07-31 22:13:13

Just tested that version and it didnt work.

After ainstakingly removing the reliance on aerolib from my include, i have managed to move it to 1.3 and it works flawlessly :D

the kappin

2022-07-15 16:07:11

Couldnt get this to work