|
@@ -8,7 +8,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
try:
|
|
|
from config import *
|
|
|
from auth import *
|
|
@@ -28,9 +27,14 @@ logging.basicConfig(filename='/var/www/html/webhooks.log', level=logging.INFO)
|
|
|
|
|
|
|
|
|
|
|
|
+current_names = []
|
|
|
testing = 0
|
|
|
|
|
|
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
|
|
+get_t_info = twitter.verify_credentials()
|
|
|
+
|
|
|
+get_m_info = requests.get('https://fosstodon.org/api/v1/accounts/verify_credentials', headers={'Authorization': m_api_key, 'Accept': 'application/json'})
|
|
|
+get_m_info = get_m_info.json()
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
@@ -40,6 +44,35 @@ 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():
|
|
|
+ get_t_info = twitter.verify_credentials()
|
|
|
+ current_t_name = f't_name = \'{get_t_info["name"]}\''
|
|
|
+ current_names.append(current_t_name)
|
|
|
+ logging.info(f'{get_now()} - Current Twitter name is \"{get_t_info["name"]}\".')
|
|
|
+
|
|
|
+ set_t_name = twitter.update_profile(name=t_online_name)
|
|
|
+
|
|
|
+ logging.info(f'{get_now()} - New Twitter name is {set_t_name["name"]}.')
|
|
|
+
|
|
|
+def change_m_name():
|
|
|
+ get_m_info = requests.get('https://fosstodon.org/api/v1/accounts/verify_credentials', headers={'Authorization': m_api_key, 'Accept': 'application/json'})
|
|
|
+ get_m_info = get_m_info.json()
|
|
|
+ current_m_name = f'm_name = \'{get_m_info["display_name"]}\''
|
|
|
+ current_names.append(current_m_name)
|
|
|
+ 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_m_name = set_m_name.json()
|
|
|
+
|
|
|
+ logging.info(f'{get_now()} - New name is \"{set_m_name["display_name"]}\".')
|
|
|
+
|
|
|
+def write_current_names():
|
|
|
+ logging.info(f'{get_now()} - Storing {current_names}.')
|
|
|
+ file = open("names.py", "w")
|
|
|
+ for name in current_names:
|
|
|
+ file.write(f'{name}\n')
|
|
|
+ file.close()
|
|
|
+
|
|
|
def mc_chat(mc_msg):
|
|
|
logging.info(f'{get_now()} - Checking Minecraft server for players.')
|
|
|
mc_server = JavaServer.lookup('mc.deadtom.me:25565')
|
|
@@ -114,6 +147,9 @@ def start():
|
|
|
discmsg = f'DeadTOm is streaming on Owncast, at https://owncast.deadtom.me. {stream_title}'
|
|
|
if testing != 1:
|
|
|
social_post(msg, discmsg)
|
|
|
+ change_m_name()
|
|
|
+ change_t_name()
|
|
|
+ write_current_names()
|
|
|
else:
|
|
|
logging.info(f'-----------------------\n\n'
|
|
|
f'{get_now()} - Currently running in test mode. We are streaming, but no notifications are being sent to social media.'
|