nxy/bot/useless.py

533 lines
16 KiB
Python

# -*- coding: utf-8 -*-
import random
import re
import irc3
from docopt import Dict
from irc3.plugins.command import command
from irc3.utils import IrcString
from psycopg2 import Error
from . import DatabasePlugin
from .utils import re_generator
class Useless(DatabasePlugin):
RAINBOW = (5, 7, 8, 9, 3, 10, 12, 2, 6, 13)
WOAH = (
'woah',
'woah indeed',
'woah woah woah!',
'keep your woahs to yourself',
)
ISPS = (
't-ipconnect',
'telefonica',
'vodafone',
'kabel',
'unity-media',
)
GENDERS = (
'male',
'female',
'shemale',
'hermaphrodite',
'Abimegender',
'Absorgender',
'Adamasgender',
'Adeptogender',
'Aerogender',
'Agenderflux',
'Alexigender',
'Androgyne',
'Arifluid',
'Batgender',
'Bigender',
'Bigenderfluid',
'Biogender',
'Blizzgender',
'Boggender',
'Bordergender/Borderfluid',
'Boyflux',
'Burstgende',
'Cancegender',
'Chaosgender',
'Circgender',
'Cloudgender',
'Cocoongender',
'Coigender',
'Colorgender',
'Demifluid/flux',
'Demigender',
'Digigender',
'Diurnalgender2',
'Domgender',
'Drakefluid',
'Dryagender',
'Dulcigender',
'Duragender',
'Eafluid',
'Earthgender',
'Fuzzgender',
'Firegender',
'Genderale',
'Genderblur',
'Genderfluid',
'Gender-Neutral',
'Gendernegative',
'Genderpunk',
'Genderqueer',
'Kingender',
'Juxera',
'Leogender',
'Invisigender',
'Intergender',
'Xirl',
'Xoy',
'Xumgender',
'Zodiacgender',
)
@command(permission='admin', show_in_help=False)
def lowfry(self, mask: IrcString, target: IrcString, args: Dict):
"""Kicks lowfry, most useful command.
%%lowfry
"""
self.bot.kick(target, 'lowfry')
@command(permission='admin', show_in_help=False)
def kim(self, mask: IrcString, target: IrcString, args: Dict):
"""Kicks kim, most useful command.
%%kim
"""
self.bot.kick(target, 'kim')
@irc3.event(r'(?i)^:(?P<mask>\S+@\S+({})\S+) JOIN :(?P<target>#\S+)$'.format('|'.join(ISPS)))
def bounce(self, mask, target):
nick = IrcString(mask).nick
if target == '#w0bm' and nick != self.bot.nick:
self.bot.privmsg(target, '{}: Du musst bouncen!'.format(nick))
@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) == 0:
self.bot.privmsg(target, random.choice(self.WOAH))
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :(?P<msg>huehuehue)$')
def huehuehue(self, target: str, msg: str):
"""Returns a huehuehue when someone writes it."""
self.bot.privmsg(target, msg)
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :re{{2,}}$')
def reeeeee(self, target: str):
"""Returns a REEEE."""
self.bot.privmsg(target, re_generator())
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :same$')
def same(self, target: str):
"""Returns a plain same when a user writes same."""
self.bot.privmsg(target, 'same')
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :\[(?P<msg>.*)\]$')
def intensifies(self, target: str, msg: str):
"""String with brackets around will be returned with INTENSIFIES."""
self.bot.privmsg(target, '\x02[{} INTENSIFIES]'.format(msg.upper()))
@command
def kill(self, mask: IrcString, target: IrcString, args: Dict):
"""Kills a user with a random message
%%kill [<nick>]
"""
with self.con.cursor() as cur:
cur.execute('''
SELECT
item
FROM
kills
ORDER BY
random()
LIMIT
1
''')
self.bot.action(target, cur.fetchone()['item'].format(
nick=args.get('<nick>', mask.nick),
))
@command
def yiff(self, mask: IrcString, target: IrcString, args: Dict):
"""Yiffs a user with a random message
%%yiff [<nick>]
"""
with self.con.cursor() as cur:
cur.execute('''
SELECT
item
FROM
yiffs
ORDER BY
random()
LIMIT
1
''')
self.bot.action(target, cur.fetchone()['item'].format(
nick=args.get('<nick>', mask.nick),
yiffer=mask.nick,
))
@command
def waifu(self, mask: IrcString, target: IrcString, args: Dict):
"""Get waifu for a user (set with prefixing the user with =)
%%waifu [<nick>...]
"""
return self.husbando_waifu('waifu', mask, target, args)
@command
def husbando(self, mask: IrcString, target: IrcString, args: Dict):
"""Get husbando for a user (set with prefixing the user with =)
%%husbando [<nick>...]
"""
return self.husbando_waifu('husbando', mask, target, args)
@command
def storyofpomfface(self, mask: IrcString, target: IrcString, args: Dict):
"""Story of pomf face
%%storyofpomfface
"""
for face in (':O C==3', ':OC==3', ':C==3', ':C=3', ':C3', ':3'):
self.bot.privmsg(target, face)
@command
def choose(self, mask: IrcString, target: IrcString, args: Dict):
"""Decides between items (separated by comma)
%%choose <items>...
"""
choice = random.choice(' '.join(args['<items>']).split(','))
return '{}: {}'.format(mask.nick, choice.strip())
@command
def jn(self, mask: IrcString, target: IrcString, args: Dict):
"""Decides between yes and no (for a question).
%%jn <question>...
%%jn
"""
choice = random.choice(['3Ja', '4Nein'])
return '{}: \x02\x030{}'.format(mask.nick, choice)
@command
def kiss(self, mask: IrcString, target: IrcString, args: Dict):
"""Kisses a user
%%kiss [<nick>]
"""
return '(づ。◕‿‿◕。)\x0304。。・゜゜・。。・゜❤\x03 {} \x0304❤'.format(args.get('<nick>', mask.nick))
@command
def hug(self, mask: IrcString, target: IrcString, args: Dict):
"""Hugs a user
%%hug [<nick>]
"""
return '\x0304♥♡❤♡♥\x03 {} \x0304♥♡❤♡♥'.format(args.get('<nick>', mask.nick))
@command
def bier(self, mask: IrcString, target: IrcString, args: Dict):
"""Gives a user a beer
%%bier [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'schenkt ein kühles Blondes an {} aus.'.format(nick))
@command
def fucken(self, mask: IrcString, target: IrcString, args: Dict):
"""Kills and fucks a user
%%fucken [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'fuckt {0} und tötet {0} anschließend.'.format(nick, nick))
@command(aliases=['anhero', 'sudoku'])
def seppuku(self, mask: IrcString, target: IrcString, args: Dict):
"""Kicks a user
%%seppuku
"""
self.bot.kick(target, mask.nick, 'Sayonara bonzai-chan...')
@command
def hack(self, mask: IrcString, target: IrcString, args: Dict):
"""Hacks (a user)
%%hack [<nick>]
"""
nick = args.get('<nick>')
return 'hacking{}...'.format(' %s' % nick if nick else '')
@command
def gay(self, mask: IrcString, target: IrcString, args: Dict):
"""Make someone gay (alias to rainbow)
%%gay <word>...
"""
return self.rainbow(mask, target, args)
@command
def rainbow(self, mask: IrcString, target: IrcString, args: Dict):
"""Colorize a word in rainbow colors
%%rainbow <word>...
"""
last = 0
word = []
for char in ' '.join(args.get('<word>')):
if char != ' ':
char = self._rainbow(last, char)
last += 1
word.append(char)
return ''.join(word)
@command
def wrainbow(self, mask: IrcString, target: IrcString, args: Dict):
"""Colorize words in a sentence with rainbow colors
%%wrainbow <words>...
"""
return ' '.join([self._rainbow(i, word) for i, word in enumerate(args['<words>'])])
@command(aliases=['hw'])
def halfwidth(self, mask: IrcString, target: IrcString, args: Dict):
"""Turns UPPERCASE words into halfwidth characters
%%halfwidth <words>...
"""
def replace(match):
return ''.join(chr(0xFF20 + (ord(c) - 64)) for c in match.group(0))
return '\x02[HALFWIDTH]\x02 {}'.format(re.sub(r'(?:\b)[A-Z]+(?:\b)', replace, ' '.join(args['<words>'])))
@command
def asshole(self, mask: IrcString, target: IrcString, args: Dict):
"""Checks how much of an asshole you are
%%asshole [<nick>]
"""
nick = args.get('<nick>', mask.nick)
if nick.lower() == 'mrhanky':
perc_min = 100
elif nick.lower() == 'flummi':
perc_min = 90
else:
perc_min = 0
asshole_perc = random.randint(perc_min, 100)
return 'Asshole scan... {} is {}% of an asshole.'.format(nick, asshole_perc)
@command
def assume(self, mask: IrcString, target: IrcString, args: Dict):
"""Assumes the gender of a nick or yourself
%%assume [<nick>]
"""
nick = args.get('<nick>', mask.nick)
gender = random.choice(self.GENDERS)
return 'Assuming {}\'s gender... they\'re a {}.'.format(nick, gender)
@command
def spit(self, mask: IrcString, target: IrcString, args: Dict):
"""Spits a user
%%spit [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'spits on {} like a dirty whore.'.format(nick))
@command
def merkel(self, mask: IrcString, target: IrcString, args: Dict):
"""Merkels (a user)
%%merkel [<nick>]
"""
return '{}, wir schaffen das!'.format(args.get('<nick>', mask.nick))
@command
def assel(self, mask: IrcString, target: IrcString, args: Dict):
"""Asselt a user
%%assel [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'asselt {0}'.format(nick, nick))
@command
def gurke(self, mask: IrcString, target: IrcString, args: Dict):
"""Gurks a user
%%gurke [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'schiebt {0} eine Gurke in den Arsch'.format(nick, nick))
@command
def kacken(self, mask: IrcString, target: IrcString, args: Dict):
"""wünscht guten rutsch beim kacken
%%kacken [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'wünscht {0} einen guten Rutsch! Nicht zu fest drücken!'.format(nick, nick))
@command
def knoblauch(self, mask: IrcString, target: IrcString, args: Dict):
"""knoblaucht einen user
%%knoblauch [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'schneidet etwas Knoblauch klein und lässt die Stückchen in den Arsch von {0} fallen.'.format(nick, nick))
@command
def zaziki(self, mask: IrcString, target: IrcString, args: Dict):
"""zaziki
%%zaziki [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'bereitet in dem Arsch von {0} ein frisches Zaziki nach original griechischem Rezept zu.'.format(nick, nick))
@command
def biene(self, mask: IrcString, target: IrcString, args: Dict):
"""biene
%%biene [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'sticht mit letzter Lebenskraft in die Eichel von {0} und stirbt dann.'.format(nick, nick))
@command
def wespe(self, mask: IrcString, target: IrcString, args: Dict):
"""wespe
%%wespe [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'sticht tausende male auf {0} ein und fliegt dann weg als wäre nichts gewesen'.format(nick, nick))
@command
def saufen(self, mask: IrcString, target: IrcString, args: Dict):
"""fordert einen Nutzer zum Saufgelage auf!
%%saufen [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'fordert {0} zum saufen auf!'.format(nick, nick))
@command
def jalapeno(self, mask: IrcString, target: IrcString, args: Dict):
"""schiebt eine jalapeno in die harnröhre eines nutzers
%%jalapeno [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'schiebt {0} eine Jalapeno in die Harnröhre'.format(nick, nick))
@command
def schwulmo(self, mask: IrcString, target: IrcString, args: Dict):
"""schwulmot den kompletten Channel!
%%schwulmo [<nick>]
"""
self.bot.action(target, 'wünscht einen tollen schwulmo an alle :********')
@command
def iframe(self, mask: IrcString, target: IrcString, args: Dict):
"""ddoses someone with an iframe!
%%iframe [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'starts a low skilled, fuuuf like iframe ddos attack on {0}'.format(nick, nick))
@command
def corona(self, mask: IrcString, target: IrcString, args: Dict):
"""infects someone with corona
%%corona [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'hustet {0} in\'s Gesicht'.format(nick, nick))
@command
def vampir(self, mask: IrcString, target: IrcString, args: Dict):
"""Sends a url with the cute vampire cat :3
%%vampir
"""
return 'https://files.catbox.moe/ma2dfs.png'
@command
def hebamme(self, mask: IrcString, target: IrcString, args: Dict):
"""Tells you to get the fuck outta this group
%%hebamme [<nick>]
"""
nick = args.get('<nick>', mask.nick)
self.bot.action(target, 'macht {0} klar, dass er sich lieber verpissen sollte!'.format(nick, nick))
def husbando_waifu(self, field: str, mask: IrcString, target: IrcString, args: Dict):
nick = args.get('<nick>', mask.nick)
if isinstance(nick, list):
nick = ' '.join(nick)
if nick.startswith('='):
nick = nick[1:]
try:
with self.con.cursor() as cur:
cur.execute('''
INSERT INTO
users (nick, {0})
VALUES
(lower(%s), %s)
ON CONFLICT (nick) DO UPDATE SET
{0} = excluded.{0}
'''.format(field), [mask.nick, nick])
self.con.commit()
self.bot.notice(mask.nick, '{} set to: {}'.format(field.title(), nick))
except Error as ex:
self.log.error(ex)
self.con.rollback()
else:
with self.con.cursor() as cur:
cur.execute('''
SELECT
{}
FROM
users
WHERE
lower(nick) = lower(%s)
'''.format(field), [nick])
result = cur.fetchone()
if result and result[field]:
return '\x02[{}]\x02 {}: {}'.format(field.title(), nick, result[field])
# noinspection PyMethodMayBeStatic
def _rainbow(self, i, char):
return '\x03{0:02d}{1}'.format(self.RAINBOW[i % len(self.RAINBOW)], char)