def explain_response(lrrbot, conn, event, respond_to, command): """ Command: !explain TOPIC Mod-Only: true Section: text Provide an explanation for a given topic. --command Command: !explain show Mod-Only: true Section: text Provide an explanation for the currently-live show. """ command = " ".join(command.split()) if command.lower() == "show": command = lrrbot.show_override or lrrbot.show if command is None and lrrbot.is_mod(event): conn.privmsg(respond_to, "Current show not set.") response_data = storage.data["explanations"].get(command.lower()) if not response_data: return if response_data["access"] == "sub": if not lrrbot.is_sub(event) and not lrrbot.is_mod(event): log.info("Refusing explain %s due to inadequate access" % command) return if response_data["access"] == "mod": if not lrrbot.is_mod(event): log.info("Refusing explain %s due to inadequate access" % command) return response = response_data['response'] if isinstance(response, (tuple, list)): response = random.choice(response) conn.privmsg(respond_to, response)
def modify_commands(commands): log.info("Setting commands to %r" % commands) storage.data["responses"] = { " ".join(k.lower().split()): v for k, v in commands.items() } storage.save() generate_hook()
def static_response(lrrbot, conn, event, respond_to, command): command = " ".join(command.split()) response_data = storage.data["responses"][command.lower()] if response_data["access"] == "sub": if not lrrbot.is_sub(event) and not lrrbot.is_mod(event): log.info("Refusing %s due to inadequate access" % command) return if response_data["access"] == "mod": if not lrrbot.is_mod(event): log.info("Refusing %s due to inadequate access" % command) return response = response_data["response"] if isinstance(response, (tuple, list)): response = random.choice(response) conn.privmsg(respond_to, response)
def static_response(lrrbot, conn, event, respond_to, command): command = " ".join(command.split()) response_data = storage.data["responses"][command.lower()] if response_data["access"] == "sub": if not lrrbot.is_sub(event) and not lrrbot.is_mod(event): log.info("Refusing %s due to inadequate access" % command) source = irc.client.NickMask(event.source) conn.privmsg(source.nick, "That is a sub-only command.") return if response_data["access"] == "mod": if not lrrbot.is_mod(event): log.info("Refusing %s due to inadequate access" % command) source = irc.client.NickMask(event.source) conn.privmsg(source.nick, "That is a mod-only command.") return response = response_data["response"] if isinstance(response, (tuple, list)): response = random.choice(response) conn.privmsg(respond_to, response.format(user=event.tags.get('display-name') or source.nick))
def explain_response(lrrbot, conn, event, respond_to, command): """ Command: !explain TOPIC Mod-Only: true Section: text Provide an explanation for a given topic. --command Command: !explain show Mod-Only: true Section: text Provide an explanation for the currently-live show. """ command = " ".join(command.split()) if command.lower() == "show": command = lrrbot.show_override or lrrbot.show if command is None and lrrbot.is_mod(event): conn.privmsg(respond_to, "Current show not set.") response_data = storage.data["explanations"].get(command.lower()) if not response_data: return if response_data["access"] == "sub": if not lrrbot.is_sub(event) and not lrrbot.is_mod(event): log.info("Refusing explain %s due to inadequate access" % command) source = irc.client.NickMask(event.source) conn.privmsg(source.nick, "That is a sub-only command.") return if response_data["access"] == "mod": if not lrrbot.is_mod(event): log.info("Refusing explain %s due to inadequate access" % command) source = irc.client.NickMask(event.source) conn.privmsg(source.nick, "That is a mod-only command.") return response = response_data['response'] if isinstance(response, (tuple, list)): response = random.choice(response) conn.privmsg(respond_to, response)
def modify_explanations(commands): log.info("Setting explanations to %r" % commands) storage.data["explanations"] = {k.lower(): v for k, v in commands.items()} storage.save()
#!/usr/bin/env python3 import logging from common import utils utils.init_logging("lrrbot") from lrrbot.main import bot, log import lrrbot.commands try: log.info("Bot startup") bot.start() except (KeyboardInterrupt, SystemExit): pass finally: log.info("Bot shutdown") logging.shutdown()
def modify_commands(commands): log.info("Setting commands to %r" % commands) storage.data["responses"] = {" ".join(k.lower().split()): v for k, v in commands.items()} storage.save() generate_hook()