def flirt(m): """Flirts with the specified user or channel in general.""" #- !flirt [user ...] #- #- ```irc #- < GorillaWarfare> !flirt #- < GorillaBot> I'm a fermata... hold me. #- < GorillaWarfare> !flirt user #- < GorillaBot> user: If you were a booger I'd rearrange the alphabet so you fell from heaven! #- ``` #- #- Flirts at the user or the channel. match = re.match(r':!(?:\w+) ?(\w+)?(?: and | |, )?((?!and)\w+)?(?:,? and |, | )?((?!and)\w+)?', m.body) users = [x for x in match.groups() if x] if match else [] if users == []: m.bot.private_message(m.location, get_line(m, "flirt.txt")) else: bot_nick = m.bot.configuration["nick"] for user in users: if user.lower() == bot_nick.lower(): users.remove(user) users.append(m.bot.parse_hostmask(m.sender)["nick"]) if users != []: m.bot.private_message(m.location, humanize_list(users) + ": " + get_line(m, "flirt.txt"))
def hug(m): """Hugs the specified user or channel in general.""" #- !hug [user ...] #- #- ```irc #- < GorillaWarfare> !hug #- * GorillaBot distributes tackle-glomps evenly among the channel #- < GorillaWarfare> !hug user #- * GorillaBot tackles user #- ``` #- #- Hugs the user or the channel. if m.is_pm: _hug_back(m) else: match = re.match( r':!(?:\w+) ?(\w+)?(?: and | |, )?((?!and)\w+)?(?:,? and |, | )?((?!and)\w+)?', m.body) users = [x for x in match.groups() if x] if match else [] if users == []: m.bot.action(m.location, "distributes {0} evenly among the channel" .format(get_line(m, "hugs.txt"))) else: bot_nick = m.bot.configuration["nick"] for user in users: if user.lower() == bot_nick.lower(): _hug_back(m) users.remove(user) if users != []: m.bot.action(m.location, "{0} {1}".format(get_line(m, "hugs.txt"), humanize_list(users)))
def eightball(m): """Returns 8-ball advice.""" #- !8ball [question] #- #- ```irc #- < GorillaWarfare> !8ball #- < GorillaBot> Most likely. #- ``` #- #- Returns a magic 8 ball response. m.bot.private_message(m.location, get_line(m, "8ball.txt"))
def _hug_back(m): """Helper function to return a hug.""" sender_nick = m.bot.parse_hostmask(m.sender)['nick'] m.bot.action(m.location, "{0} {1} back".format(get_line(m, "hugs.txt"), sender_nick))
def batman(m): """Respond with a line from batman.txt every 1 in 5 times "batman" is mentioned.""" if random() < 0.2: m.bot.private_message(m.location, get_line(m, "batman.txt"))
def alfred(m): """Respond with a line from alfred.txt every 1 in 5 times "AlfredBot" is mentioned.""" if random() < 0.2: m.bot.private_message(m.location, get_line(m, "alfred.txt"))