# -*- coding: utf-8 -*- import os import sys import json # noinspection PyPackageRequirements from dotenv import load_dotenv from irc3 import IrcBot # This is a development config for use with irc3s server CFG_DEV = { 'nick': 'nxy', 'autojoins': ['#dev'], 'host': 'localhost', 'port': 6667, 'ssl': False, 'raw': True, 'debug': True, 'verbose': True, 'irc3.plugins.command.masks': { '*!admin@127.0.0.1': 'all_permissions', '*': 'view', } } # TODO: ddg def main(cfg_file): # Load dotenv from file load_dotenv('.env') # Load config from json file with open(cfg_file, 'r') as fp: cfg = json.load(fp) # Apply dev config if env variable is set if bool(os.environ.get('DEV')): cfg.update(CFG_DEV) # If PASSWORD in env set it in config if 'PASSWORD' in os.environ: cfg['password'] = os.environ['PASSWORD'] # Start the bot with constructed config bot = IrcBot.from_config(cfg) bot.run() bot.mode(bot.nick, '+R') if __name__ == '__main__': main(sys.argv[1])