7 Commits
3 changed files with 60 additions and 23 deletions
+23
View File
@@ -0,0 +1,23 @@
name: Release
on:
push:
tags:
- "*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- run: git log $(git describe --tags --abbrev=0 HEAD~1)..HEAD --oneline > changelog.txt
- uses: softprops/action-gh-release@v2
with:
make_latest: true
body_path: changelog.txt
files: astrolobot.py
+36 -22
View File
@@ -10,24 +10,27 @@ import json,sys,webbrowser,importlib,tomllib
def update(): def update():
print('checking for updates...') print('checking for updates...')
with open(script_path()+'astrolobot.py','r') as file: try:
current_script=file.read() with open(script_path()+'astrolobot.py','r') as file:
urlretrieve( current_script=file.read()
'https://github.com/sugoidogo/astrolobot/releases/latest/download/astrolobot.py', urlretrieve(
script_path()+'astrolobot.py' 'https://gitea.sugoidogo.com/SugoiDogo/astrolobot/releases/download/latest/astrolobot.py',
) script_path()+'astrolobot.py'
with open(script_path()+'astrolobot.py','r') as file: )
updated_script=file.read() with open(script_path()+'astrolobot.py','r') as file:
if current_script==updated_script: updated_script=file.read()
print('up to date') if current_script==updated_script:
else: print('up to date')
print('update downloaded, restart script to apply') else:
print('update downloaded, restart script to apply')
except:
print('update check failed, ignoring')
def dependency_setup(): def dependency_setup():
if not path.exists(script_path()+'pip'): if not path.exists(script_path()+'pip'):
print('installing dependencies') print('installing dependencies')
from pip._internal.cli.main import main as pip from pip._internal.cli.main import main as pip
pip(['install','-qq','pyswisseph','twitch.py','--target',script_path()+'pip']) pip(['install','-qq','-r',script_path()+'/requirements.txt','--target',script_path()+'pip'])
sys.path.append(script_path()+'pip') sys.path.append(script_path()+'pip')
@@ -394,7 +397,11 @@ def login(*args):
global device_code global device_code
if device_code==None: if device_code==None:
print('astrolobot is still starting, please wait',sys.stderr) print('astrolobot is still starting, please wait',sys.stderr)
webbrowser.open('https://www.twitch.tv/activate?public=true&device-code='+device_code) else:
login_url='https://www.twitch.tv/activate?public=true&device-code='+device_code
print("if your browser doesn't automatically open, go to the following url:")
print(login_url)
webbrowser.open(login_url)
def save_tokens(access_token,refresh_token): def save_tokens(access_token,refresh_token):
with open(script_path()+'tokens.json','w') as file: with open(script_path()+'tokens.json','w') as file:
@@ -463,7 +470,7 @@ def main():
async def on_code(code: str): async def on_code(code: str):
global device_code, obs_settings global device_code, obs_settings
device_code=code device_code=code
if obs_settings == None: if len(tokens)==0:
login() login()
@client.event @client.event
@@ -472,6 +479,12 @@ def main():
@client.event @client.event
async def on_ready() -> None: async def on_ready() -> None:
global user
user=client.user
config=load_settings()
if('channel' in config):
user=await client.get_user(config['channel'])
await client.add_custom_event('on_chat_message',user,on_chat_message)
print('astrolobot ready') print('astrolobot ready')
while True: while True:
tokens=client.http.get_token(client.user.id) tokens=client.http.get_token(client.user.id)
@@ -479,32 +492,32 @@ def main():
tokens=refresh_tokens(tokens['refresh_token']) tokens=refresh_tokens(tokens['refresh_token'])
await client.authorize(tokens['access_token'],tokens['refresh_token']) await client.authorize(tokens['access_token'],tokens['refresh_token'])
@client.event
async def on_chat_message(data: eventsub.chat.MessageEvent): async def on_chat_message(data: eventsub.chat.MessageEvent):
global user
config=load_settings() config=load_settings()
if data['message']['text']==config['positions']: if data['message']['text']==config['positions']:
for line in get_positions_formatted().splitlines(False): for line in get_positions_formatted().splitlines(False):
await client.channel.chat.send_message(line,data['message_id']) await user.channel.chat.send_message(line,data['message_id'])
return return
if data['message']['text']==config['transits']: if data['message']['text']==config['transits']:
for line in get_transits_formatted().splitlines(False): for line in get_transits_formatted().splitlines(False):
await client.channel.chat.send_message(line,data['message_id']) await user.channel.chat.send_message(line,data['message_id'])
return return
if data['message']['text']==config['major_aspects']: if data['message']['text']==config['major_aspects']:
for line in get_aspects_formatted().splitlines(False): for line in get_aspects_formatted().splitlines(False):
await client.channel.chat.send_message(line,data['message_id']) await user.channel.chat.send_message(line,data['message_id'])
return return
if data['message']['text']==config['minor_aspects']: if data['message']['text']==config['minor_aspects']:
for line in get_aspects_formatted(minor=True).splitlines(False): for line in get_aspects_formatted(minor=True).splitlines(False):
await client.channel.chat.send_message(line,data['message_id']) await user.channel.chat.send_message(line,data['message_id'])
return return
if data['message']['text']==config['major_aspect_transits']: if data['message']['text']==config['major_aspect_transits']:
for line in get_aspect_transits_formatted().splitlines(False): for line in get_aspect_transits_formatted().splitlines(False):
await client.channel.chat.send_message(line,data['message_id']) await user.channel.chat.send_message(line,data['message_id'])
return return
if data['message']['text']==config['minor_aspect_transits']: if data['message']['text']==config['minor_aspect_transits']:
for line in get_aspect_transits_formatted(minor=True).splitlines(False): for line in get_aspect_transits_formatted(minor=True).splitlines(False):
await client.channel.chat.send_message(line,data['message_id']) await user.channel.chat.send_message(line,data['message_id'])
return return
client.run(*tokens.values()) client.run(*tokens.values())
@@ -555,6 +568,7 @@ def script_properties():
properties=obspython.obs_properties_create() properties=obspython.obs_properties_create()
obspython.obs_properties_add_button(properties,'login','Login to Twitch',login) obspython.obs_properties_add_button(properties,'login','Login to Twitch',login)
obspython.obs_properties_add_button(properties,'update','Check for Updates',obs_update) obspython.obs_properties_add_button(properties,'update','Check for Updates',obs_update)
obspython.obs_properties_add_text(properties,'channel','channel name',obspython.OBS_TEXT_DEFAULT)
obspython.obs_properties_add_text(properties,'commands','commands',obspython.OBS_TEXT_INFO) obspython.obs_properties_add_text(properties,'commands','commands',obspython.OBS_TEXT_INFO)
obspython.obs_properties_add_text(properties,'positions','positions',obspython.OBS_TEXT_DEFAULT) obspython.obs_properties_add_text(properties,'positions','positions',obspython.OBS_TEXT_DEFAULT)
obspython.obs_properties_add_text(properties,'transits','transits',obspython.OBS_TEXT_DEFAULT) obspython.obs_properties_add_text(properties,'transits','transits',obspython.OBS_TEXT_DEFAULT)
+1 -1
View File
@@ -1,2 +1,2 @@
pyswisseph pyswisseph
twitch.py twitch.py == 3.*