|
@@ -1,7 +1,7 @@
|
|
|
#!/var/www/html/webhooks/.venv/bin/python
|
|
|
# File name: Hooks.py
|
|
|
# Date created: 09/16/2022
|
|
|
-# Date last modified: 09/18/2022
|
|
|
+# Date last modified: 10/15/2022
|
|
|
# Python Version: 3.9.2
|
|
|
# Copyright © 2022 DeadTOm
|
|
|
# Description: Webhooks for Owncast to send notifications to Discord, Mastodon and Twitter, and to interact with
|
|
@@ -65,7 +65,7 @@ def set_hashtags(title): # Sets up hash tags to be appended to social media
|
|
|
check_title = title.lower()
|
|
|
default_tags = '#Owncast '
|
|
|
tags = ''
|
|
|
- ### tag_dict located in config.py ###
|
|
|
+ # tag_dict located in config.py
|
|
|
for tag in tag_dict.keys(): # Iterate through each dict entry, and check for hashtag triggers
|
|
|
if tag in check_title:
|
|
|
print(f'Found {tag}, adding {tag_dict[tag]} to hashtags.')
|
|
@@ -75,7 +75,7 @@ def set_hashtags(title): # Sets up hash tags to be appended to social media
|
|
|
return tags
|
|
|
|
|
|
def social_post(msg, discmsg): # Post to Mastodon
|
|
|
- ### Send to Mastodon ###
|
|
|
+ # Send to Mastodon
|
|
|
logging.info(f'{get_now()} - Posting to Mastodon.')
|
|
|
response = requests.post(m_api_url,
|
|
|
params={'status': msg},
|
|
@@ -86,11 +86,11 @@ def social_post(msg, discmsg): # Post to Mastodon
|
|
|
for line in json_response:
|
|
|
logging.debug(f'{get_now()} - API returned: {line}: {json_response[line]}')
|
|
|
|
|
|
- ### Send to Twitter ###
|
|
|
+ # Send to Twitter
|
|
|
twitter.update_status(status=msg) # Tweet the message
|
|
|
logging.info(f'{get_now()} - Posted to Twitter.')
|
|
|
|
|
|
- ### Send to Discord ###
|
|
|
+ # Send to Discord
|
|
|
# for all params, see https://discordapp.com/developers/docs/resources/webhook#execute-webhook
|
|
|
data = {
|
|
|
'content': discmsg
|