|
@@ -9,6 +9,7 @@
|
|
|
# TODO: Make routes for various chat and video links
|
|
|
|
|
|
try:
|
|
|
+ from names import *
|
|
|
from config import *
|
|
|
from auth import *
|
|
|
from flask import Flask, jsonify, current_app, request
|
|
@@ -44,27 +45,38 @@ def get_now(): # This creates and returns a time stamp
|
|
|
|
|
|
logging.info(f'\n\n\n\n{get_now()} - Webhook called.\n')
|
|
|
|
|
|
-def change_t_name():
|
|
|
+def streaming_t_name(): # Change Twitter name to show we're streaming'
|
|
|
get_t_info = twitter.verify_credentials() # Get current Twitter name
|
|
|
current_t_name = f't_name = \'{get_t_info["name"]}\'' # Create Twitter list entry
|
|
|
current_names.append(current_t_name) # Append to list of current names
|
|
|
logging.info(f'{get_now()} - Current Twitter name is \"{get_t_info["name"]}\".')
|
|
|
|
|
|
- set_t_name = twitter.update_profile(name=t_online_name)
|
|
|
+ set_t_name = twitter.update_profile(name=t_streaming_name)
|
|
|
|
|
|
- logging.info(f'{get_now()} - New Twitter name is {set_t_name["name"]}.')
|
|
|
+ logging.info(f'{get_now()} - Twitter name is now {set_t_name["name"]}.')
|
|
|
|
|
|
-def change_m_name():
|
|
|
+def streaming_m_name(): # Change Mastodon name to show we're streaming
|
|
|
get_m_info = requests.get('https://fosstodon.org/api/v1/accounts/verify_credentials', headers={'Authorization': m_api_key, 'Accept': 'application/json'}) # Get Mastodon account information
|
|
|
get_m_info = get_m_info.json() # Jsonify the response
|
|
|
current_m_name = f'm_name = \'{get_m_info["display_name"]}\'' # Create Mastodon list entry
|
|
|
current_names.append(current_m_name) # Append to list of current names
|
|
|
logging.info(f'{get_now()} - Current Mastodon name is \"{get_m_info["display_name"]}\".')
|
|
|
|
|
|
- set_m_name = requests.patch('https://fosstodon.org/api/v1/accounts/update_credentials', params={'display_name': m_online_name}, headers={'Authorization': m_api_key, 'Accept': 'application/json'}) # Set Mastodon display name
|
|
|
+ set_m_name = requests.patch('https://fosstodon.org/api/v1/accounts/update_credentials', params={'display_name': m_streaming_name}, headers={'Authorization': m_api_key, 'Accept': 'application/json'}) # Set Mastodon display name
|
|
|
set_m_name = set_m_name.json() # Jsonify the response
|
|
|
|
|
|
- logging.info(f'{get_now()} - New name is \"{set_m_name["display_name"]}\".')
|
|
|
+ logging.info(f'{get_now()} - Mastodon name is now \"{set_m_name["display_name"]}\".')
|
|
|
+
|
|
|
+def reg_t_name(): # Change Twitter name to regular name
|
|
|
+ set_t_name = twitter.update_profile(name=t_name)
|
|
|
+
|
|
|
+ logging.info(f'{get_now()} - Twitter name is now {set_t_name["name"]}.')
|
|
|
+
|
|
|
+def reg_m_name(): # Change Mastodon name to regular name
|
|
|
+ set_m_name = requests.patch('https://fosstodon.org/api/v1/accounts/update_credentials', params={'display_name': m_name}, headers={'Authorization': m_api_key, 'Accept': 'application/json'}) # Set Mastodon display name
|
|
|
+ set_m_name = set_m_name.json() # Jsonify the response
|
|
|
+
|
|
|
+ logging.info(f'{get_now()} - Mastodon name is now \"{set_m_name["display_name"]}\".')
|
|
|
|
|
|
def write_current_names(): # Write current names to names.py
|
|
|
logging.info(f'{get_now()} - Storing {current_names}.')
|
|
@@ -147,8 +159,8 @@ def start():
|
|
|
discmsg = f'DeadTOm is streaming on Owncast, at https://owncast.deadtom.me. {stream_title}'
|
|
|
if testing != 1: # If we're testing, don't actually send out notification
|
|
|
social_post(msg, discmsg)
|
|
|
- change_m_name()
|
|
|
- change_t_name()
|
|
|
+ streaming_m_name()
|
|
|
+ streaming_t_name()
|
|
|
write_current_names()
|
|
|
else:
|
|
|
logging.info(f'-----------------------\n\n'
|