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
+25 -11
View File
@@ -10,10 +10,11 @@ import json,sys,webbrowser,importlib,tomllib
def update():
print('checking for updates...')
try:
with open(script_path()+'astrolobot.py','r') as file:
current_script=file.read()
urlretrieve(
'https://github.com/sugoidogo/astrolobot/releases/latest/download/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:
@@ -22,12 +23,14 @@ def update():
print('up to date')
else:
print('update downloaded, restart script to apply')
except:
print('update check failed, ignoring')
def dependency_setup():
if not path.exists(script_path()+'pip'):
print('installing dependencies')
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')
@@ -394,7 +397,11 @@ def login(*args):
global device_code
if device_code==None:
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):
with open(script_path()+'tokens.json','w') as file:
@@ -463,7 +470,7 @@ def main():
async def on_code(code: str):
global device_code, obs_settings
device_code=code
if obs_settings == None:
if len(tokens)==0:
login()
@client.event
@@ -472,6 +479,12 @@ def main():
@client.event
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')
while True:
tokens=client.http.get_token(client.user.id)
@@ -479,32 +492,32 @@ def main():
tokens=refresh_tokens(tokens['refresh_token'])
await client.authorize(tokens['access_token'],tokens['refresh_token'])
@client.event
async def on_chat_message(data: eventsub.chat.MessageEvent):
global user
config=load_settings()
if data['message']['text']==config['positions']:
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
if data['message']['text']==config['transits']:
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
if data['message']['text']==config['major_aspects']:
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
if data['message']['text']==config['minor_aspects']:
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
if data['message']['text']==config['major_aspect_transits']:
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
if data['message']['text']==config['minor_aspect_transits']:
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
client.run(*tokens.values())
@@ -555,6 +568,7 @@ def script_properties():
properties=obspython.obs_properties_create()
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_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,'positions','positions',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
twitch.py
twitch.py == 3.*