Merge branch 'develop' into feature/encrypt

This commit is contained in:
Luke Rogers 2013-10-01 15:49:38 +13:00
commit b5ae12f50b
8 changed files with 32 additions and 27 deletions

View File

@ -13,29 +13,34 @@ class Input(dict):
if chan == conn.nick.lower(): # is a PM if chan == conn.nick.lower(): # is a PM
chan = nick chan = nick
def say(msg, chan=chan): def say(msg):
"""sends a message to the current channel/user"""
conn.msg(chan, msg) 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) conn.msg(nick, msg)
def reply(msg, chan=chan): def reply(msg, chan=chan):
"""sends a message to the current channel/user with a prefix"""
if chan == nick: # PMs don't need prefixes if chan == nick: # PMs don't need prefixes
conn.msg(chan, msg) conn.msg(chan, msg)
else: else:
conn.msg(chan, u'(' + nick + u') ' + msg) 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)) conn.msg(chan, u"\x01{} {}\x01".format("ACTION", msg))
def notice(msg, nick=nick): def notice(msg, chan=chan):
conn.cmd('NOTICE', [nick, msg]) """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, dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command,
params=params, nick=nick, user=user, host=host, mask=mask, params=params, nick=nick, user=user, host=host, mask=mask,
paraml=paraml, msg=msg, server=conn.server, chan=chan, paraml=paraml, msg=msg, server=conn.server, chan=chan,
notice=notice, say=say, reply=reply, pm=pm, bot=bot, notice=notice, say=say, reply=reply, msg=msg, bot=bot,
me=me, lastparam=paraml[-1]) action=action, lastparam=paraml[-1])
# make dict keys accessible as attributes # make dict keys accessible as attributes
def __getattr__(self, key): def __getattr__(self, key):

View File

@ -14,7 +14,7 @@ with open("plugins/data/flirts.txt") as f:
if not line.startswith("//")] if not line.startswith("//")]
@hook.command @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>.""" """lart <user> -- LARTs <user>."""
target = inp.strip() target = inp.strip()
@ -30,11 +30,11 @@ def lart(inp, me=None, nick=None, conn=None, notice=None):
phrase = random.choice(larts) phrase = random.choice(larts)
# act out the message # act out the message
me(phrase.format(**values)) action(phrase.format(**values))
@hook.command @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>.""" """insult <user> -- Makes the bot insult <user>."""
target = inp.strip() target = inp.strip()
@ -48,11 +48,11 @@ def insult(inp, nick=None, me=None, conn=None, notice=None):
target = inp target = inp
out = 'insults {}... "{}"'.format(target, random.choice(insults)) out = 'insults {}... "{}"'.format(target, random.choice(insults))
me(out) action(out)
@hook.command @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>.""" """flirt <user> -- Make the bot flirt with <user>."""
target = inp.strip() target = inp.strip()
@ -66,4 +66,4 @@ def flirt(inp, me=None, conn=None, notice=None):
target = inp target = inp
out = 'flirts with {}... "{}"'.format(target, random.choice(flirts)) out = 'flirts with {}... "{}"'.format(target, random.choice(flirts))
me(out) action(out)

View File

@ -3,7 +3,7 @@ import random
@hook.command(autohelp=False) @hook.command(autohelp=False)
def coin(inp, me=None): def coin(inp, action=None):
"""coin [amount] -- Flips [amount] of coins.""" """coin [amount] -- Flips [amount] of coins."""
if inp: if inp:
@ -15,10 +15,10 @@ def coin(inp, me=None):
amount = 1 amount = 1
if 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: elif amount == 0:
me("makes a coin flipping motion with its hands.") action("makes a coin flipping motion with its hands.")
else: else:
heads = int(random.normalvariate(.5 * amount, (.75 * amount) ** .5)) heads = int(random.normalvariate(.5 * amount, (.75 * amount) ** .5))
tails = amount - heads 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))

View File

@ -13,9 +13,9 @@ with open("plugins/data/8ball_responses.txt") as f:
@hook.command('8ball') @hook.command('8ball')
def eightball(input, me=None): def eightball(input, action=None):
"""8ball <question> -- The all knowing magic eight ball, """8ball <question> -- The all knowing magic eight ball,
in electronic form. Ask and it shall be answered!""" in electronic form. Ask and it shall be answered!"""
magic = text.multiword_replace(random.choice(responses), color_codes) 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))

View File

@ -105,7 +105,7 @@ def info(inp, notice=None, db=None):
@hook.regex(r'^\? ?(.+)') @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>." "?<word> -- Shows what data is associated with <word>."
try: try:
prefix_on = bot.config["plugins"]["factoids"].get("prefix", False) 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>"): if result.startswith("<act>"):
result = result[5:].strip() result = result[5:].strip()
me(result) action(result)
elif result.startswith("<url>"): elif result.startswith("<url>"):
url = result[5:].strip() url = result[5:].strip()
try: try:

View File

@ -9,7 +9,7 @@ def get_generator(_json, variables):
@hook.command @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>.""" """kill <user> -- Makes the bot kill <user>."""
target = inp.strip() target = inp.strip()
@ -29,4 +29,4 @@ def kill(inp, me=None, nick=None, conn=None, notice=None):
generator = get_generator(f.read(), variables) generator = get_generator(f.read(), variables)
# act out the message # act out the message
me(generator.generate_string()) action(generator.generate_string())

View File

@ -37,7 +37,7 @@ potatoes = ['AC Belmont', 'AC Blue Pride', 'AC Brador', 'AC Chaleur', 'AC Domino
@hook.command @hook.command
def potato(inp, me=None, input=None): def potato(inp, action=None, input=None):
"""potato <user> - Makes <user> a tasty little potato.""" """potato <user> - Makes <user> a tasty little potato."""
inp = inp.strip() inp = inp.strip()
@ -50,5 +50,5 @@ def potato(inp, me=None, input=None):
method = random.choice(['bakes', 'fries', 'boils', 'roasts']) method = random.choice(['bakes', 'fries', 'boils', 'roasts'])
side_dish = random.choice(['side salad', 'dollop of sour cream', 'piece of chicken', 'bowl of shredded bacon']) 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)) side_dish))

View File

@ -9,7 +9,7 @@ def get_generator(_json, variables):
@hook.command @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>.""" """slap <user> -- Makes the bot slap <user>."""
target = inp.strip() target = inp.strip()
@ -29,4 +29,4 @@ def slap(inp, me=None, nick=None, conn=None, notice=None):
generator = get_generator(f.read(), variables) generator = get_generator(f.read(), variables)
# act out the message # act out the message
me(generator.generate_string()) action(generator.generate_string())