nxy/bot/plugins/__init__.py
2017-07-31 15:29:59 +02:00

32 lines
724 B
Python

# -*- coding: utf-8 -*-
from irc3 import IrcBot
from irc3.plugins.command import Commands
MODULE = __name__
class BasePlugin(object):
def __init__(self, bot: 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: 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