nxy/bot/useless.py

533 lines
16 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 random
2017-08-22 12:57:07 +00:00
import re
2017-05-16 10:06:29 +00:00
2017-06-30 12:09:46 +00:00
import irc3
2017-08-22 13:57:57 +00:00
from docopt import Dict
2017-05-15 22:26:10 +00:00
from irc3.plugins.command import command
from irc3.utils import IrcString
from psycopg2 import Error
2017-05-15 22:26:10 +00:00
from . import DatabasePlugin
2017-08-22 15:43:48 +00:00
from .utils import re_generator
2017-05-15 22:26:10 +00:00
class Useless(DatabasePlugin):
RAINBOW = (5, 7, 8, 9, 3, 10, 12, 2, 6, 13)
2017-07-04 13:22:20 +00:00
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',
)
2019-07-16 13:47:19 +00:00
@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')
2017-08-16 12:39:44 +00:00
@command(permission='admin', show_in_help=False)
2017-08-22 13:57:57 +00:00
def kim(self, mask: IrcString, target: IrcString, args: Dict):
2019-07-16 13:47:19 +00:00
"""Kicks kim, most useful command.
2017-08-16 12:39:44 +00:00
%%kim
"""
2019-07-16 13:47:19 +00:00
self.bot.kick(target, 'kim')
2017-08-16 12:39:44 +00:00
@irc3.event(r'(?i)^:(?P<mask>\S+@\S+({})\S+) JOIN :(?P<target>#\S+)$'.format('|'.join(ISPS)))
2017-07-31 13:29:59 +00:00
def bounce(self, mask, target):
nick = IrcString(mask).nick
2017-08-22 13:16:29 +00:00
if target == '#w0bm' and nick != self.bot.nick:
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) == 0:
2017-07-04 13:22:20 +00:00
self.bot.privmsg(target, random.choice(self.WOAH))
2017-05-15 22:26:10 +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."""
self.bot.privmsg(target, msg)
2018-08-14 10:52:58 +00:00
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :re{{2,}}$')
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
@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."""
self.bot.privmsg(target, 'same')
@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()))
@command
2017-08-22 13:57:57 +00:00
def kill(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +00:00
"""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
2017-08-22 13:57:57 +00:00
def yiff(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +00:00
"""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,
))
2017-06-30 17:33:26 +00:00
@command
2017-08-22 13:57:57 +00:00
def waifu(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:19:57 +00:00
"""Get waifu for a user (set with prefixing the user with =)
2017-06-30 17:33:26 +00:00
2017-07-04 13:22:20 +00:00
%%waifu [<nick>...]
2017-06-30 17:33:26 +00:00
"""
return self.husbando_waifu('waifu', mask, target, args)
2017-06-30 17:33:26 +00:00
@command
2017-08-22 13:57:57 +00:00
def husbando(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:19:57 +00:00
"""Get husbando for a user (set with prefixing the user with =)
2017-06-30 17:33:26 +00:00
2017-07-04 13:22:20 +00:00
%%husbando [<nick>...]
2017-06-30 17:33:26 +00:00
"""
return self.husbando_waifu('husbando', mask, target, args)
2017-06-30 17:33:26 +00:00
@command
2017-08-22 13:57:57 +00:00
def storyofpomfface(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +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(target, face)
2017-05-29 11:29:23 +00:00
@command
2017-08-22 13:57:57 +00:00
def choose(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +00:00
"""Decides between items (separated by comma)
2017-05-29 11:29:23 +00:00
%%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-08-22 13:57:57 +00:00
def jn(self, mask: IrcString, target: IrcString, args: Dict):
2017-05-28 12:07:35 +00:00
"""Decides between yes and no (for a question).
2017-05-16 12:27:34 +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-08-22 13:57:57 +00:00
def kiss(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +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-08-22 13:16:29 +00:00
return '(づ。◕‿‿◕。)\x0304。。・゜゜・。。・゜❤\x03 {} \x0304❤'.format(args.get('<nick>', mask.nick))
2017-05-15 22:26:10 +00:00
@command
2017-08-22 13:57:57 +00:00
def hug(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +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-08-22 13:16:29 +00:00
return '\x0304♥♡❤♡♥\x03 {} \x0304♥♡❤♡♥'.format(args.get('<nick>', mask.nick))
2017-05-15 22:26:10 +00:00
@command
2017-08-22 13:57:57 +00:00
def bier(self, mask: IrcString, target: IrcString, args: Dict):
"""Gives a user a beer
2017-06-01 15:38:34 +00:00
%%bier [<nick>]
"""
nick = args.get('<nick>', mask.nick)
2017-07-07 00:11:20 +00:00
self.bot.action(target, 'schenkt ein kühles Blondes an {} aus.'.format(nick))
@command
2017-08-22 13:57:57 +00:00
def fucken(self, mask: IrcString, target: IrcString, args: Dict):
"""Kills and fucks a user
2017-06-01 15:38:34 +00:00
%%fucken [<nick>]
"""
nick = args.get('<nick>', mask.nick)
2017-07-07 00:11:20 +00:00
self.bot.action(target, 'fuckt {0} und tötet {0} anschließend.'.format(nick, nick))
@command(aliases=['anhero', 'sudoku'])
2017-08-22 13:57:57 +00:00
def seppuku(self, mask: IrcString, target: IrcString, args: Dict):
"""Kicks a user
%%seppuku
"""
2017-07-31 13:29:59 +00:00
self.bot.kick(target, mask.nick, 'Sayonara bonzai-chan...')
@command
2017-08-22 13:57:57 +00:00
def hack(self, mask: IrcString, target: IrcString, args: Dict):
"""Hacks (a user)
2017-05-28 11:27:40 +00:00
%%hack [<nick>]
"""
nick = args.get('<nick>')
2017-07-07 00:11:20 +00:00
return 'hacking{}...'.format(' %s' % nick if nick else '')
2017-05-15 22:26:10 +00:00
@command
2017-08-22 13:57:57 +00:00
def gay(self, mask: IrcString, target: IrcString, args: Dict):
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, target, args)
2017-05-15 22:26:10 +00:00
@command
2017-08-22 13:57:57 +00:00
def rainbow(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +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-08-22 13:57:57 +00:00
def wrainbow(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +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-08-22 14:23:54 +00:00
@command(aliases=['hw'])
2017-08-22 13:57:57 +00:00
def halfwidth(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 12:57:07 +00:00
"""Turns UPPERCASE words into halfwidth characters
2017-08-22 13:16:29 +00:00
%%halfwidth <words>...
2017-08-22 12:57:07 +00:00
"""
2017-08-22 13:16:29 +00:00
def replace(match):
2017-08-22 13:08:33 +00:00
return ''.join(chr(0xFF20 + (ord(c) - 64)) for c in match.group(0))
2017-08-22 13:16:29 +00:00
return '\x02[HALFWIDTH]\x02 {}'.format(re.sub(r'(?:\b)[A-Z]+(?:\b)', replace, ' '.join(args['<words>'])))
2017-08-22 12:57:07 +00:00
@command
2017-08-22 13:57:57 +00:00
def asshole(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +00:00
"""Checks how much of an asshole you are
2017-08-18 09:31:56 +00:00
%%asshole [<nick>]
"""
nick = args.get('<nick>', mask.nick)
2017-08-18 09:31:56 +00:00
2017-08-22 09:31:32 +00:00
if nick.lower() == 'mrhanky':
2017-08-21 16:33:26 +00:00
perc_min = 100
2017-08-22 09:31:32 +00:00
elif nick.lower() == 'flummi':
2017-08-21 16:33:26 +00:00
perc_min = 90
else:
perc_min = 0
2017-08-18 09:31:56 +00:00
2017-08-21 16:33:26 +00:00
asshole_perc = random.randint(perc_min, 100)
2017-08-21 11:38:31 +00:00
return 'Asshole scan... {} is {}% of an asshole.'.format(nick, asshole_perc)
2017-08-18 09:31:56 +00:00
2017-08-18 10:01:06 +00:00
@command
2017-08-22 13:57:57 +00:00
def assume(self, mask: IrcString, target: IrcString, args: Dict):
2017-08-22 13:16:29 +00:00
"""Assumes the gender of a nick or yourself
2017-08-18 10:01:06 +00:00
%%assume [<nick>]
"""
nick = args.get('<nick>', mask.nick)
gender = random.choice(self.GENDERS)
2017-08-18 10:01:06 +00:00
2017-08-21 16:24:39 +00:00
return 'Assuming {}\'s gender... they\'re a {}.'.format(nick, gender)
2017-08-18 10:01:06 +00:00
2017-08-22 14:23:54 +00:00
@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))
2020-05-01 23:19:31 +00:00
@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))
2020-11-20 16:50:26 +00:00
@command
def vampir(self, mask: IrcString, target: IrcString, args: Dict):
"""Sends a url with the cute vampire cat :3
%%vampir
"""
2021-05-12 18:41:54 +00:00
return 'https://files.catbox.moe/ma2dfs.png'
2020-11-20 16:50:26 +00:00
2021-05-12 18:34:06 +00:00
@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)
2021-05-12 18:41:54 +00:00
self.bot.action(target, 'macht {0} klar, dass er sich lieber verpissen sollte!'.format(nick, nick))
2021-05-12 18:34:06 +00:00
2017-08-22 13:57:57 +00:00
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])
2017-07-07 00:11:20 +00:00
# noinspection PyMethodMayBeStatic
2017-07-04 13:22:20 +00:00
def _rainbow(self, i, char):
return '\x03{0:02d}{1}'.format(self.RAINBOW[i % len(self.RAINBOW)], char)