# Nemubot is a smart and modulable IM bot. # Copyright (C) 2012-2016 Mercier Pierre-Olivier # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . from typing import Optional, Sequence, Union import nemubot.config.include import nemubot.config.module import nemubot.config.server class Nemubot: def __init__(self, nick: str = "nemubot", realname: str = "nemubot", owner: Optional[str] = None, ip: Optional[str] = None, ssl: bool = False, caps: Optional[Sequence[str]] = None, encoding: str = "utf-8"): self.nick = nick self.realname = realname self.owner = owner self.ip = ip self.caps = caps.split(" ") if caps is not None else [] self.encoding = encoding self.servers = [] self.modules = [] self.includes = [] def addChild(self, name: str, child: Union[nemubot.config.module.Module, nemubot.config.server.Server, nemubot.config.include.Include]): if name == "module" and isinstance(child, nemubot.config.module.Module): self.modules.append(child) return True elif name == "server" and isinstance(child, nemubot.config.server.Server): self.servers.append(child) return True elif name == "include" and isinstance(child, nemubot.config.include.Include): self.includes.append(child) return True