Discourse to Discord Webhook

:discourse: :information_source: Before trying this, check out the official chat integration plugin for Discord

Discourse to Discord Webhook

This PHP script acts an intermediary between Discourse and Discord, receiving webhooks from Discourse and parsing them into an optimal format before relaying them to Discord.

Demo

See it in action and test it out for yourself on Crit Cola’s Discourse and Discord.

Installation

Just clone it!

git clone https://github.com/critcola/discourse-to-discord-webhook.git

This has been tested with and is supported on PHP 7.1, but should work fine on older versions of PHP.

Configuration

Copy config-template.php to config.php and populate all non-optional variables after configuring webhooks in both Discourse and Discord.

License

The Discourse to Discord Webhook script is released under the MIT License.

9 إعجابات

where is the “congif.php” located

Rename config-template.php to config.php.

إعجابَين (2)

Still don’t know where it is found

https://github.com/critcola/discourse-to-discord-webhook

إعجاب واحد (1)

I am getting this error when sending a ping or a new post is created. Any help with what is happening here?

I tried both a public and private channel; same response.

Status: 400

{"code": 50006, "message": "Cannot send an empty message"}

config.php

$discord_webhook_url = 'WEBHOOK_FROM_DISCORD';

$discord_embed_color = '#HEX_VALUE';

$discord_embed_thumbnail_url ='https://DOMAIN_NAME';

$discord_embed_footer_icon_url = $discord_embed_thumbnail_url;
$discord_embed_footer_text = 'CUSTOM_STRING';

$discord_embed_timestamp = true;

$discourse_payload_secret = 'RANDOMLY_GENERATED_STRING';

$discourse_url_protocol = 'https';

$discourse_url_domain = 'forums.domain.com';

$discourse_path = '/';

Discourse Settings

Payload URL = DISCORD_APP_WEBOOK_URL

Content Type = application/json

Secret = RANDOMLY_GENERATED_STRING #same as above

Events = All events, or, all individual events checked

Check TLS certificate of payload url = checked

Active = checked

نعم، إذن… أنا أيضًا؟ أنا أشغل Discourse داخل حاوية Docker، وملف app.yml يحتوي على العديد من الأسطر لسحب مستودعات Git لبنائها عبر أداة التشغيل (launcher)… لذا أضفت

- git clone https://github.com/critcola/discourse-to-discord-webhook.git

إلى ملف app.yml وأعيد البناء.. لكن أصبح غير واضح بالنسبة لي كيفية تعديل ملف config-template.php وحفظ هذه التحديثات في config.php عندما تكون العملية كلها مؤتمتة بواسطة عملية بناء أداة التشغيل.

لماذا لا تُجعل هذه الإعدادات جزءًا من واجهة إعدادات ضمن قسم المسؤول بدلاً من تعديل ملف PHP؟ إذا كان ذلك غير عملي، فكيف يمكن لشخص مثلي تعديل ملف config.php؟ هل يجب علي الدخول إلى بيئة حاوية Docker وإنشاء ملف config.php يدويًا هناك؟ وهل يظل هذا الملف قائمًا بعد التحديثات وإعادة بناء الحاويات؟