Created
June 16, 2020 14:36
-
-
Save Parik27/3fca8328812c28375dbc3d05a982fc49 to your computer and use it in GitHub Desktop.
OBS Plugin to send a webhook message to Discord when you start streaming (requires discord-webhook to be installed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import obspython | |
from discord_webhook import DiscordWebhook | |
webhookUrl = "" | |
content = "" | |
enabled = False | |
def frontend_event_handler(data): | |
if data == obspython.OBS_FRONTEND_EVENT_STREAMING_STARTED and enabled: | |
webhook = DiscordWebhook(url=webhookUrl, content=content) | |
webhook.execute() | |
def validate_webhook_url(url): | |
return url.startswith("https://discord.com/api/webhooks/") | |
def script_update(settings): | |
global webhookUrl | |
global enabled | |
global content | |
webhookUrl = obspython.obs_data_get_string(settings, "webhookUrl").strip() | |
content = obspython.obs_data_get_string(settings, "content") | |
enabled = validate_webhook_url(webhookUrl) | |
if not enabled: | |
print("Invalid Webhook URL : {}".format(webhookUrl)) | |
def script_description(): | |
return "Sends a Webhook Request to post a message on a Discord channel when you start streaming" | |
def script_properties(): | |
props = obspython.obs_properties_create() | |
obspython.obs_properties_add_text(props, | |
"webhookUrl", | |
"Webhook URL", | |
obspython.OBS_TEXT_DEFAULT) | |
obspython.obs_properties_add_text(props, | |
"content", | |
"Content", | |
obspython.OBS_TEXT_MULTILINE) | |
return props | |
obspython.obs_frontend_add_event_callback(frontend_event_handler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment