Removed DatabasePlugin._insert, added .rape and .owe
This commit is contained in:
parent
2dd9289ffd
commit
85a8c3985c
29
README.md
29
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
|
@ -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",
|
||||
|
@ -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()
|
||||
|
@ -45,4 +45,5 @@ class McManiac(DatabasePlugin):
|
||||
@irc3.event(r'(?i)^:(?P<mask>\S+) PRIVMSG \S+ :.*(?P<item>Mc\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()
|
||||
|
@ -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:
|
||||
|
68
nxy/plugins/rape.py
Normal file
68
nxy/plugins/rape.py
Normal file
@ -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>...]
|
||||
"""
|
||||
nick = ' '.join(args.get('<nick>')) 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>
|
||||
"""
|
||||
nick = args.get('<nick>') 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)
|
@ -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()
|
||||
|
@ -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['<message>']).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<mask>.*) PRIVMSG .* :.*')
|
||||
def check(self, mask: str):
|
||||
|
@ -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['<message>'])
|
||||
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}'
|
||||
|
@ -73,14 +73,48 @@ class Useless(Plugin):
|
||||
nick=args['<nick>'])
|
||||
|
||||
@command
|
||||
def hug(self, mask: IrcString, channel: IrcString,
|
||||
args: DocOptDict) -> str:
|
||||
def hug(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
"""Hugs a user.
|
||||
|
||||
%%hug <nick>
|
||||
"""
|
||||
return '\x033♥♡❤♡♥\x0F {nick} \x033♥♡❤♡♥'.format(nick=args['<nick>'])
|
||||
|
||||
@command
|
||||
def bier(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
"""Gives nick a beer.
|
||||
|
||||
%%bier <nick>
|
||||
"""
|
||||
return '\x01ACTION schenkt ein kühles blondes an {nick} aus.\x01' \
|
||||
.format(nick=args['<nick>'])
|
||||
|
||||
@command
|
||||
def fucken(self, mask: IrcString, channel: IrcString, args: DocOptDict):
|
||||
"""Kills and fucks a nick.
|
||||
|
||||
%%fucken <nick>
|
||||
"""
|
||||
return '\x01ACTION fuckt {nick} und tötet {nick} anschließend.\x01' \
|
||||
.format(nick=args['<nick>'])
|
||||
|
||||
@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).
|
||||
|
@ -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
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user