How to use the pmxbot.config.get function in pmxbot

To help you get started, we’ve selected a few pmxbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yougov / pmxbot / pmxbot / logging.py View on Github external
def logs(channel):
    "Where can one find the logs?"
    default_url = 'http://' + socket.getfqdn()
    base = pmxbot.config.get('logs URL', default_url)
    logged_channel = channel in pmxbot.config.log_channels
    path = '/channel/' + channel.lstrip('#') if logged_channel else '/'
    return urllib.parse.urljoin(base, path)
github yougov / pmxbot / pmxbot / core.py View on Github external
def _load_bot_class():
    default = 'pmxbot.irc:LoggingCommandBot'
    if 'slack token' in pmxbot.config:
        default = 'pmxbot.slack:Bot'
    class_spec = pmxbot.config.get('bot class', default)
    mod_name, sep, name = class_spec.partition(':')
    module = importlib.import_module(mod_name)
    return eval(name, vars(module))
github yougov / pmxbot / pmxbot / irc.py View on Github external
def warn(self, nick, connection):
        if pmxbot.config.get('privacy warning') == 'suppress':
            return
        if not self.needs_warning(nick):
            return
        logged_channels_string = ', '.join(pmxbot.config.log_channels)
        msg = self.warn_message.format(**locals())
        for line in msg.splitlines():
            connection.notice(nick, line)
github yougov / pmxbot / pmxbot / storage.py View on Github external
def _get_collection(cls, uri):
        importlib.import_module('pymongo')
        client_params = pmxbot.config.get('database params', {})
        client = pymongo.MongoClient(uri, **client_params)
        uri_p = pymongo.uri_parser.parse_uri(uri)
        db_name = uri_p['database'] or 'pmxbot'
        return client[db_name][cls.collection_name]
github yougov / pmxbot / pmxbot / commands.py View on Github external
'panic',
        'rubberstamp',
        'dance',
        'annoy',
        'klingon',
        'storytime',
        'murphy',
        'quote',
    ]

    def lookup_command(cmd_name):
        msg = '!' + cmd_name + ' '
        res = pmxbot.core.CommandHandler.find_matching(msg, channel=None)
        return next(res).func

    functions = pmxbot.config.get('random commands', default_commands)
    exclude_nick_functions = ('quote',)
    chosen = random.choice(functions)
    func = lookup_command(chosen)

    # Only use the relevant nick as the target in some cases
    rest = nick if chosen not in exclude_nick_functions else ''
    nick = 'pmxbot'

    # save the func for troubleshooting
    rand_bot.last_func = func

    return attach(func, locals())()
github yougov / pmxbot / pmxbot / channels.py View on Github external
def _compat_load(self):
		"""
		Older versions of pmxbot would store config in 'log_channels' and
		'other_channels'. Support those keys.
		"""
		if self.items:
			return

		legacy_values = pmxbot.config.get('log_channels', [])
		if self.aspect == 'member':
			legacy_values += pmxbot.config.get('other_channels', [])
		self[:] = legacy_values
github yougov / pmxbot / pmxbot / irc.py View on Github external
def on_welcome(self, connection, event):
        # save the connection object so .out has something to call
        self._conn = connection
        if pmxbot.config.get('nickserv_password'):
            msg = 'identify %s' % pmxbot.config.nickserv_password
            connection.privmsg('NickServ', msg)

        # join channels
        for channel in self._channels:
            if not channel.startswith('#'):
                channel = '#' + channel
            connection.join(channel)

        self.init_schedule(self.reactor.scheduler)

        self._set_keepalive(connection)
github yougov / pmxbot / pmxbot / channels.py View on Github external
def _compat_load(self):
		"""
		Older versions of pmxbot would store config in 'log_channels' and
		'other_channels'. Support those keys.
		"""
		if self.items:
			return

		legacy_values = pmxbot.config.get('log_channels', [])
		if self.aspect == 'member':
			legacy_values += pmxbot.config.get('other_channels', [])
		self[:] = legacy_values