2017-05-15 22:26:10 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from irc3 import IrcBot
|
2017-05-16 10:06:29 +00:00
|
|
|
from irc3.plugins.command import Commands
|
2017-05-15 22:26:10 +00:00
|
|
|
|
|
|
|
MODULE = __name__
|
|
|
|
|
|
|
|
|
|
|
|
class BasePlugin(object):
|
|
|
|
def __init__(self, bot: IrcBot):
|
|
|
|
self.bot = bot
|
|
|
|
self.log = bot.log
|
2017-05-16 06:54:47 +00:00
|
|
|
self.guard = bot.get_plugin(Commands).guard
|
2017-05-15 22:26:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Plugin(BasePlugin):
|
|
|
|
@classmethod
|
|
|
|
def reload(cls, old: BasePlugin):
|
|
|
|
return cls(old.bot)
|
|
|
|
|
|
|
|
|
2017-06-30 11:25:56 +00:00
|
|
|
# Import the PgSQL storage plugin
|
2017-07-31 13:29:59 +00:00
|
|
|
from .storage import Storage # noqa
|
2017-06-30 11:25:56 +00:00
|
|
|
|
|
|
|
|
2017-05-15 22:26:10 +00:00
|
|
|
class DatabasePlugin(Plugin):
|
2017-06-30 11:25:56 +00:00
|
|
|
def __init__(self, bot: IrcBot):
|
2017-05-15 22:26:10 +00:00
|
|
|
super().__init__(bot)
|
2017-06-30 11:25:56 +00:00
|
|
|
# Get PgSQL storage instance and connection + cursor
|
|
|
|
self.db = bot.get_plugin(Storage)
|
|
|
|
self.con = self.db.con
|
|
|
|
self.cur = self.db.cur
|