Пример #1
0
def listener():
    Db = Database()

    Db.execute(query='LISTEN "{}";'.format(os.environ["CONSOLE_ID"]))
    logger.info(
        'Waiting for notifications on channel "{}";'.format(os.environ["CONSOLE_ID"])
    )

    while True:
        Db.conn.poll()
        while Db.conn.notifies:
            notify = Db.conn.notifies.pop(0)
            logger.info(
                "Got NOTIFY:{} {} {}".format(notify.pid, notify.channel, notify.payload)
            )

            payload = json.loads(notify.payload)
            operation = payload["operation"]
            message = payload["message"]

            if operation in ["INSERT", "UPDATE"]:
                    job = """SELECT id, line_task_id, line_id, device_id, desired_state, exec_time, expire_time, status 
                    FROM jobs_queue
                    WHERE id = %(job_id)s"""
                messages = Db.execute(query=job, params={"job_id": message["id"]}, method="fetchone")
                msg = MsgAnalyzer(**message)
                msg.analyze_and_exec()
Пример #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, shard_count=1, **kwargs)
        self.owner_id = 300592580381376513
        self.start_time = dt.utcnow()
        self.commands_used = Counter()
        self.guilds_commands = Counter()
        self.guilds_messages = Counter()
        self.user_commands = Counter()
        self.announcements = [
            'ANUNCIE COMIGO: ENTRE NO MEU SERVIDOR E SAIBA COMO ANUNCIAR!',
            'SEJA VIP: SENDO VIP VOCÊ ACABA COM OS ANUNCIOS',
            'SISTEMA DE ANUNCIOS: O SISTEMA DE ANUNCIO EXISTE PARA EU PODER ME MANTER'
        ]
        self.languages = ("pt", "en")
        self.version = "5.0.0"
        self.server_ = "heroku"
        self.prefix_ = "'ash.', 'ash '"
        self.all_prefix = [
            'ash.', 'Ash.', 'aSh.', 'asH.', 'ASh.', 'aSH.', 'ASH.', 'AsH.',
            'ash ', 'Ash ', 'aSh ', 'asH ', 'ASh ', 'aSH ', 'ASH ', 'AsH '
        ]
        self.github = "https://github.com/Ashley-Lab/Ashley"
        self.progress = "V.5 -> 0.5%"
        self.data_cog = {}
        self.vip_cog = ['commands.music.default', 'commands.admin.staff']

        self.log_dir = os.path.dirname(__file__)
        self.logger = logging.getLogger('discord')
        self.logger.setLevel(logging.INFO)
        self.handler = logging.FileHandler(filename=os.path.join(
            self.log_dir, 'discord.log'),
                                           encoding='utf-8',
                                           mode='w')
        self.handler.setFormatter(
            logging.Formatter(
                '%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
        self.logger.addHandler(self.handler)

        self.db: Database = Database(self)
        self.data: DataInteraction = DataInteraction(self)

        self.staff = [235937029106434048, 300592580381376513]

        with open("resources/translations.json") as translations:
            self.translations = json.loads(translations.read())

        with open("resources/blacklist.json") as blacklist:
            self.blacklist = json.loads(blacklist.read())

        with open("resources/shutdown.json") as shutdown:
            self.shutdowns = json.loads(shutdown.read())
Пример #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, shard_count=1, **kwargs)
        self.owner_id = 300592580381376513
        self.start_time = dt.utcnow()
        self.cmd_event = {}
        self.commands_used = Counter()
        self.guilds_commands = Counter()
        self.guilds_messages = Counter()
        self.user_commands = Counter()
        self.blacklist = list()
        self.shutdowns = list()
        self.session = aiohttp.ClientSession()

        self.config = config
        self.em = self.config["emojis"]["msg"]
        self.color = int(config['config']['default_embed'], 16)
        self.announcements = self.config['attribute']['announcements']
        self.all_prefix = self.config['attribute']['all_prefix']
        self.vip_cog = self.config['attribute']['vip_cog']
        self.titling = self.config['attribute']['titling']
        self.boxes_l = self.config['attribute']['boxes_l']
        self.chests_l = self.config['attribute']['chests_l']
        self.boxes = self.config['attribute']['boxes']
        self.chests = self.config['attribute']['chests']
        self.money = self.config['attribute']['money']
        self.items = self.config['items']
        self.icons = self.config['icons']
        self.pets = self.config['pets']
        self.no_panning = self.config['attribute']['no_panning']
        self.testers = self.config['attribute']['testers']
        self.maintenance = False
        self.event_special = False
        self.help_emoji = {}

        self.log_dir = os.path.join('log', 'discord.log')
        self.logger = logging.getLogger('discord')
        self.logger.setLevel(logging.INFO)
        self.handler = logging.FileHandler(filename=self.log_dir,
                                           encoding='utf-8',
                                           mode='w')
        self.handler.setFormatter(
            logging.Formatter(
                '%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
        self.logger.addHandler(self.handler)

        self.server_ = "EXTRAVM.COM"
        self.progress = "V.9 -> 5.0%"
        self.python_version = "3.8.2"
        self.github = "https://github.com/Ashley-Lab/Ashley"
        self.staff = self.config['attribute']['staff']
        self.team = self.config['attribute']['team']
        self.version = "API: " + str(
            discord.__version__) + " | BOT: 9.0.50 | PROGRESS: " + str(
                self.progress)
        self.shortcut = self.config['attribute']['shortcut']
        self.block = self.config['attribute']['block']
        self.data_cog = {}
        self.box = {}
        self.chests_users = {}
        self.msg_cont = 0

        self.db: Database = Database(self)
        self.data: DataInteraction = DataInteraction(self)
        self.booster: Booster = Booster(self.items)