TehKuh regex, rollback and print(exception) for waifu
This commit is contained in:
parent
71ab473f01
commit
3e86c605f8
|
@ -1,10 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import random
|
||||
import re
|
||||
|
||||
import irc3
|
||||
from docopt import Dict as DocOptDict
|
||||
from irc3.plugins.command import command
|
||||
from irc3.utils import IrcString
|
||||
from psycopg2 import Error
|
||||
|
||||
from . import DatabasePlugin
|
||||
|
||||
|
@ -23,17 +25,9 @@ class Useless(DatabasePlugin):
|
|||
'keep your woahs to yourself',
|
||||
)
|
||||
|
||||
ISP_HOSTS = (
|
||||
'vodafone',
|
||||
'telefonica',
|
||||
'kabel',
|
||||
'unity-media',
|
||||
)
|
||||
|
||||
@irc3.event(r'(?i)^:(?P<mask>\S+) JOIN :(?P<target>#\S+)$')
|
||||
def tehkuh(self, mask, target):
|
||||
nick = IrcString(mask).nick
|
||||
if 'TehKuh' in mask.lower() and self.ISP_HOSTS in mask.lower():
|
||||
if re.search(r'(?i).*(tehkuh).*@.*(telefonica|vodafone|kabel|unity-media).*', mask):
|
||||
self.bot.privmsg(target, '{}: Bouncer'.format(nick))
|
||||
|
||||
@irc3.event(r'(?i)^:\S+ PRIVMSG (?P<target>\S+) :.*(woah|whoa).*$')
|
||||
|
@ -112,6 +106,7 @@ class Useless(DatabasePlugin):
|
|||
if nick.startswith('='):
|
||||
waifu = nick[1:]
|
||||
|
||||
try:
|
||||
self.cur.execute('''
|
||||
insert into
|
||||
users (nick, waifu)
|
||||
|
@ -123,6 +118,9 @@ class Useless(DatabasePlugin):
|
|||
|
||||
self.bot.notice(mask.nick, 'Waifu set to: {waifu}'
|
||||
.format(waifu=waifu))
|
||||
except Error as ex:
|
||||
print(ex)
|
||||
self.con.rollback()
|
||||
else:
|
||||
self.cur.execute('''
|
||||
select
|
||||
|
|
Loading…
Reference in New Issue
Block a user