diff --git a/README.md b/README.md index e69de29..7533013 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,29 @@ +* [x] .btc - prints current btc value +* [x] .finger - does a FINGER ctcp +* [x] .gay - colors text in rainbow colors +* [x] .hack - prints "hacking..." +* [x] .help - lists all available commands +* [x] .jn - returns yes or no for a given question +* [x] .kiss - kisses a user +* [x] .mcmaniac - shows McManiaC memes or adds a new one +* [x] .ping - pings a user and prints time +* [x] .q - print a quote of a user or adds one +* [x] .rainbow - same as .gay +* [x] .storyofpomfface - .... +* [x] .tell - stores a message for a user and sends it to him when he writes a message in any channel (shows activity) +* [x] .time - does a ctcp TIME on a user and prints the returned time +* [x] .timer - sets a timer for a specified amount of time and a name +* [x] .uptime - prints bot uptime +* [x] .ver - does a ctcp VERSION on a user and prints the returned version information +* [x] Bier Trigger – nxy schenkt ein kühles blondes an $nick aus +* [ ] REEEEEE Trigger – REEEEEEEEEEEEEEEEEEEEEEEEEEEE +* [x] Fucken Trigger – nxy fuckt $nick und tötet $nick anschließend. +* [ ] joke Trigger – Erzählt einen schlechten Witz +* [x] rape trigger +* [x] .choose - picks a random entry from a list seperated with commas +* [x] .kernel - displays current linux kernel info +* [x] .sudoku/.anhero - kicks the user that executes that command +* [x] .yt - search for a video on youtube +* [x] youtube url parser - returns video information if a youtube link is posted +* [ ] .seen trigger – returns the last message and date the user was seen in the channel +* [ ] .urban - queries urban dictionary diff --git a/config.json b/config.json index 95eead6..ec902a7 100644 --- a/config.json +++ b/config.json @@ -17,6 +17,7 @@ "nxy.plugins.linux", "nxy.plugins.mcmaniac", "nxy.plugins.quotes", + "nxy.plugins.rape", "nxy.plugins.seen", "nxy.plugins.tell", "nxy.plugins.timer", diff --git a/nxy/plugins/__init__.py b/nxy/plugins/__init__.py index e0dab03..188a505 100644 --- a/nxy/plugins/__init__.py +++ b/nxy/plugins/__init__.py @@ -19,18 +19,7 @@ class Plugin(BasePlugin): class DatabasePlugin(Plugin): - table = None - def __init__(self, bot): super().__init__(bot) self.con = bot.con.db self.cur = self.con.cursor() - - def _insert(self, **kwargs): - qry = 'insert into {table} ({rows}) values ({placeholders})'.format( - table=self.table, - rows=', '.join(kwargs), - placeholders=', '.join('?' * len(kwargs)) - ) - self.cur.execute(qry, list(kwargs.values())) - self.con.commit() diff --git a/nxy/plugins/mcmaniac.py b/nxy/plugins/mcmaniac.py index b94a296..346b9ef 100644 --- a/nxy/plugins/mcmaniac.py +++ b/nxy/plugins/mcmaniac.py @@ -45,4 +45,5 @@ class McManiac(DatabasePlugin): @irc3.event(r'(?i)^:(?P\S+) PRIVMSG \S+ :.*(?PMc\S+iaC).*') def save(self, mask: str, item: str): if IrcString(mask).nick != self.bot.nick: - self._insert(item=item) + self.cur.execute('insert into mcmaniacs (item) values (?)', [item]) + self.con.commit() diff --git a/nxy/plugins/quotes.py b/nxy/plugins/quotes.py index f887828..92601b1 100644 --- a/nxy/plugins/quotes.py +++ b/nxy/plugins/quotes.py @@ -13,7 +13,6 @@ from ..utils import NICK_REGEX, parse_int class Quotes(DatabasePlugin): requires = ['irc3.plugins.command', 'nxy.plugins.database'] - table = 'quotes' @command(options_first=True) def q(self, mask: IrcString, channel: IrcString, args: DocOptDict): @@ -31,7 +30,9 @@ class Quotes(DatabasePlugin): nick = NICK_REGEX.match(nick).group(1) if not nick: return '[Quotes] Error parsing nick' - self._insert(nick=nick, item=' '.join(item)) + self.cur.execute('insert into quotes (nick, item) values ' + '(?, ?', [nick, ' '.join(item)]) + self.con.commit() if cmd == 'del': index, order, op = parse_int(''.join(item), select=False) if not index: diff --git a/nxy/plugins/rape.py b/nxy/plugins/rape.py new file mode 100644 index 0000000..3e4e99e --- /dev/null +++ b/nxy/plugins/rape.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +import random + +from docopt import Dict as DocOptDict +from irc3.plugins.command import command +from irc3.utils import IrcString + +from . import DatabasePlugin + + +class Rape(DatabasePlugin): + requires = ['irc3.plugins.command', + 'nxy.plugins.database'] + + @command + def owe(self, mask: IrcString, channel: IrcString, args: DocOptDict): + """Shows how much a nick owes. + + %%owe [...] + """ + nick = ' '.join(args.get('')) or mask.nick + + if nick.startswith('@'): + nick = nick.lstrip('@').strip() + + self.cur.execute('select amount from owes where nick = ?', [nick]) + owes = self.cur.fetchone() + + if owes: + total = '5${total}'.format(total=owes['amount']) + else: + total = '3$0' + + return '{nick} owes: \x03{total}\x03'.format(nick=nick, total=total) + + @command + def rape(self, mask: IrcString, channel: IrcString, args: DocOptDict): + """Rapes a nick and eventually charge for it. + + %%rape + """ + nick = args.get('') or mask.nick + fine = random.randint(1, 500) + rand = random.randint(0, 3) + + if rand in (0, 1): + self.cur.execute('select amount from owes where nick = ?', [nick]) + owe = self.cur.fetchone() + + if owe: + total = owe['amount'] + fine + self.cur.execute('update owes set amount = ? where nick = ?', + [total, nick]) + else: + total = fine + self.cur.execute('insert into owes (nick, amount) values ' + '(?, ?)', [nick, total]) + self.con.commit() + + reason = ('raping', 'being too lewd and getting raped')[rand] + action = 'fines {nick} \x02${fine}\x02 for {reason}. You owe: ' \ + '\x0304${total}\x03'.format(nick=nick, + fine=fine, + reason=reason, + total=total) + else: + action = 'rapes {nick}'.format(nick=nick) + self.bot.action(channel, action) diff --git a/nxy/plugins/seen.py b/nxy/plugins/seen.py index 403fdbb..97eb7c1 100644 --- a/nxy/plugins/seen.py +++ b/nxy/plugins/seen.py @@ -13,7 +13,6 @@ from . import DatabasePlugin class Seen(DatabasePlugin): requires = ['irc3.plugins.command', 'nxy.plugins.database'] - table = 'seens' @command(options_first=True) def seen(self, mask: IrcString, channel: IrcString, args: DocOptDict): @@ -39,5 +38,7 @@ class Seen(DatabasePlugin): def save(self, mask: str, channel: str, msg: str): nick = IrcString(mask).nick if nick != self.bot.nick: - self._insert(nick=nick, channel=channel.lower(), message=msg, - last_seen=datetime.now()) + self.cur.execute('insert into seens (nick, channel, message, ' + 'last_seen) values (?, ?, ?, ?)', + [nick, channel.lower(), msg, datetime.now()]) + self.con.commit() diff --git a/nxy/plugins/tell.py b/nxy/plugins/tell.py index 2dbded1..22795c4 100644 --- a/nxy/plugins/tell.py +++ b/nxy/plugins/tell.py @@ -11,7 +11,6 @@ from . import DatabasePlugin class Tell(DatabasePlugin): requires = ['irc3.plugins.command', 'nxy.plugins.database'] - table = 'tells' def __init__(self, bot: irc3.IrcBot): super().__init__(bot) @@ -35,7 +34,9 @@ class Tell(DatabasePlugin): self.tell_queue[nick] = [] tell = [mask.nick.lower(), nick, ' '.join(args['']).strip()] self.tell_queue[nick].append(tell) - self._insert(from_user=tell[0], to_user=tell[1], message=tell[2]) + self.cur.execute('insert into tells (from_user, to_user, message) ' + 'values (?, ?, ?)', tell) + self.con.commit() @irc3.event(r'(?i)^:(?P.*) PRIVMSG .* :.*') def check(self, mask: str): diff --git a/nxy/plugins/timer.py b/nxy/plugins/timer.py index b385f30..5b120ee 100644 --- a/nxy/plugins/timer.py +++ b/nxy/plugins/timer.py @@ -15,7 +15,6 @@ from ..utils import time_delta class Timer(DatabasePlugin): requires = ['irc3.plugins.command', 'nxy.plugins.database'] - table = 'timers' def __init__(self, bot: irc3.IrcBot): super().__init__(bot) @@ -38,8 +37,11 @@ class Timer(DatabasePlugin): delta = time_delta(delay) if delta: message = ' '.join(args['']) - self._insert(mask=mask.nick, channel=channel, message=message, - delay=delay, until=datetime.utcnow() + delta) + self.cur.execute('insert into timers (mask, channel, message, ' + 'delay, until) values (?, ?, ?, ?, ?)', + [mask.nick, channel.lower(), message, delay, + datetime.utcnow() + delta]) + self.con.commit() asyncio.ensure_future(self._timer(mask, channel, delta, message, delay, self.cur.lastrowid)) self.bot.notice(mask.nick, 'Timer in {delay} set: {message}' diff --git a/nxy/plugins/useless.py b/nxy/plugins/useless.py index 1ab4ad0..7381af5 100644 --- a/nxy/plugins/useless.py +++ b/nxy/plugins/useless.py @@ -73,14 +73,48 @@ class Useless(Plugin): nick=args['']) @command - def hug(self, mask: IrcString, channel: IrcString, - args: DocOptDict) -> str: + def hug(self, mask: IrcString, channel: IrcString, args: DocOptDict): """Hugs a user. %%hug """ return '\x033♥♡❤♡♥\x0F {nick} \x033♥♡❤♡♥'.format(nick=args['']) + @command + def bier(self, mask: IrcString, channel: IrcString, args: DocOptDict): + """Gives nick a beer. + + %%bier + """ + return '\x01ACTION schenkt ein kühles blondes an {nick} aus.\x01' \ + .format(nick=args['']) + + @command + def fucken(self, mask: IrcString, channel: IrcString, args: DocOptDict): + """Kills and fucks a nick. + + %%fucken + """ + return '\x01ACTION fuckt {nick} und tötet {nick} anschließend.\x01' \ + .format(nick=args['']) + + @command + def anhero(self, mask: IrcString, channel: IrcString, args: DocOptDict): + """Kicks a nick. + + %%anhero + """ + self.bot.privmsg(channel, 'Sayonara bonzai-chan...') + self.bot.kick(channel, mask.nick) + + @command + def sudoku(self, mask: IrcString, channel: IrcString, args: DocOptDict): + """Kicks a nick. + + %%sudoku + """ + self.anhero(mask, channel, args) + @command def hack(self, mask: IrcString, channel: IrcString, args: DocOptDict): """Hacks (a user). diff --git a/schema.sql b/schema.sql index 320a821..342ffb7 100644 --- a/schema.sql +++ b/schema.sql @@ -38,3 +38,10 @@ create table if not exists seens ( last_seen timestamp not null, unique (nick) on conflict replace ); + +create table if not exists owes ( + id integer primary key autoincrement, + nick text not null collate nocase, + amount integer not null, + unique (nick) on conflict ignore +);