nxy/nxy/plugins/useless.py

136 lines
4.5 KiB
Python
Raw Normal View History

2017-05-15 22:26:10 +00:00
# -*- coding: utf-8 -*-
2017-05-16 10:06:29 +00:00
import irc3
import random
2017-05-15 22:26:10 +00:00
from docopt import Dict as DocOptDict
from irc3.plugins.command import command
from irc3.utils import IrcString
from . import Plugin
from ..utils import fmt
RAINBOW = ('maroon', 'red', 'orange', 'yellow', 'ltgreen', 'green', 'teal',
'ltblue', 'blue', 'purple', 'pink')
RAINBOW_LEN = len(RAINBOW)
GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring
to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it,
GNU plus Linux. Linux is not an operating system unto itself, but rather
another free component of a fully functioning GNU system made useful by the
2017-05-16 05:45:10 +00:00
GNU corelibs, shell utilities and vital system components comprising a full
OS as defined by POSIX."""
2017-05-15 22:26:10 +00:00
2017-05-16 05:45:10 +00:00
@irc3.plugin
2017-05-15 22:26:10 +00:00
class Useless(Plugin):
requires = ['irc3.plugins.command']
2017-05-15 22:26:10 +00:00
2017-05-29 12:40:58 +00:00
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :'
r'.*(?<!gnu[/+])linux(?! kernel).*')
def linux(self, channel: str):
if random.randint(0, 4) is 0:
self.bot.privmsg(channel, GNU_LINUX)
2017-05-29 12:40:58 +00:00
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :(?P<msg>huehuehue)$')
2017-05-28 12:07:35 +00:00
def huehuehue(self, channel: str, msg: str):
self.bot.privmsg(channel, msg)
2017-05-29 12:40:58 +00:00
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :same$')
def same(self, channel: str):
self.bot.privmsg(channel, 'same')
2017-05-29 12:40:58 +00:00
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :\[(?P<data>.*)\]$')
def intensifies(self, channel: str, data: str):
self.bot.privmsg(channel, fmt('{bold}[{data} INTENSIFIES]',
data=data.upper()))
@command
def storyofpomfface(self, mask: IrcString, channel: IrcString,
args: DocOptDict):
2017-05-28 12:07:35 +00:00
"""Story of pomf face.
2017-05-16 12:27:34 +00:00
%%storyofpomfface
"""
for face in (':O C==3', ':OC==3', ':C==3', ':C=3', ':C3', ':3'):
self.bot.privmsg(channel, face)
2017-05-29 11:29:23 +00:00
@command
def choose(self, mask: IrcString, channel: IrcString, args: DocOptDict):
"""Decides between items separated by comma.
%%choose <items>...
"""
choice = random.choice(' '.join(args['<items>']).split(','))
return '{nick}, I\'d choose: {choice}'.format(nick=mask.nick,
choice=choice.strip())
2017-05-15 22:26:10 +00:00
@command
2017-05-16 06:54:47 +00:00
def jn(self, mask: IrcString, channel: IrcString, args: DocOptDict):
2017-05-28 12:07:35 +00:00
"""Decides between yes and no (for a question).
2017-05-16 12:27:34 +00:00
2017-05-15 22:26:10 +00:00
%%jn <question>
2017-05-16 06:54:47 +00:00
%%jn
2017-05-15 22:26:10 +00:00
"""
choice = random.choice(['{green}Ja', '{maroon}Nein'])
return fmt('{nick}: {bold}{color}%s' % choice, nick=mask.nick)
@command
def kiss(self, mask: IrcString, channel: IrcString, args: DocOptDict):
2017-05-28 12:07:35 +00:00
"""Kisses a user.
2017-05-28 11:27:40 +00:00
2017-05-15 22:26:10 +00:00
%%kiss <nick>
"""
return fmt('(づ。◕‿‿◕。)づ{color}{red}。。・゜゜・。。・゜❤{reset} {nick} '
2017-05-28 11:30:16 +00:00
'{color}{red}', nick=args['<nick>'])
2017-05-15 22:26:10 +00:00
@command
def hug(self, mask: IrcString, channel: IrcString,
args: DocOptDict) -> str:
2017-05-28 12:07:35 +00:00
"""Hugs a user.
2017-05-28 11:27:40 +00:00
2017-05-15 22:26:10 +00:00
%%hug <nick>
"""
return fmt('{color}{red}♥♡❤♡♥{reset} {nick} {color}{red}♥♡❤♡♥',
nick=args['<nick>'])
@command
2017-05-16 06:54:47 +00:00
def hack(self, mask: IrcString, channel: IrcString, args: DocOptDict):
2017-05-28 12:07:35 +00:00
"""Hacks (a user).
2017-05-28 11:27:40 +00:00
%%hack [<nick>]
"""
nick = args.get('<nick>') or ''
2017-05-28 12:07:35 +00:00
return 'hacking{}...'.format(' %s' % nick if nick else '')
2017-05-15 22:26:10 +00:00
@command
2017-05-16 06:54:47 +00:00
def gay(self, mask: IrcString, channel: IrcString, args: DocOptDict):
2017-05-16 12:27:34 +00:00
"""Make someone gay (alias to rainbow)
2017-05-28 11:27:40 +00:00
2017-05-15 22:26:10 +00:00
%%gay <word>...
"""
return self.rainbow(mask, channel, args)
@command
2017-05-16 06:54:47 +00:00
def rainbow(self, mask: IrcString, channel: IrcString, args: DocOptDict):
2017-05-28 12:07:35 +00:00
"""Colorize a word in rainbow colors.
2017-05-28 11:27:40 +00:00
2017-05-15 22:26:10 +00:00
%%rainbow <word>...
"""
last = 0
word = []
for i, char in enumerate(' '.join(args.get('<word>'))):
if char != ' ':
char = '{color}{%s}%s' % (RAINBOW[last % RAINBOW_LEN], char)
last += 1
word.append(char)
return fmt(''.join(word))
@command
2017-05-16 06:54:47 +00:00
def wrainbow(self, mask: IrcString, channel: IrcString, args: DocOptDict):
2017-05-28 12:07:35 +00:00
"""Colorize words in a sentence with rainbow colors.
2017-05-16 12:27:34 +00:00
2017-05-15 22:26:10 +00:00
%%wrainbow <words>...
"""
return fmt(' '.join(['{color}{%s}%s' % (RAINBOW[i % RAINBOW_LEN], word)
for i, word in enumerate(args['<words>'])]))