def main(): pool = pydle.ClientPool() try: config = yaml.safe_load(open('config.yaml', 'r')) logging.basicConfig(level=config['loglevel']) load_badwords(config['badwords']) for server in config['servers']: client = Scooter(config['servers'][server]) pool.connect(client, server, config['servers'][server]['port'], tls=True) except yaml.YAMLError as e: logging.exception("Error in configuration file: " + str(e)) pool.handle_forever()
"""Is called when recieved whoisactually.""" pass dbs: List[Connection] = [] # list of dbs for closing restarted = False # global, typed in stop bot = Bot() # global typed in rawmsg try: server_configs: Dict[str, Any] = bot.config['servers'] except KeyError: print('No servers in config') sys.exit(0) pool: pydle.client.ClientPool = pydle.ClientPool() # type: ignore for server_name in bot.config['servers']: server: Dict[str, Any] = bot.config['servers'][server_name] if server: client: Client = Client(server['nick']) else: print('Invalid server config.') sys.exit(0) bot.clients.append(client) pool.connect(client, server['server'], tls=True, tls_verify=False) try: pool.handle_forever() except KeyboardInterrupt: print('Disconnecting clients.')
logger = logging.getLogger('musicConversations') logger.setLevel(logging.DEBUG) logger.propagate = False fh = logging.handlers.TimedRotatingFileHandler('debug.log', when='midnight', encoding='utf-8') fh.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.INFO) fh.setFormatter(formatter) ch.setFormatter(formatter) logger.addHandler(fh) logger.addHandler(ch) pool = pydle.ClientPool() current_milli_time = lambda: int(round(time.time() * 1000)) logger.info("Loading up....") channelname = None logins = None inputfile = None sentences = None messagechance = None messagetiming = None # read config values from file (db login etc) try: f = open("musicconversations.cfg", "r", encoding="utf-8") lines = f.readlines()