예제 #1
0
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)
예제 #2
0
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()
예제 #3
0
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)
예제 #4
0
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))
예제 #5
0
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)
예제 #6
0
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()
예제 #7
0
#!/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()
예제 #8
0
파일: static.py 프로젝트: andreasots/lrrbot
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()
예제 #9
0
#!/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()
예제 #10
0
파일: explain.py 프로젝트: pyrige/lrrbot
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()