33 lines
735 B
Python
33 lines
735 B
Python
# -*- coding: utf-8 -*-
|
|
import irc3
|
|
from irc3.plugins.command import Commands
|
|
|
|
MODULE = __name__
|
|
|
|
|
|
@irc3.plugin
|
|
class BasePlugin(object):
|
|
def __init__(self, bot: irc3.IrcBot):
|
|
self.bot = bot
|
|
self.log = bot.log
|
|
self.guard = bot.get_plugin(Commands).guard
|
|
|
|
|
|
class Plugin(BasePlugin):
|
|
@classmethod
|
|
def reload(cls, old: BasePlugin):
|
|
return cls(old.bot)
|
|
|
|
|
|
# Import the PgSQL storage plugin
|
|
from .storage import Storage # noqa
|
|
|
|
|
|
class DatabasePlugin(Plugin):
|
|
def __init__(self, bot: irc3.IrcBot):
|
|
super().__init__(bot)
|
|
# Get PgSQL storage instance and connection + cursor
|
|
self.db = bot.get_plugin(Storage)
|
|
self.con = self.db.con
|
|
self.cur = self.db.cur
|