nxy/bot/plugins/__init__.py

32 lines
724 B
Python
Raw Normal View History

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)
# Import the PgSQL storage plugin
2017-07-31 13:29:59 +00:00
from .storage import Storage # noqa
2017-05-15 22:26:10 +00:00
class DatabasePlugin(Plugin):
def __init__(self, bot: IrcBot):
2017-05-15 22:26:10 +00:00
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