From 4c31332e23ed49fe9748d97c5a81b3097836aabc Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Wed, 8 Sep 2021 20:19:24 +0000 Subject: [PATCH] Add use_ssl option This change enables using the statusbot with a non ssl server. Change-Id: I4e79625316ebaa391941743bfd1a2ea29e14df09 --- statusbot/bot.py | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/statusbot/bot.py b/statusbot/bot.py index 6801083..58e40fc 100755 --- a/statusbot/bot.py +++ b/statusbot/bot.py @@ -354,7 +354,7 @@ class AlertFile(UpdateInterface): self.write(None) -class BaseStatusBot(SSL, irc.bot.SingleServerIRCBot): +class BaseStatusBot(irc.bot.SingleServerIRCBot): log = logging.getLogger("statusbot.bot") def on_pubmsg(self, c, e): @@ -556,20 +556,29 @@ def _main(configpath): else: use_sasl = False if use_sasl: - bot = SASLStatusBot(channels, nicks, publishers, successlog, - thankslog, - config.get('ircbot', 'nick'), - config.get('ircbot', 'pass'), - config.get('ircbot', 'server'), - config.getint('ircbot', 'port')) + base = SASLStatusBot else: - bot = NoSASLStatusBot(channels, nicks, publishers, successlog, - thankslog, - config.get('ircbot', 'nick'), - config.get('ircbot', 'pass'), - config.get('ircbot', 'server'), - config.getint('ircbot', 'port')) - bot.start() + base = NoSASLStatusBot + + if config.has_option('ircbot', 'use_ssl'): + use_ssl = config.getboolean('ircbot', 'use_ssl') + else: + use_ssl = False + + # SSL is set through class inheritance. + if use_ssl: + class Bot(base, SSL): + pass + else: + class Bot(base): + pass + + Bot(channels, nicks, publishers, successlog, + thankslog, + config.get('ircbot', 'nick'), + config.get('ircbot', 'pass'), + config.get('ircbot', 'server'), + config.getint('ircbot', 'port')).start() def main():