Skip to content

Commit

Permalink
Added reminder about supporting authors
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed May 13, 2023
1 parent e6b40e9 commit b1b5b62
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gzip
import glob
import json
import random
import shutil
import zipfile
import requests
Expand Down Expand Up @@ -164,6 +165,7 @@ def start(self):
if self.headless:
sys.exit(0)
else:
self.print_author_reminder()
self.console.print('Press [bold]I[/bold] to enter interactive mode or any other button to close'
' the application.')
keypress = self.handle_keypress(0)
Expand Down Expand Up @@ -263,7 +265,8 @@ def auto_update(self):
def motd_parser(self):
payload = requests.get('https://storage.googleapis.com/cursebreaker/motd', headers=HEADERS, timeout=5)
if payload.status_code == 200:
self.console.print(Panel(payload.content.decode('UTF-8'), title='MOTD', border_style='red'))
self.console.print(Panel(payload.content.decode('UTF-8'), title=':warning: MOTD :warning:',
border_style='red'))
self.console.print('')

def handle_exception(self, e, table=True):
Expand Down Expand Up @@ -317,6 +320,23 @@ def print_log(self):
with open('CurseBreaker.html', 'a+', encoding='utf-8') as log:
log.write(html)

def print_author_reminder(self):
if random.randint(1, 10) == 1:
addon = random.choice(self.core.config['Addons'])
project_url = addon['URL']
if not project_url.startswith('https://'):
custom_project_url = {'elvui': 'https://www.tukui.org/support.php',
'elvui:dev': 'https://www.tukui.org/support.php',
'tukui': 'https://www.tukui.org/support.php',
'tukui:dev': 'https://www.tukui.org/support.php',
'shadow&light:dev': 'https://addons.wago.io/addons/shadow-and-light'}
project_url = custom_project_url[addon['URL'].lower()]
self.console.print(Panel(f'Hey! You use [bold white]{addon["Name"]}[/bold white] quite often. Maybe it\'s t'
f'ime to check out the project page how you can support the author(s)? [link='
f'{project_url}]{project_url}[/link]', title=':sparkles: Support :sparkles:',
border_style='yellow'))
self.console.print('')

def setup_console(self):
if self.headless:
self.console = Console(record=True)
Expand Down

0 comments on commit b1b5b62

Please sign in to comment.