2017-05-15 22:26:10 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-05-16 10:06:29 +00:00
|
|
|
import random
|
|
|
|
|
2017-06-30 12:09:46 +00:00
|
|
|
import irc3
|
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
|
2017-07-06 17:06:38 +00:00
|
|
|
from psycopg2 import Error
|
2017-05-15 22:26:10 +00:00
|
|
|
|
2017-06-30 15:47:24 +00:00
|
|
|
from . import DatabasePlugin
|
2017-07-07 00:11:20 +00:00
|
|
|
from ..utils import re_generator
|
2017-05-15 22:26:10 +00:00
|
|
|
|
2017-07-04 13:22:20 +00:00
|
|
|
RAINBOW = (5, 7, 8, 9, 3, 10, 12, 2, 6, 13)
|
2017-05-15 22:26:10 +00:00
|
|
|
RAINBOW_LEN = len(RAINBOW)
|
|
|
|
|
2017-07-31 13:29:59 +00:00
|
|
|
ISPS = (
|
|
|
|
't-ipconnect',
|
|
|
|
'telefonica',
|
|
|
|
'vodafone',
|
|
|
|
'kabel',
|
|
|
|
'unity-media',
|
|
|
|
)
|
|
|
|
|
2017-05-15 22:26:10 +00:00
|
|
|
|
2017-05-16 05:45:10 +00:00
|
|
|
@irc3.plugin
|
2017-06-30 15:47:24 +00:00
|
|
|
class Useless(DatabasePlugin):
|
|
|
|
requires = ['irc3.plugins.command',
|
2017-07-07 00:11:20 +00:00
|
|
|
'bot.plugins.storage']
|
2017-07-04 13:22:20 +00:00
|
|
|
WOAH = (
|
|
|
|
'woah',
|
|
|
|
'woah indeed',
|
|
|
|
'woah woah woah!',
|
|
|
|
'keep your woahs to yourself',
|
|
|
|
)
|
|
|
|
|
2017-07-31 13:29:59 +00:00
|
|
|
@irc3.event(r'(?i)^:(?P<mask>\S+@\S+({isps})\S+) JOIN :(?P<target>#\S+)$'.format(isps='|'.join(ISPS)))
|
|
|
|
def bounce(self, mask, target):
|
|
|
|
nick = IrcString(mask).nick
|
|
|
|
|
|
|
|
if nick == self.bot.nick:
|
|
|
|
return
|
|
|
|
|
|
|
|
self.bot.privmsg(target, '{}: Du musst bouncen!'.format(nick))
|
2017-07-06 16:37:28 +00:00
|
|
|
|
2017-07-04 13:22:20 +00:00
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :.*(woah|whoa).*$')
|
|
|
|
def woah(self, target: str):
|
|
|
|
"""Colorize words in a sentence with rainbow colors."""
|
|
|
|
if random.randint(0, 4) is 0:
|
|
|
|
self.bot.privmsg(target, random.choice(self.WOAH))
|
2017-05-15 22:26:10 +00:00
|
|
|
|
2017-06-29 20:56:32 +00:00
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :(?P<msg>huehuehue)$')
|
|
|
|
def huehuehue(self, target: str, msg: str):
|
2017-05-30 10:56:20 +00:00
|
|
|
"""Returns a huehuehue when someone writes it."""
|
2017-06-29 20:56:32 +00:00
|
|
|
self.bot.privmsg(target, msg)
|
2017-05-16 01:52:03 +00:00
|
|
|
|
2017-07-07 00:11:20 +00:00
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :re+$')
|
2017-06-29 20:56:32 +00:00
|
|
|
def reeeeee(self, target: str):
|
2017-05-31 12:07:57 +00:00
|
|
|
"""Returns a REEEE."""
|
2017-07-07 00:11:20 +00:00
|
|
|
self.bot.privmsg(target, re_generator())
|
2017-05-31 12:07:57 +00:00
|
|
|
|
2017-06-29 20:56:32 +00:00
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :same$')
|
|
|
|
def same(self, target: str):
|
2017-05-30 10:56:20 +00:00
|
|
|
"""Returns a plain same when a user writes same."""
|
2017-06-29 20:56:32 +00:00
|
|
|
self.bot.privmsg(target, 'same')
|
2017-05-16 01:52:03 +00:00
|
|
|
|
2017-06-29 20:56:32 +00:00
|
|
|
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :\[(?P<msg>.*)\]$')
|
|
|
|
def intensifies(self, target: str, msg: str):
|
2017-05-30 10:56:20 +00:00
|
|
|
"""String with brackets around will be returned with INTENSIFIES."""
|
2017-07-07 00:11:20 +00:00
|
|
|
self.bot.privmsg(target, '\x02[{} INTENSIFIES]'.format(msg.upper()))
|
2017-05-16 01:52:03 +00:00
|
|
|
|
2017-06-30 15:47:24 +00:00
|
|
|
@command
|
2017-06-30 17:33:26 +00:00
|
|
|
def kill(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-06-30 15:47:24 +00:00
|
|
|
"""Kills a user with a random message.
|
|
|
|
|
|
|
|
%%kill [<nick>]
|
|
|
|
"""
|
|
|
|
self.cur.execute('''
|
|
|
|
select
|
|
|
|
item
|
|
|
|
from
|
|
|
|
kills
|
|
|
|
order by
|
|
|
|
random()
|
|
|
|
limit
|
|
|
|
1
|
|
|
|
''')
|
2017-07-07 00:11:20 +00:00
|
|
|
nick = args.get('<nick>') or mask.nick
|
|
|
|
self.bot.action(target, self.cur.fetchone()['item'].format(nick))
|
2017-06-30 15:47:24 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-30 17:33:26 +00:00
|
|
|
def yiff(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-06-30 15:47:24 +00:00
|
|
|
"""Yiffs a user with a random message.
|
|
|
|
|
|
|
|
%%yiff [<nick>]
|
|
|
|
"""
|
|
|
|
self.cur.execute('''
|
|
|
|
select
|
|
|
|
item
|
|
|
|
from
|
|
|
|
yiffs
|
|
|
|
order by
|
|
|
|
random()
|
|
|
|
limit
|
|
|
|
1
|
|
|
|
''')
|
2017-07-07 00:11:20 +00:00
|
|
|
nick = args.get('<nick>') or mask.nick
|
2017-07-31 13:29:59 +00:00
|
|
|
self.bot.action(target, self.cur.fetchone()['item'].format(
|
|
|
|
nick=args.get('<nick>') or mask.nick,
|
|
|
|
yiffer=mask.nick,
|
|
|
|
))
|
2017-06-30 15:47:24 +00:00
|
|
|
|
2017-06-30 17:33:26 +00:00
|
|
|
@command
|
|
|
|
def waifu(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
|
|
|
"""Get waifu for a user.
|
|
|
|
|
2017-07-04 13:22:20 +00:00
|
|
|
%%waifu [<nick>...]
|
2017-06-30 17:33:26 +00:00
|
|
|
"""
|
2017-07-04 13:22:20 +00:00
|
|
|
nick = ' '.join(args.get('<nick>')) or mask.nick
|
2017-06-30 17:33:26 +00:00
|
|
|
|
|
|
|
if nick.startswith('='):
|
|
|
|
waifu = nick[1:]
|
|
|
|
|
2017-07-06 17:06:38 +00:00
|
|
|
try:
|
|
|
|
self.cur.execute('''
|
2017-07-31 13:29:59 +00:00
|
|
|
insert into
|
|
|
|
users (nick, waifu)
|
|
|
|
values
|
|
|
|
(lower(%s), %s)
|
|
|
|
on conflict (nick) do update set
|
|
|
|
waifu = excluded.waifu
|
|
|
|
''', [mask.nick, waifu])
|
|
|
|
self.con.commit()
|
2017-07-06 17:06:38 +00:00
|
|
|
|
2017-07-07 00:11:20 +00:00
|
|
|
self.bot.notice(mask.nick, 'Waifu set to: {}'.format(waifu))
|
2017-07-06 17:06:38 +00:00
|
|
|
except Error as ex:
|
|
|
|
print(ex)
|
|
|
|
self.con.rollback()
|
2017-06-30 17:33:26 +00:00
|
|
|
else:
|
|
|
|
self.cur.execute('''
|
2017-07-31 13:29:59 +00:00
|
|
|
select
|
|
|
|
waifu
|
|
|
|
from
|
|
|
|
users
|
|
|
|
where
|
|
|
|
lower(nick) = lower(%s)
|
|
|
|
''', [nick])
|
2017-06-30 17:33:26 +00:00
|
|
|
result = self.cur.fetchone()
|
|
|
|
|
|
|
|
if result and result['waifu']:
|
2017-07-07 00:11:20 +00:00
|
|
|
return '\x02[Waifu]\x0F {}: {}'.format(nick, result['waifu'])
|
2017-06-30 17:33:26 +00:00
|
|
|
|
|
|
|
@command
|
|
|
|
def husbando(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
|
|
|
"""Get husbando for a user.
|
|
|
|
|
2017-07-04 13:22:20 +00:00
|
|
|
%%husbando [<nick>...]
|
2017-06-30 17:33:26 +00:00
|
|
|
"""
|
2017-07-04 13:22:20 +00:00
|
|
|
nick = ' '.join(args.get('<nick>')) or mask.nick
|
2017-06-30 17:33:26 +00:00
|
|
|
|
|
|
|
if nick.startswith('='):
|
2017-07-04 13:22:20 +00:00
|
|
|
nick = nick[1:]
|
2017-06-30 17:33:26 +00:00
|
|
|
|
2017-07-06 17:17:03 +00:00
|
|
|
try:
|
|
|
|
self.cur.execute('''
|
2017-07-31 13:29:59 +00:00
|
|
|
insert into
|
|
|
|
users (nick, husbando)
|
|
|
|
values
|
|
|
|
(lower(%s), %s)
|
|
|
|
on conflict (nick) do update set
|
|
|
|
husbando = excluded.husbando
|
|
|
|
''', [mask.nick, nick])
|
|
|
|
self.con.commit()
|
2017-07-06 17:17:03 +00:00
|
|
|
|
2017-07-07 00:11:20 +00:00
|
|
|
self.bot.notice(mask.nick, 'Husbando set to: {}'.format(nick))
|
|
|
|
except Error as ex:
|
2017-07-06 17:17:03 +00:00
|
|
|
print(ex)
|
|
|
|
self.con.rollback()
|
2017-06-30 17:33:26 +00:00
|
|
|
else:
|
|
|
|
self.cur.execute('''
|
2017-07-31 13:29:59 +00:00
|
|
|
select
|
|
|
|
husbando
|
|
|
|
from
|
|
|
|
users
|
|
|
|
where
|
|
|
|
lower(nick) = lower(%s)
|
|
|
|
''', [nick])
|
2017-06-30 17:33:26 +00:00
|
|
|
result = self.cur.fetchone()
|
|
|
|
|
|
|
|
if result and result['husbando']:
|
2017-07-07 00:11:20 +00:00
|
|
|
return '\x02[Husbando]\x0F {}: {}'.format(nick, result['husbando'])
|
2017-06-30 17:33:26 +00:00
|
|
|
|
2017-05-16 01:52:03 +00:00
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def storyofpomfface(self, mask: IrcString, target: IrcString,
|
2017-05-16 01:52:03 +00:00
|
|
|
args: DocOptDict):
|
2017-05-28 12:07:35 +00:00
|
|
|
"""Story of pomf face.
|
2017-05-16 12:27:34 +00:00
|
|
|
|
2017-05-16 01:52:03 +00:00
|
|
|
%%storyofpomfface
|
|
|
|
"""
|
|
|
|
for face in (':O C==3', ':OC==3', ':C==3', ':C=3', ':C3', ':3'):
|
2017-06-29 20:56:32 +00:00
|
|
|
self.bot.privmsg(target, face)
|
2017-05-16 01:52:03 +00:00
|
|
|
|
2017-05-29 11:29:23 +00:00
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def choose(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-29 11:29:23 +00:00
|
|
|
"""Decides between items separated by comma.
|
|
|
|
|
|
|
|
%%choose <items>...
|
|
|
|
"""
|
|
|
|
choice = random.choice(' '.join(args['<items>']).split(','))
|
2017-07-07 00:11:20 +00:00
|
|
|
return '{}: {}'.format(mask.nick, choice.strip())
|
2017-05-29 11:29:23 +00:00
|
|
|
|
2017-05-15 22:26:10 +00:00
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def jn(self, mask: IrcString, target: 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-07-06 12:40:48 +00:00
|
|
|
%%jn <question>...
|
2017-05-16 06:54:47 +00:00
|
|
|
%%jn
|
2017-05-15 22:26:10 +00:00
|
|
|
"""
|
2017-06-01 15:38:34 +00:00
|
|
|
choice = random.choice(['3Ja', '4Nein'])
|
2017-07-07 00:11:20 +00:00
|
|
|
return '{}: \x02\x030{}'.format(mask.nick, choice)
|
2017-05-15 22:26:10 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def kiss(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-28 12:07:35 +00:00
|
|
|
"""Kisses a user.
|
2017-05-28 11:27:40 +00:00
|
|
|
|
2017-07-31 13:29:59 +00:00
|
|
|
%%kiss [<nick>]
|
|
|
|
|
2017-05-15 22:26:10 +00:00
|
|
|
"""
|
2017-07-31 13:29:59 +00:00
|
|
|
return '(づ。◕‿‿◕。)\x0304。。・゜゜・。。・゜❤\x0F {} \x0304❤'.format(args.get('<nick>') or mask.nick)
|
2017-05-15 22:26:10 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def hug(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-28 12:07:35 +00:00
|
|
|
"""Hugs a user.
|
2017-05-28 11:27:40 +00:00
|
|
|
|
2017-07-31 13:29:59 +00:00
|
|
|
%%hug [<nick>]
|
2017-05-15 22:26:10 +00:00
|
|
|
"""
|
2017-07-31 13:29:59 +00:00
|
|
|
return '\x0304♥♡❤♡♥\x0F {} \x0304♥♡❤♡♥'.format(args.get('<nick>') or mask.nick)
|
2017-05-15 22:26:10 +00:00
|
|
|
|
2017-05-31 12:05:55 +00:00
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def bier(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-31 12:05:55 +00:00
|
|
|
"""Gives nick a beer.
|
|
|
|
|
2017-06-01 15:38:34 +00:00
|
|
|
%%bier [<nick>]
|
2017-05-31 12:05:55 +00:00
|
|
|
"""
|
2017-07-07 00:11:20 +00:00
|
|
|
nick = args.get('<nick>') or mask.nick
|
|
|
|
self.bot.action(target, 'schenkt ein kühles Blondes an {} aus.'.format(nick))
|
2017-05-31 12:05:55 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def fucken(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-31 12:05:55 +00:00
|
|
|
"""Kills and fucks a nick.
|
|
|
|
|
2017-06-01 15:38:34 +00:00
|
|
|
%%fucken [<nick>]
|
2017-05-31 12:05:55 +00:00
|
|
|
"""
|
2017-07-07 00:11:20 +00:00
|
|
|
nick = args.get('<nick>') or mask.nick
|
|
|
|
self.bot.action(target, 'fuckt {0} und tötet {0} anschließend.'.format(nick, nick))
|
2017-05-31 12:05:55 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def anhero(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-31 12:05:55 +00:00
|
|
|
"""Kicks a nick.
|
|
|
|
|
|
|
|
%%anhero
|
|
|
|
"""
|
2017-07-31 13:29:59 +00:00
|
|
|
self.bot.kick(target, mask.nick, 'Sayonara bonzai-chan...')
|
2017-05-31 12:05:55 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def sudoku(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-31 12:05:55 +00:00
|
|
|
"""Kicks a nick.
|
|
|
|
|
|
|
|
%%sudoku
|
|
|
|
"""
|
2017-06-29 20:56:32 +00:00
|
|
|
self.anhero(mask, target, args)
|
2017-05-31 12:05:55 +00:00
|
|
|
|
2017-05-16 01:52:03 +00:00
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def hack(self, mask: IrcString, target: IrcString, args: DocOptDict):
|
2017-05-28 12:07:35 +00:00
|
|
|
"""Hacks (a user).
|
2017-05-28 11:27:40 +00:00
|
|
|
|
2017-05-16 01:52:03 +00:00
|
|
|
%%hack [<nick>]
|
|
|
|
"""
|
|
|
|
nick = args.get('<nick>') or ''
|
2017-07-07 00:11:20 +00:00
|
|
|
return 'hacking{}...'.format(' %s' % nick if nick else '')
|
2017-05-16 01:52:03 +00:00
|
|
|
|
2017-05-15 22:26:10 +00:00
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def gay(self, mask: IrcString, target: 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>...
|
|
|
|
"""
|
2017-06-29 20:56:32 +00:00
|
|
|
return self.rainbow(mask, target, args)
|
2017-05-15 22:26:10 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def rainbow(self, mask: IrcString, target: 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 = []
|
2017-05-30 10:56:20 +00:00
|
|
|
for char in ' '.join(args.get('<word>')):
|
2017-05-15 22:26:10 +00:00
|
|
|
if char != ' ':
|
2017-05-29 16:44:26 +00:00
|
|
|
char = self._rainbow(last, char)
|
2017-05-15 22:26:10 +00:00
|
|
|
last += 1
|
|
|
|
word.append(char)
|
2017-05-29 16:44:26 +00:00
|
|
|
return ''.join(word)
|
2017-05-15 22:26:10 +00:00
|
|
|
|
|
|
|
@command
|
2017-06-29 20:56:32 +00:00
|
|
|
def wrainbow(self, mask: IrcString, target: 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>...
|
|
|
|
"""
|
2017-07-07 00:11:20 +00:00
|
|
|
return ' '.join([self._rainbow(i, word) for i, word in enumerate(args['<words>'])])
|
2017-05-29 16:44:26 +00:00
|
|
|
|
2017-07-07 00:11:20 +00:00
|
|
|
# noinspection PyMethodMayBeStatic
|
2017-07-04 13:22:20 +00:00
|
|
|
def _rainbow(self, i, char):
|
2017-07-07 00:11:20 +00:00
|
|
|
return '\x030{}{}'.format(RAINBOW[i % RAINBOW_LEN], char)
|