fix: match not supported before python 3.10

This commit is contained in:
Sayantan Santra 2023-08-10 22:30:12 -05:00
parent 7169cc79e2
commit 37b4d1e172
Signed by: SinTan1729
GPG key ID: EB3E68BFBA25C85F

View file

@ -44,53 +44,52 @@ def send_notif(appstate, error=False):
continue continue
encoded_title = '⚙⚙⚙ ReVanced Build ⚙⚙⚙'.encode('utf-8') encoded_title = '⚙⚙⚙ ReVanced Build ⚙⚙⚙'.encode('utf-8')
match entry: if entry == 'ntfy':
case 'ntfy': print('Sending notification through ntfy.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'] except:
except: print('URL or TOPIC not provided!')
print('URL or TOPIC not provided!') continue
continue headers = {'Icon': 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Revanced-logo-round.svg/240px-Revanced-logo-round.svg.png',
headers = {'Icon': 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Revanced-logo-round.svg/240px-Revanced-logo-round.svg.png', 'Title': encoded_title}
'Title': encoded_title} try:
try: req.post(f"{url}/{topic}", msg, headers=headers)
req.post(f"{url}/{topic}", msg, headers=headers) except Exception as e:
except Exception as e: print('Failed!' + str(e))
print('Failed!' + str(e))
case 'gotify': elif entry == 'gotify':
print('Sending notification through Gotify...') print('Sending notification through Gotify...')
try: try:
url = config[entry]['url'] url = config[entry]['url']
token = config[entry]['token'] token = config[entry]['token']
except: except:
print('URL or TOKEN not provided!') print('URL or TOKEN not provided!')
continue continue
data = {'Title': encoded_title, 'message': msg, 'priority': '5'} data = {'Title': encoded_title, 'message': msg, 'priority': '5'}
try: try:
req.post(f"{url}/message?token={token}", data) req.post(f"{url}/message?token={token}", data)
except Exception as e: except Exception as e:
print('Failed!' + str(e)) print('Failed!' + str(e))
case 'telegram': elif entry == 'telegram':
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
cmd = f"./telegram.sh -t {token} -c {chat} -T {encoded_title} -M \"{msg}\"" cmd = f"./telegram.sh -t {token} -c {chat} -T {encoded_title} -M \"{msg}\""
try: try:
with subprocess.Popen(cmd, shell=True, bufsize=0, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout as output: with subprocess.Popen(cmd, shell=True, bufsize=0, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout as output:
for line in output: for line in output:
line_utf = line.decode('utf-8').strip('\n') line_utf = line.decode('utf-8').strip('\n')
if line_utf: if line_utf:
print(line_utf) print(line_utf)
except Exception as e: except Exception as e:
clean_exit(f"Failed!\n{e}", appstate) clean_exit(f"Failed!\n{e}", appstate)
case _: else:
print('Don\'t know how to send notifications to ' + entry) print('Don\'t know how to send notifications to ' + entry)