Exemple #1
0
    async def _send_shutdown_message(self) -> None:
        message = IPCMessage(author=self.self_name,
                             action="shutdown",
                             reply_global=True,
                             data=None)

        await self.bot.redis.publish(self.global_channel,
                                     jsonpickle.encode(message))
Exemple #2
0
    async def _send_results(self, result: str) -> None:
        message = IPCMessage(author=self.self_name,
                             action="result",
                             reply_global=True,
                             data=result)

        await self.bot.redis.publish(self.global_channel,
                                     jsonpickle.encode(message))
Exemple #3
0
    async def _send_unload_message(self, extenstion: str) -> None:
        message = IPCMessage(author=self.self_name,
                             action="unload",
                             reply_global=True,
                             data=extenstion)

        await self.bot.redis.publish(self.global_channel,
                                     jsonpickle.encode(message))
Exemple #4
0
    async def _send_set_maintenance_message(self, enabled: bool) -> None:
        message = IPCMessage(author=self.self_name,
                             action="maintenance",
                             reply_global=True,
                             data=enabled)

        await self.bot.redis.publish(self.global_channel,
                                     jsonpickle.encode(message))
Exemple #5
0
    async def _send_eval_message(self, eval_code: str) -> None:
        message = IPCMessage(author=self.self_name,
                             action="eval",
                             reply_global=True,
                             data=eval_code)

        await self.bot.redis.publish(self.global_channel,
                                     jsonpickle.encode(message))
Exemple #6
0
    async def _send_set_game_news_message(self, game_news: str) -> None:
        message = IPCMessage(author=self.self_name,
                             action="set_game_news",
                             reply_global=False,
                             data=game_news)

        await self.bot.redis.publish(self.self_name,
                                     jsonpickle.encode(message))
Exemple #7
0
    async def _send_set_field_guard_message(self, duration: int) -> None:
        message = IPCMessage(author=self.self_name,
                             action="enable_guard",
                             reply_global=True,
                             data=duration)

        await self.bot.redis.publish(self.global_channel,
                                     jsonpickle.encode(message))
Exemple #8
0
    async def _send_set_items_message(self) -> None:
        message = IPCMessage(author=self.self_name,
                             action="set_items",
                             reply_global=True,
                             data=None)

        await self.bot.redis.publish(self.self_name,
                                     jsonpickle.encode(message))
Exemple #9
0
    async def send_delete_reminders_message(self, user_id: int) -> None:
        message = IPCMessage(author=self.self_name,
                             action="del_reminders",
                             reply_global=False,
                             data=user_id)

        await self.bot.redis.publish(self.self_name,
                                     jsonpickle.encode(message))
Exemple #10
0
    async def send_set_reminder_message(self, reminder: Reminder) -> None:
        message = IPCMessage(author=self.self_name,
                             action="add_reminder",
                             reply_global=False,
                             data=reminder)

        await self.bot.redis.publish(self.self_name,
                                     jsonpickle.encode(message))
Exemple #11
0
    async def _send_update_items_message(self, channel: str) -> None:
        message = IPCMessage(
            author=self.ipc_name,
            action="get_items",
            reply_global=False,
            data=jsonpickle.encode(self.item_pool)
        )

        await self.redis.publish(channel, jsonpickle.encode(message))
Exemple #12
0
    async def _send_ping_message(self, channel: str) -> None:
        message = IPCMessage(
            author=self.ipc_name,
            action="ping",
            reply_global=False,
            data=jsonpickle.encode(self.active_clusters)
        )

        await self.redis.publish(channel, jsonpickle.encode(message))
Exemple #13
0
    async def _send_get_game_news_message(self,
                                          reply_global: bool = False) -> None:
        message = IPCMessage(author=self.self_name,
                             action="get_game_news",
                             reply_global=reply_global,
                             data=None)

        await self.bot.redis.publish(self.self_name,
                                     jsonpickle.encode(message))
Exemple #14
0
    async def _send_set_game_guard_message(
        self,
        channel: str,
        duration: int
    ) -> None:
        message = IPCMessage(
            author=self.ipc_name,
            action="enable_guard",
            reply_global=False,
            data=duration
        )

        await self.redis.publish(channel, jsonpickle.encode(message))
Exemple #15
0
    async def _send_ping_message(self) -> None:
        self.last_ping = datetime.datetime.now()

        if hasattr(self.bot, "launch_time"):
            uptime = self.bot.uptime
        else:
            uptime = datetime.timedelta(seconds=0)

        cluster = Cluster(self.bot.cluster_name,
                          self.bot.latencies, self.bot.ipc_ping,
                          len(self.bot.guilds), self.last_ping, uptime)

        message = IPCMessage(author=self.self_name,
                             action="ping",
                             reply_global=False,
                             data=jsonpickle.encode(cluster))

        await self.bot.redis.publish(self.self_name,
                                     jsonpickle.encode(message))