How to use the pmxbot.core.command 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 / tests / functional / plugins / pmxbot_test_commands.py View on Github external
@core.command("crashnow")
def crash_immediately():
    "Crash now!"
    raise TypeError("You should never call this!")
github yougov / pmxbot / pmxbot / commands.py View on Github external
@command(aliases="dm")
def demotivate(channel, rest):
    "Demotivate someone"
    if rest:
        r = rest.strip()
    else:
        r = channel
    karma.Karma.store.change(r, -1)
    return "you're doing horrible work, %s!" % r
github yougov / pmxbot / pmxbot / commands.py View on Github external
@command(aliases=("slap", "ts"))
def troutslap(rest):
    "Slap some(one|thing) with a fish"
    slapee = rest
    karma.Karma.store.change(slapee, -1)
    return "/me slaps %s around a bit with a large trout" % slapee
github yougov / pmxbot / pmxbot / commands.py View on Github external
@command(aliases=("urb", 'ud', 'urbandictionary', 'urbandefine', 'urbandef', 'urbdef'))
def urbandict(rest):
    "Define a word with Urban Dictionary"
    word = rest.strip()
    definition = util.urban_lookup(word)
    if not definition:
        return "Arg!  I didn't find a definition for that."
    return 'Urban Dictionary says {word}: {definition}'.format(**locals())
github yougov / pmxbot / pmxbot / commands.py View on Github external
@command()
def insult(rest):
    "Generate a random insult from datahamster"
    # not supplying any style will automatically redirect to a random
    url = 'http://autoinsult.datahamster.com/'
    ins_type = random.randrange(4)
    ins_url = url + "?style={ins_type}".format(**locals())
    insre = re.compile('<div id="insult" class="insult">(.*?)</div>')
    resp = requests.get(ins_url)
    resp.raise_for_status()
    insult = insre.search(resp.text).group(1)
    if not insult:
        return
    if rest:
        insultee = rest.strip()
        karma.Karma.store.change(insultee, -1)
        if ins_type in (0, 2):
github yougov / pmxbot / pmxbot / commands.py View on Github external
@command()
def blame(channel, rest, nick):
    "Pass the buck!"
    if rest:
        blamee = rest
    else:
        blamee = channel
    karma.Karma.store.change(nick, -1)
    if random.randint(1, 10) == 1:
        yield "/me jumps atop the chair and points back at %s." % nick
        yield (
            "stop blaming the world for your problems, you bitter, "
            "two-faced sissified monkey!"
        )
    else:
        yield (
            "I blame %s for everything!  it's your fault!  "
github yougov / pmxbot / pmxbot / karma.py View on Github external
@command(aliases=("bottom",))
def bottom10(rest):
    """
    Return the bottom n (default 10) lowest entities by Karmic value.
    Use negative numbers for the bottom N.
    """
    if rest:
        topn = -int(rest)
    else:
        topn = -10
    selection = Karma.store.list(topn)
    res = ' '.join('(%s: %s)' % (', '.join(n), k) for n, k in selection)
    return res
github yougov / pmxbot / pmxbot / commands.py View on Github external
@command()
def fml(rest):
    "A SFW version of fml."
    return "indeed"
github yougov / pmxbot / pmxbot / commands.py View on Github external
@command()
def calc(rest):
    "Perform a basic calculation"
    mo = calc_exp.match(rest)
    if mo:
        try:
            return str(eval(rest))
        except Exception:
            return "eval failed... check your syntax"
    else:
        return "misformatted arithmetic!"