allow custom prefix in message

This commit is contained in:
mcinj 2022-05-10 13:03:34 -04:00
parent 1d6d5da86e
commit ca3425e964
4 changed files with 6 additions and 3 deletions

View file

@ -22,6 +22,8 @@ wishlist.max_entries = 10000
# time left in minutes of a giveaway for it to be considered # time left in minutes of a giveaway for it to be considered
wishlist.max_time_left = 300 wishlist.max_time_left = 300
[NOTIFICATIONS] [NOTIFICATIONS]
# a prefix for messages sent via notifications
notification.prefix = SG-Bot
# if we should send notifications via pushover # if we should send notifications via pushover
pushover.enabled = false pushover.enabled = false
# your specific pushover token # your specific pushover token

View file

@ -48,6 +48,7 @@ class ConfigReader(ConfigParser):
'wishlist.max_time_left': f"{randint(180,500)}" 'wishlist.max_time_left': f"{randint(180,500)}"
}, },
'NOTIFICATIONS': { 'NOTIFICATIONS': {
'notification.prefix': '',
'pushover.enabled': 'false', 'pushover.enabled': 'false',
'pushover.token': '', 'pushover.token': '',
'pushover.user_key': '', 'pushover.user_key': '',

View file

@ -11,11 +11,11 @@ logger = log.get_logger(__name__)
class Notification: class Notification:
def __init__(self): def __init__(self, message_prefix):
self.pushover = False self.pushover = False
self.pushover_token = None self.pushover_token = None
self.pushover_user_key = None self.pushover_user_key = None
self.message_prefix = "SG-bot: " self.message_prefix = f"{message_prefix}: "
def send_won(self, message): def send_won(self, message):
self.__send('won', message) self.__send('won', message)

View file

@ -25,7 +25,7 @@ def run():
config.read(file_name) config.read(file_name)
notification = Notification() notification = Notification(config['NOTIFICATIONS'].get('notification.prefix'))
pushover_enabled = config['NOTIFICATIONS'].getboolean('pushover.enabled') pushover_enabled = config['NOTIFICATIONS'].getboolean('pushover.enabled')
pushover_token = config['NOTIFICATIONS'].get('pushover.token') pushover_token = config['NOTIFICATIONS'].get('pushover.token')
pushover_user_key = config['NOTIFICATIONS'].get('pushover.user_key') pushover_user_key = config['NOTIFICATIONS'].get('pushover.user_key')