Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.reactor.process_once(0.1)
self.channels = set()
def join(self, channel):
self.c.join(channel)
self.channels.add(channel)
def send_message(self, channel, message):
if channel not in self.channels:
self.join(channel)
self.c.privmsg(channel, message)
time.sleep(0.05)
class PmxbotHarness:
config = pmxbot.dictlib.ConfigDict(
server_port=6668,
bot_nickname='pmxbotTest',
log_channels=['#logged'],
other_channels=['#inane'],
database="sqlite:tests/functional/pmxbot.sqlite",
)
@classmethod
def setup_class(cls):
"""Start an IRC server, launch the bot, and ask it to do stuff"""
path = os.path.dirname(os.path.abspath(__file__))
cls.config_fn = os.path.join(path, 'testconf.yaml')
cls.config.to_yaml(cls.config_fn)
cls.dbfile = urllib.parse.urlparse(cls.config['database']).path
cls.db = sqlite3.connect(cls.dbfile)
env = os.environ.copy()
def setup_class(cls):
path = os.path.dirname(os.path.abspath(__file__))
configfile = os.path.join(path, 'testconf.yaml')
config = pmxbot.dictlib.ConfigDict.from_yaml(configfile)
cls.bot = core.initialize(config)
logging.Logger.store.message("logged", "testrunner", "some text")
# vim:ts=4:sw=4:noexpandtab
from .dictlib import ConfigDict
config = ConfigDict(
bot_nickname='pmxbot',
server_host='localhost',
server_port=6667,
use_ssl=False,
password=None,
nickserv_password=None,
silent_bot=False,
log_channels=[],
other_channels=[],
)
"The config object"
def init_config(overrides):
"""
Install the config dict as pmxbot.config, setting overrides,
and return the result.
"""
pmxbot.config = config = ConfigDict()
config.setdefault('bot_nickname', 'pmxbot')
config.update(overrides)
return config
def get_args(*args, **kwargs):
parser = argparse.ArgumentParser()
parser.add_argument(
'config',
type=pmxbot.dictlib.ConfigDict.from_yaml,
nargs='*',
action=ConfigMergeAction,
)
return parser.parse_args(*args, **kwargs)
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument('config', type=dictlib.ConfigDict.from_yaml)
return parser.parse_args()