Merge branch 'develop' into feature/encrypt
This commit is contained in:
commit
b5ae12f50b
19
core/main.py
19
core/main.py
|
@ -13,29 +13,34 @@ class Input(dict):
|
|||
if chan == conn.nick.lower(): # is a PM
|
||||
chan = nick
|
||||
|
||||
def say(msg, chan=chan):
|
||||
def say(msg):
|
||||
"""sends a message to the current channel/user"""
|
||||
conn.msg(chan, msg)
|
||||
|
||||
def pm(msg, nick=nick):
|
||||
def msg(msg, nick=nick):
|
||||
"""sends a message to a specific channel/user"""
|
||||
conn.msg(nick, msg)
|
||||
|
||||
def reply(msg, chan=chan):
|
||||
"""sends a message to the current channel/user with a prefix"""
|
||||
if chan == nick: # PMs don't need prefixes
|
||||
conn.msg(chan, msg)
|
||||
else:
|
||||
conn.msg(chan, u'(' + nick + u') ' + msg)
|
||||
|
||||
def me(msg, chan=chan):
|
||||
def action(msg, chan=chan):
|
||||
"""sends an action to the current channel/user or a specific channel/user"""
|
||||
conn.msg(chan, u"\x01{} {}\x01".format("ACTION", msg))
|
||||
|
||||
def notice(msg, nick=nick):
|
||||
conn.cmd('NOTICE', [nick, msg])
|
||||
def notice(msg, chan=chan):
|
||||
"""sends a notice to the current channel/user or a specific channel/user"""
|
||||
conn.cmd('NOTICE', [chan, msg])
|
||||
|
||||
dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command,
|
||||
params=params, nick=nick, user=user, host=host, mask=mask,
|
||||
paraml=paraml, msg=msg, server=conn.server, chan=chan,
|
||||
notice=notice, say=say, reply=reply, pm=pm, bot=bot,
|
||||
me=me, lastparam=paraml[-1])
|
||||
notice=notice, say=say, reply=reply, msg=msg, bot=bot,
|
||||
action=action, lastparam=paraml[-1])
|
||||
|
||||
# make dict keys accessible as attributes
|
||||
def __getattr__(self, key):
|
||||
|
|
|
@ -14,7 +14,7 @@ with open("plugins/data/flirts.txt") as f:
|
|||
if not line.startswith("//")]
|
||||
|
||||
@hook.command
|
||||
def lart(inp, me=None, nick=None, conn=None, notice=None):
|
||||
def lart(inp, action=None, nick=None, conn=None, notice=None):
|
||||
"""lart <user> -- LARTs <user>."""
|
||||
target = inp.strip()
|
||||
|
||||
|
@ -30,11 +30,11 @@ def lart(inp, me=None, nick=None, conn=None, notice=None):
|
|||
phrase = random.choice(larts)
|
||||
|
||||
# act out the message
|
||||
me(phrase.format(**values))
|
||||
action(phrase.format(**values))
|
||||
|
||||
|
||||
@hook.command
|
||||
def insult(inp, nick=None, me=None, conn=None, notice=None):
|
||||
def insult(inp, nick=None, action=None, conn=None, notice=None):
|
||||
"""insult <user> -- Makes the bot insult <user>."""
|
||||
target = inp.strip()
|
||||
|
||||
|
@ -48,11 +48,11 @@ def insult(inp, nick=None, me=None, conn=None, notice=None):
|
|||
target = inp
|
||||
|
||||
out = 'insults {}... "{}"'.format(target, random.choice(insults))
|
||||
me(out)
|
||||
action(out)
|
||||
|
||||
|
||||
@hook.command
|
||||
def flirt(inp, me=None, conn=None, notice=None):
|
||||
def flirt(inp, action=None, conn=None, notice=None):
|
||||
"""flirt <user> -- Make the bot flirt with <user>."""
|
||||
target = inp.strip()
|
||||
|
||||
|
@ -66,4 +66,4 @@ def flirt(inp, me=None, conn=None, notice=None):
|
|||
target = inp
|
||||
|
||||
out = 'flirts with {}... "{}"'.format(target, random.choice(flirts))
|
||||
me(out)
|
||||
action(out)
|
||||
|
|
|
@ -3,7 +3,7 @@ import random
|
|||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def coin(inp, me=None):
|
||||
def coin(inp, action=None):
|
||||
"""coin [amount] -- Flips [amount] of coins."""
|
||||
|
||||
if inp:
|
||||
|
@ -15,10 +15,10 @@ def coin(inp, me=None):
|
|||
amount = 1
|
||||
|
||||
if amount == 1:
|
||||
me("flips a coin and gets {}.".format(random.choice(["heads", "tails"])))
|
||||
action("flips a coin and gets {}.".format(random.choice(["heads", "tails"])))
|
||||
elif amount == 0:
|
||||
me("makes a coin flipping motion with its hands.")
|
||||
action("makes a coin flipping motion with its hands.")
|
||||
else:
|
||||
heads = int(random.normalvariate(.5 * amount, (.75 * amount) ** .5))
|
||||
tails = amount - heads
|
||||
me("flips {} coins and gets {} heads and {} tails.".format(amount, heads, tails))
|
||||
action("flips {} coins and gets {} heads and {} tails.".format(amount, heads, tails))
|
||||
|
|
|
@ -13,9 +13,9 @@ with open("plugins/data/8ball_responses.txt") as f:
|
|||
|
||||
|
||||
@hook.command('8ball')
|
||||
def eightball(input, me=None):
|
||||
def eightball(input, action=None):
|
||||
"""8ball <question> -- The all knowing magic eight ball,
|
||||
in electronic form. Ask and it shall be answered!"""
|
||||
|
||||
magic = text.multiword_replace(random.choice(responses), color_codes)
|
||||
me("shakes the magic 8 ball... {}".format(magic))
|
||||
action("shakes the magic 8 ball... {}".format(magic))
|
||||
|
|
|
@ -105,7 +105,7 @@ def info(inp, notice=None, db=None):
|
|||
|
||||
|
||||
@hook.regex(r'^\? ?(.+)')
|
||||
def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
||||
def factoid(inp, say=None, db=None, bot=None, action=None, conn=None, input=None):
|
||||
"?<word> -- Shows what data is associated with <word>."
|
||||
try:
|
||||
prefix_on = bot.config["plugins"]["factoids"].get("prefix", False)
|
||||
|
@ -141,7 +141,7 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
|||
|
||||
if result.startswith("<act>"):
|
||||
result = result[5:].strip()
|
||||
me(result)
|
||||
action(result)
|
||||
elif result.startswith("<url>"):
|
||||
url = result[5:].strip()
|
||||
try:
|
||||
|
|
|
@ -9,7 +9,7 @@ def get_generator(_json, variables):
|
|||
|
||||
|
||||
@hook.command
|
||||
def kill(inp, me=None, nick=None, conn=None, notice=None):
|
||||
def kill(inp, action=None, nick=None, conn=None, notice=None):
|
||||
"""kill <user> -- Makes the bot kill <user>."""
|
||||
target = inp.strip()
|
||||
|
||||
|
@ -29,4 +29,4 @@ def kill(inp, me=None, nick=None, conn=None, notice=None):
|
|||
generator = get_generator(f.read(), variables)
|
||||
|
||||
# act out the message
|
||||
me(generator.generate_string())
|
||||
action(generator.generate_string())
|
|
@ -37,7 +37,7 @@ potatoes = ['AC Belmont', 'AC Blue Pride', 'AC Brador', 'AC Chaleur', 'AC Domino
|
|||
|
||||
|
||||
@hook.command
|
||||
def potato(inp, me=None, input=None):
|
||||
def potato(inp, action=None, input=None):
|
||||
"""potato <user> - Makes <user> a tasty little potato."""
|
||||
inp = inp.strip()
|
||||
|
||||
|
@ -50,5 +50,5 @@ def potato(inp, me=None, input=None):
|
|||
method = random.choice(['bakes', 'fries', 'boils', 'roasts'])
|
||||
side_dish = random.choice(['side salad', 'dollop of sour cream', 'piece of chicken', 'bowl of shredded bacon'])
|
||||
|
||||
me("{} a {} {} {} potato for {} and serves it with a small {}!".format(method, flavor, size, potato_type, inp,
|
||||
action("{} a {} {} {} potato for {} and serves it with a small {}!".format(method, flavor, size, potato_type, inp,
|
||||
side_dish))
|
||||
|
|
|
@ -9,7 +9,7 @@ def get_generator(_json, variables):
|
|||
|
||||
|
||||
@hook.command
|
||||
def slap(inp, me=None, nick=None, conn=None, notice=None):
|
||||
def slap(inp, action=None, nick=None, conn=None, notice=None):
|
||||
"""slap <user> -- Makes the bot slap <user>."""
|
||||
target = inp.strip()
|
||||
|
||||
|
@ -29,4 +29,4 @@ def slap(inp, me=None, nick=None, conn=None, notice=None):
|
|||
generator = get_generator(f.read(), variables)
|
||||
|
||||
# act out the message
|
||||
me(generator.generate_string())
|
||||
action(generator.generate_string())
|
Reference in New Issue