def until(prefix, target, event, card): """ Roll in `event` until `card` is found and return a privmsg of the number of rolls necessary. """ try: n = event.roll_until(card) except ValueError: line = ("Onii-chan your fat, greasy fingers must've made a typo, {0} isn't in " 'the {1.formatted_title}!') line = line.format(paddb.name(card) or 'that monster', event) return cc.privmsg(target, line) if n: line = 'It took me {0} {1} of the {2.formatted_title} to roll {3}!' line = line.format( engine.number_to_words(n, threshold=100), engine.plural('roll', n), event, paddb.name(card) or 'that monster' ) else: line = "Sorry onii-chan, looks like you don't have enough stones for that." return cc.privmsg(target, line)
def until(prefix, target, event, card): """ Roll in `event` until `card` is found and return a privmsg of the number of rolls necessary. """ try: n = event.roll_until(card) except ValueError: line = ( "Onii-chan your fat, greasy fingers must've made a typo, {0} isn't in " 'the {1.formatted_title}!') line = line.format(paddb.name(card) or 'that monster', event) return cc.privmsg(target, line) if n: line = 'It took me {0} {1} of the {2.formatted_title} to roll {3}!' line = line.format(engine.number_to_words(n, threshold=100), engine.plural('roll', n), event, paddb.name(card) or 'that monster') else: line = "Sorry onii-chan, looks like you don't have enough stones for that." return cc.privmsg(target, line)
def compare(prefix, channel, message): try: _, id1, id2, *_ = message.split(maxsplit=3) except ValueError: return cc.privmsg(target, 'Onii-chan you baka! Use it like this: ".compare <id 1> <id 2>"') id1, id2 = int(id1), int(id2) return (cc.privmsg(channel, line) for line in statcomp(id1, id2))
def compare(prefix, channel, message): try: _, id1, id2, *_ = message.split(maxsplit=3) except ValueError: return cc.privmsg( target, 'Onii-chan you baka! Use it like this: ".compare <id 1> <id 2>"') id1, id2 = int(id1), int(id2) return (cc.privmsg(channel, line) for line in statcomp(id1, id2))
def usage(prefix, target): """ Return a generic usage message on error. """ line = '{0.nick} no baka! Use it like this: {1} [event [event ...]]' line = line.format(prefix, parser.format_usage()) return cc.privmsg(target, line)
def roll(prefix, target, event, hide=False, n=1): """Roll `n` times, yielding each result as an individual privmsg.""" for card_id in event.roll(n): card = paddb.lookup(card_id) line = fmt.roll(prefix.nick, event.formatted_title, card, hide) # line = "{0.nick}-nii's {1.formatted_title} roll: {2}!" # line = line.format(prefix, event, paddb.name(card) or 'some monster') yield cc.privmsg(target, line)
def identify(*args): """Identify nick and user with the server, send server password, and join channels.""" yield cc.identify(nickname='Sakubot', username='******') # wait for the welcome message to know we've successfully joined yield from sakubot.wait_for(RPL_WELCOME) password = os.environ.get('RIZON_BOT') yield cc.privmsg('nickserv', 'identify {0}'.format(password)) # wait for our password to be accepted so our vhost will show up yield from sakubot.wait_for('NOTICE', text=cc.operator.contains('password accepted')) yield cc.join('#sakubot', '#padg')
def chance(prefix, target, event, card, n=1): """ Calculate the percent chance of rolling `card` in `n` rolls of `event` and return a privmsg of the results. """ chance = event.chance(card, n=n) line = 'You have a {0} chance of rolling {1} in {2} {3} of the {4.formatted_title}.' line = line.format(percent(chance), paddb.name(card) or 'that monster', engine.number_to_words(n, threshold=100), engine.plural('roll', n), event) return cc.privmsg(target, line)
def chance(prefix, target, event, card, n=1): """ Calculate the percent chance of rolling `card` in `n` rolls of `event` and return a privmsg of the results. """ chance = event.chance(card, n=n) line = 'You have a {0} chance of rolling {1} in {2} {3} of the {4.formatted_title}.' line = line.format( percent(chance), paddb.name(card) or 'that monster', engine.number_to_words(n, threshold=100), engine.plural('roll', n), event ) return cc.privmsg(target, line)
def plugin(prefix, target, message): gid, token = valid_gallery(message) req = dict(method='gdata', gidlist=[[gid, token]], namespace=1) resp = requests.post(API, json=req) resp.encoding = 'UTF-8' doujin = resp.json()['gmetadata'][0] if 'error' in doujin: return None lines = [ '"{0[title]}" (★ {0[rating]})'.format(doujin), format_tags(doujin['tags'], skip=SKIPPED) ] return [cc.privmsg(target, line) for line in lines]
def sakuball(prefix, channel, message): return cc.privmsg(channel, message='{0}: {1}'.format(prefix.nick, random.choice(sakuballList)))
def belly(prefix, target, message): lewd = ['N-no..', 'S-stop..', "T-that's lewd necro-nii-sama..", "If that's what you like..", 'P-please stop, t-that tickles..'] return cc.privmsg(target, message=random.choice(lewd))
def sakuball(prefix, channel, message): line = "{0.nick}: {1}".format(prefix, random.choice(options)) return cc.privmsg(channel, line)
def sakuball(prefix, channel, message): line = '{0.nick}: {1}'.format(prefix, random.choice(options)) return cc.privmsg(channel, line)