Import cleanup

This commit is contained in:
mrhanky 2017-05-29 14:40:58 +02:00
parent c1ddb10e06
commit db8b0a4d4c
No known key found for this signature in database
GPG Key ID: 67D772C481CB41B8
5 changed files with 13 additions and 18 deletions

View File

@ -2,7 +2,6 @@
import irc3 import irc3
from docopt import Dict as DocoptDict from docopt import Dict as DocoptDict
from irc3 import IrcBot
from irc3.plugins.command import command from irc3.plugins.command import command
from irc3.utils import IrcString from irc3.utils import IrcString
@ -10,7 +9,8 @@ from . import MODULE, Plugin
@command(permission='admin', show_in_help_list=False) @command(permission='admin', show_in_help_list=False)
def reload(bot: IrcBot, mask: IrcString, channel: IrcString, args: DocoptDict): def reload(bot: irc3.IrcBot, mask: IrcString, channel: IrcString,
args: DocoptDict):
"""Reloads a plugin or the whole bot """Reloads a plugin or the whole bot
%%reload [<plugin>] %%reload [<plugin>]

View File

@ -2,14 +2,12 @@
import sqlite3 import sqlite3
import irc3 import irc3
from irc3 import IrcBot
from . import Plugin from . import Plugin
@irc3.plugin @irc3.plugin
class Database(Plugin): class Database(Plugin):
def __init__(self, bot: IrcBot): def __init__(self, bot: irc3.IrcBot):
super().__init__(bot) super().__init__(bot)
file = bot.config.storage.split('sqlite://', 1)[1] file = bot.config.storage.split('sqlite://', 1)[1]
if not file: if not file:

View File

@ -2,7 +2,7 @@
from docopt import Dict as DocOptDict from docopt import Dict as DocOptDict
from irc3.plugins.command import command from irc3.plugins.command import command
from irc3.utils import IrcString from irc3.utils import IrcString
from irc3 import event import irc3
from . import DatabasePlugin from . import DatabasePlugin
from ..utils import parse_int from ..utils import parse_int
@ -40,10 +40,9 @@ class McManiac(DatabasePlugin):
if result: if result:
return '[{idx}/{len}] {item}'.format(**result) return '[{idx}/{len}] {item}'.format(**result)
@event(r'(?i)^:(?P<mask>\S+) PRIVMSG \S+ :(?P<msg>.*(?P<item>Mc\S+iaC).*)') @irc3.event(r'(?i)^:(?P<mask>\S+) PRIVMSG \S+ :(?P<msg>.*(?P<item>Mc\S+iaC).*)')
def check(self, mask: str, msg: str, item: str): def save(self, mask: str, msg: str, item: str):
nick = IrcString(mask).nick nick = IrcString(mask).nick
if nick != self.bot.nick and msg != '.reload mcmaniac': if nick != self.bot.nick and msg != '.reload mcmaniac':
self.cur.execute('insert into mcmaniacs (item) values (?)', [item]) self.cur.execute('insert into mcmaniacs (item) values (?)', [item])
self.con.commit() self.con.commit()
self.bot.notice(nick, '[McManiac] added "{}"'.format(item))

View File

@ -2,7 +2,6 @@
from docopt import Dict as DocOptDict from docopt import Dict as DocOptDict
from irc3.plugins.command import command from irc3.plugins.command import command
from irc3.utils import IrcString from irc3.utils import IrcString
from irc3 import IrcBot, event
import irc3 import irc3
from . import DatabasePlugin from . import DatabasePlugin
@ -13,7 +12,7 @@ class Tell(DatabasePlugin):
requires = ['irc3.plugins.command', requires = ['irc3.plugins.command',
'nxy.plugins.database'] 'nxy.plugins.database']
def __init__(self, bot: IrcBot): def __init__(self, bot: irc3.IrcBot):
super().__init__(bot) super().__init__(bot)
self.tell_queue = {} self.tell_queue = {}
# Restore tells from database # Restore tells from database
@ -39,7 +38,7 @@ class Tell(DatabasePlugin):
'values (?, ?, ?)', tell) 'values (?, ?, ?)', tell)
self.con.commit() self.con.commit()
@event(r'(?i)^:(?P<mask>.*) PRIVMSG .* :.*') @irc3.event(r'(?i)^:(?P<mask>.*) PRIVMSG .* :.*')
def check(self, mask: str): def check(self, mask: str):
"""If activ user has tells, forward and delete them.""" """If activ user has tells, forward and delete them."""
nick = IrcString(mask).nick nick = IrcString(mask).nick

View File

@ -3,7 +3,6 @@ import irc3
import random import random
from docopt import Dict as DocOptDict from docopt import Dict as DocOptDict
from irc3.dec import event
from irc3.plugins.command import command from irc3.plugins.command import command
from irc3.utils import IrcString from irc3.utils import IrcString
@ -26,21 +25,21 @@ GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring
class Useless(Plugin): class Useless(Plugin):
requires = ['irc3.plugins.command'] requires = ['irc3.plugins.command']
@event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :' @irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :'
r'.*(?<!gnu[/+])linux(?! kernel).*') r'.*(?<!gnu[/+])linux(?! kernel).*')
def linux(self, channel: str): def linux(self, channel: str):
if random.randint(0, 4) is 0: if random.randint(0, 4) is 0:
self.bot.privmsg(channel, GNU_LINUX) self.bot.privmsg(channel, GNU_LINUX)
@event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :(?P<msg>huehuehue)$') @irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :(?P<msg>huehuehue)$')
def huehuehue(self, channel: str, msg: str): def huehuehue(self, channel: str, msg: str):
self.bot.privmsg(channel, msg) self.bot.privmsg(channel, msg)
@event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :same$') @irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :same$')
def same(self, channel: str): def same(self, channel: str):
self.bot.privmsg(channel, 'same') self.bot.privmsg(channel, 'same')
@event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :\[(?P<data>.*)\]$') @irc3.event(r'(?i)^:\S+ PRIVMSG (?P<channel>\S+) :\[(?P<data>.*)\]$')
def intensifies(self, channel: str, data: str): def intensifies(self, channel: str, data: str):
self.bot.privmsg(channel, fmt('{bold}[{data} INTENSIFIES]', self.bot.privmsg(channel, fmt('{bold}[{data} INTENSIFIES]',
data=data.upper())) data=data.upper()))