~cedric/guardian

294da57117c92ec123e6cc4a51e3c2c1331aeccc — Cédric Bonhomme 3 years ago 8fc182e
chg: check that the IRC channel has been defined.
2 files changed, 4 insertions(+), 1 deletions(-)

M guardian/conf.py
M guardian/notification.py
M guardian/conf.py => guardian/conf.py +2 -1
@@ 12,7 12,8 @@ except Exception:
    pass  # config.read("guardian/config/conf.cfg.sample")


IRC_CHANNEL = config.get("irc", "channel", fallback="irc://irc.libera.chat/#testGuardian")
IRC_CHANNEL = config.get(
    "irc", "channel", fallback="")
IRKER_HOST = config.get("irc", "host", fallback="localhost")
IRKER_PORT = int(config.get("irc", "port", fallback=6659))


M guardian/notification.py => guardian/notification.py +2 -0
@@ 11,6 11,8 @@ from guardian import conf

def irker(message):
    """Send a JSON formatted message to an instance of irker."""
    if not conf.IRC_CHANNEL:
        raise "No IRC channel defined."
    data = {"to": conf.IRC_CHANNEL, "privmsg": message}
    try:
        s = socket.create_connection((conf.IRKER_HOST, conf.IRKER_PORT))