mirror of
https://github.com/SinTan1729/ReVancedBuilder.git
synced 2024-12-26 12:48:36 -06:00
feat: Notifications should work
This commit is contained in:
parent
b5fc2e43d3
commit
c1451bcc37
3 changed files with 12 additions and 5 deletions
|
@ -23,6 +23,7 @@ def move_apps(appstate):
|
||||||
pass
|
pass
|
||||||
# sys.exit('There was an error moving the final apk files!')
|
# sys.exit('There was an error moving the final apk files!')
|
||||||
|
|
||||||
|
# Do some cleanup, keep only the last 3 build's worth of files and a week worth of logs
|
||||||
files = []
|
files = []
|
||||||
dir = os.scandir('archive')
|
dir = os.scandir('archive')
|
||||||
for f in dir:
|
for f in dir:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import requests as req
|
import requests as req
|
||||||
|
import subprocess
|
||||||
|
|
||||||
def send_notif(appstate, error=False):
|
def send_notif(appstate, error=False):
|
||||||
timestamp = appstate['timestamp']
|
timestamp = appstate['timestamp']
|
||||||
|
@ -21,6 +22,8 @@ def send_notif(appstate, error=False):
|
||||||
msg = msg.replace(build_config[app]['apk'], build_config[app]['pretty_name'])
|
msg = msg.replace(build_config[app]['apk'], build_config[app]['pretty_name'])
|
||||||
|
|
||||||
msg += '\nTimestamp: ' + timestamp
|
msg += '\nTimestamp: ' + timestamp
|
||||||
|
if appstate['microg_updated']:
|
||||||
|
msg += '\nVanced microG was updated.'
|
||||||
|
|
||||||
config = appstate['notification_config']
|
config = appstate['notification_config']
|
||||||
for entry in config:
|
for entry in config:
|
||||||
|
@ -30,7 +33,7 @@ def send_notif(appstate, error=False):
|
||||||
|
|
||||||
match entry:
|
match entry:
|
||||||
case 'ntfy':
|
case 'ntfy':
|
||||||
print('Sending notification through nfty.sh')
|
print('Sending notification through ntfy.sh...')
|
||||||
try:
|
try:
|
||||||
url = config[entry]['url']
|
url = config[entry]['url']
|
||||||
topic = config[entry]['topic']
|
topic = config[entry]['topic']
|
||||||
|
@ -45,7 +48,7 @@ def send_notif(appstate, error=False):
|
||||||
print('Failed!' + str(e))
|
print('Failed!' + str(e))
|
||||||
|
|
||||||
case 'gotify':
|
case 'gotify':
|
||||||
print('Sending notification through nfty.sh')
|
print('Sending notification through Gotify...')
|
||||||
try:
|
try:
|
||||||
url = config[entry]['url']
|
url = config[entry]['url']
|
||||||
token = config[entry]['token']
|
token = config[entry]['token']
|
||||||
|
@ -60,16 +63,16 @@ def send_notif(appstate, error=False):
|
||||||
|
|
||||||
case 'telegram':
|
case 'telegram':
|
||||||
# TODO: Finish this!
|
# TODO: Finish this!
|
||||||
print('Sending notification through telegram')
|
print('Sending notification through Telegram...')
|
||||||
try:
|
try:
|
||||||
chat = config[entry]['chat']
|
chat = config[entry]['chat']
|
||||||
token = config[entry]['token']
|
token = config[entry]['token']
|
||||||
except:
|
except:
|
||||||
print('CHAT or TOKEN not provided!')
|
print('CHAT or TOKEN not provided!')
|
||||||
continue
|
continue
|
||||||
data = {'Title': encoded_title, 'message': msg, 'priority': '5'}
|
cmd = f"./telegram.sh -t {token} -c {chat} -T {encoded_title} -M \"{msg}\""
|
||||||
try:
|
try:
|
||||||
req.post(f"{url}/message?token={token}", data)
|
subprocess.run(cmd, shell=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Failed!' + str(e))
|
print('Failed!' + str(e))
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ from Cleanup import *
|
||||||
# TODO: Run post_script (preferably in any language)
|
# TODO: Run post_script (preferably in any language)
|
||||||
# TODO: README
|
# TODO: README
|
||||||
# TODO: PATCHES_GUIDE.md (maybe delete it?)
|
# TODO: PATCHES_GUIDE.md (maybe delete it?)
|
||||||
|
# TODO: Make it PIP installable
|
||||||
|
|
||||||
# Update the ReVanced tools, if needed
|
# Update the ReVanced tools, if needed
|
||||||
def update_tools(appstate):
|
def update_tools(appstate):
|
||||||
|
@ -70,6 +71,7 @@ def update_microg(appstate):
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
appstate['present_vers'].update({'VancedMicroG': str(latest_ver)})
|
appstate['present_vers'].update({'VancedMicroG': str(latest_ver)})
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
appstate['microg_updated'] = True
|
||||||
|
|
||||||
return appstate
|
return appstate
|
||||||
|
|
||||||
|
@ -100,6 +102,7 @@ except:
|
||||||
flag = None
|
flag = None
|
||||||
|
|
||||||
appstate['flag'] = flag
|
appstate['flag'] = flag
|
||||||
|
appstate['microg_updated'] = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
appstate['build_config']=cp.ConfigParser()
|
appstate['build_config']=cp.ConfigParser()
|
||||||
|
|
Loading…
Reference in a new issue