Beispiel #1
0
import asyncio
import discord
import logging
import traceback
from libs import banpool
from discord import Embed, Color

banpool_manager = banpool.BanPoolManager()

# Setup Logging
logger = logging.getLogger('banpool_manager')
logger.setLevel(logging.DEBUG)

logger.info(
    "[Event Plugin] <banpool_events.py>: This plugin manages banpool related events."
)


@asyncio.coroutine
async def action(**kwargs):
    event_type = kwargs['event_type']
    config = kwargs['config']
    client = kwargs['client']

    if event_type == 'member.unban':
        # Grab configuration values
        admin_server_id = config.getint('banpool', 'admin_server_id')
        admin_chan_name = config.get('banpool', 'admin_chan')
        admin_server = discord.utils.get(client.guilds, id=admin_server_id)
        admin_chan = discord.utils.get(admin_server.channels,
                                       name=admin_chan_name)
Beispiel #2
0
from datetime import datetime

from libs import banpool

Base = declarative_base()
engine = create_engine('sqlite:///banpool_configuration.db')
Base.metadata.bind = engine
session_factory = sessionmaker(bind=engine)
Session = scoped_session(session_factory)
session = Session()

# Setup Logging
logger = logging.getLogger('banpool_configuration')

# Setup banpool manager
bpm = banpool.BanPoolManager()


class BanpoolConfigManager:
    def build_db(self):
        Base.metadata.create_all(engine)

    def set_announce_chan(self, server_id, channel_id, author, author_id):
        try:
            now = datetime.now()
            target_server = session.query(BanpoolConfig).filter(
                BanpoolConfig.server_id == server_id).first()

            # the server exists, set its channel
            if target_server:
                target_server.announce_chan = channel_id