Exemple #1
0
    def _universe(self, data, connection):
        """
        Universal chat. Sends a message that everyone can see.

        :param data: The packet containing the command.
        :param connection: The connection from which the packet came.
        :return: Null
        """
        if self.plugins['chat_manager'].mute_check(connection.player):
            send_message(connection, "You are muted and cannot chat.")
            return False
        if data:
            yield from self._send_to_server(data,
                                            ChatSendMode.UNIVERSE,
                                            connection)
            if link_plugin_if_available(self, "irc_bot"):
                # Try sending it to IRC if we have that available.
                asyncio.ensure_future(
                    self.plugins["irc_bot"].bot_write(
                        "<{}> {}".format(connection.player.alias,
                                         " ".join(data))))
            if link_plugin_if_available(self, "discord_bot"):
                discord = self.plugins['discord_bot']
                asyncio.ensure_future(discord.bot.send_message(
                    discord.bot.get_channel(discord.channel),
                    "**<{}>** {}".format(connection.player.alias, " ".join(
                        data))))
            return True
Exemple #2
0
 def activate(self):
     BasePlugin.activate(self)
     self.dispatcher = self.plugins.command_dispatcher
     self.irc_bot_exists = link_plugin_if_available(self, 'irc_bot')
     if self.irc_bot_exists:
         self.irc = self.plugins['irc_bot']
     self.prefix = self.config.get_plugin_config(
         "command_dispatcher")["command_prefix"]
     self.command_prefix = self.config.get_plugin_config(
         self.name)["command_prefix"]
     self.token = self.config.get_plugin_config(self.name)["token"]
     self.client_id = self.config.get_plugin_config(self.name)["client_id"]
     self.channel = self.config.get_plugin_config(self.name)["channel"]
     self.staff_channel = self.config.get_plugin_config(
         self.name)["staff_channel"]
     self.sc = self.config.get_plugin_config(self.name)["strip_colors"]
     asyncio.ensure_future(self.start_bot())
     self.update_id(self.client_id)
     self.mock_connection = MockConnection(self)
     self.rank_roles = self.config.get_plugin_config(
         self.name)["rank_roles"]
     if link_plugin_if_available(self, "chat_manager"):
         self.chat_manager = self.plugins['chat_manager']
     self.discord_logger = logging.getLogger("discord")
     self.discord_logger.setLevel(logging.INFO)
     ch = logging.StreamHandler()
     ch.setFormatter(
         logging.Formatter(
             '%(asctime)s - %(levelname)s - '
             '%(name)s # %(message)s',
             datefmt='%Y-%m-%d %H:%M:%S'))
     self.discord_logger.addHandler(ch)
 def activate(self):
     BasePlugin.activate(self)
     self.dispatcher = self.plugins.command_dispatcher
     self.irc_bot_exists = link_plugin_if_available(self, 'irc_bot')
     if self.irc_bot_exists:
         self.irc = self.plugins['irc_bot']
     self.prefix = self.config.get_plugin_config("command_dispatcher")[
         "command_prefix"]
     self.command_prefix = self.config.get_plugin_config(self.name)[
         "command_prefix"]
     self.token = self.config.get_plugin_config(self.name)["token"]
     self.client_id = self.config.get_plugin_config(self.name)["client_id"]
     self.channel = self.config.get_plugin_config(self.name)["channel"]
     self.staff_channel = self.config.get_plugin_config(self.name)[
         "staff_channel"]
     self.sc = self.config.get_plugin_config(self.name)["strip_colors"]
     asyncio.ensure_future(self.start_bot())
     self.update_id(self.client_id)
     self.mock_connection = MockConnection(self)
     self.rank_roles = self.config.get_plugin_config(self.name)[
         "rank_roles"]
     if link_plugin_if_available(self, "chat_manager"):
         self.chat_manager = self.plugins['chat_manager']
     self.discord_logger = logging.getLogger("discord")
     self.discord_logger.setLevel(logging.INFO)
     ch = logging.StreamHandler()
     ch.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - '
                                       '%(name)s # %(message)s',
                                       datefmt='%Y-%m-%d %H:%M:%S'))
     self.discord_logger.addHandler(ch)
 def activate(self):
     super().activate()
     self.command_dispatcher = self.plugins.command_dispatcher.plugin_config
     self.colors = self.config.get_plugin_config(self.name)["colors"]
     self.cts = self.config.get_plugin_config(self.name)["chat_timestamps"]
     self.cts_color = self.config.get_plugin_config(self.name)[
         "timestamp_color"]
     link_plugin_if_available(self, "irc_bot")
Exemple #5
0
 def activate(self):
     super().activate()
     self.command_dispatcher = self.plugins.command_dispatcher.plugin_config
     self.colors = self.config.get_plugin_config(self.name)["colors"]
     self.cts = self.config.get_plugin_config(self.name)["chat_timestamps"]
     self.cts_color = self.config.get_plugin_config(
         self.name)["timestamp_color"]
     link_plugin_if_available(self, "irc_bot")
Exemple #6
0
 def activate(self):
     super().activate()
     self.command_dispatcher = self.plugins.command_dispatcher.plugin_config
     self.colors = self.config.get_plugin_config(self.name)["colors"]
     self.cts = self.config.get_plugin_config(self.name)["chat_timestamps"]
     self.cts_color = self.config.get_plugin_config(self.name)[
         "timestamp_color"]
     self.last_whisper = {}
     link_plugin_if_available(self, "irc_bot")
     if "ignores" not in self.storage:
         self.storage["ignores"] = {}
 def activate(self):
     super().activate()
     self.modchat_color = self.config.get_plugin_config(self.name)[
         "modchat_color"]
     self.report_prefix = self.config.get_plugin_config(self.name)[
         "report_prefix"]
     self.broadcast_prefix = self.config.get_plugin_config(self.name)[
         "broadcast_prefix"]
     if link_plugin_if_available(self, 'mail'):
         self.mail = self.plugins.mail
     if link_plugin_if_available(self, 'discord_bot'):
         self.discord = self.plugins.discord_bot
     if link_plugin_if_available(self, 'chat_enhancements'):
         self.chat_enhancements = self.plugins.chat_enhancements
 def activate(self):
     super().activate()
     self.modchat_color = self.config.get_plugin_config(
         self.name)["modchat_color"]
     self.report_prefix = self.config.get_plugin_config(
         self.name)["report_prefix"]
     self.broadcast_prefix = self.config.get_plugin_config(
         self.name)["broadcast_prefix"]
     if link_plugin_if_available(self, 'mail'):
         self.mail = self.plugins.mail
     if link_plugin_if_available(self, 'discord_bot'):
         self.discord = self.plugins.discord_bot
     if link_plugin_if_available(self, 'chat_enhancements'):
         self.chat_enhancements = self.plugins.chat_enhancements
Exemple #9
0
    def activate(self):
        super().activate()
        self.connection = MockConnection(self)
        self.dispatcher = self.plugins.command_dispatcher
        self.prefix = self.config.get_plugin_config("command_dispatcher")[
            "command_prefix"]
        self.server = self.config.get_plugin_config(self.name)["server"]
        self.channel = self.config.get_plugin_config(self.name)["channel"]
        self.username = self.config.get_plugin_config(self.name)["username"]
        self.sc = self.config.get_plugin_config(self.name)["strip_colors"]

        self.bot = irc3.IrcBot(nick=self.username,
                               autojoins=[self.channel],
                               host=self.server)
        self.bot.log = self.logger

        self.bot.include("irc3.plugins.core")
        self.bot.include("irc3.plugins.userlist")

        x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
        x.compile(None)
        y = irc3.event(r"^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)",
                       self.name_check)
        y.compile(None)
        z = irc3.event(irc3.rfc.JOIN_PART_QUIT, self.announce_irc_join)
        z.compile(None)
        self.bot.attach_events(x)
        self.bot.attach_events(y)
        self.bot.attach_events(z)
        self.bot.create_connection()

        self.discord_active = link_plugin_if_available(self, 'discord_bot')

        self.ops = set()
        asyncio.ensure_future(self.update_ops())
Exemple #10
0
    def send_to_game(cls, message):
        """
        Broadcast a message on the server. Make sure it isn't coming from the
        bot (or else we get duplicate messages).

        :param message: The message packet.
        :return: Null
        """
        nick = message.author.display_name
        text = message.clean_content
        server = message.server
        if message.author.id != cls.client_id:
            if message.content[0] == ".":
                asyncio.ensure_future(cls.handle_command(message.content[1:]))
            else:
                for emote in server.emojis:
                    text = text.replace("<:{}:{}>".format(emote.name,emote.id),
                                        ":{}:".format(emote.name))
                yield from cls.factory.broadcast("<^orange;Discord^reset;> <{}> {}"
                                                 "".format(nick, text),
                                                 mode=ChatReceiveMode.BROADCAST)
                if cls.config.get_plugin_config(cls.name)["log_discord"]:
                    cls.logger.info("<{}> {}".format(nick, text))
                if link_plugin_if_available(cls, "irc_bot"):
                    asyncio.ensure_future(cls.plugins['irc_bot'].bot_write(
                                          "<DC><{}> {}".format(nick, text)))
Exemple #11
0
 def activate(self):
     super().activate()
     self.maintenance = False
     self.rejection_message = self.config.get_plugin_config(self.name)[
         "maintenance_message"]
     self.start_time = datetime.datetime.now()
     if link_plugin_if_available(self, "chat_manager"):
         self.chat_manager = self.plugins["chat_manager"]
 def activate(self):
     super().activate()
     self.connection = MockConnection(self)
     DiscordPlugin.connection = self.connection
     self.dispatcher = self.plugins.command_dispatcher
     DiscordPlugin.dispatcher = self.dispatcher
     self.irc_bot_exists = link_plugin_if_available(self, 'irc_bot')
     DiscordPlugin.irc_bot_exists = self.irc_bot_exists
     self.prefix = self.config.get_plugin_config(
         "command_dispatcher")["command_prefix"]
     self.token = self.config.get_plugin_config(self.name)["token"]
     self.client_id = self.config.get_plugin_config(self.name)["client_id"]
     self.channel = self.config.get_plugin_config(self.name)["channel"]
     self.sc = self.config.get_plugin_config(self.name)["strip_colors"]
     asyncio.ensure_future(self.start_bot())
     self.update_id(self.client_id)
     if link_plugin_if_available(self, "chat_manager"):
         self.chat_manager = self.plugins['chat_manager']
Exemple #13
0
    def activate(self):
        self.enabled = self.config.get_plugin_config(self.name)["enabled"]
        if not self.enabled:
            return
        super().activate()
        self.dispatcher = self.plugins.command_dispatcher
        self.prefix = self.config.get_plugin_config("command_dispatcher")[
            "command_prefix"]
        self.command_prefix = self.config.get_plugin_config(self.name)[
            "command_prefix"]
        self.server = self.config.get_plugin_config(self.name)["server"]
        self.channel = self.config.get_plugin_config(self.name)["channel"]
        self.username = self.config.get_plugin_config(self.name)["username"]
        self.sc = self.config.get_plugin_config(self.name)["strip_colors"]

        self.bot = irc3.IrcBot(nick=self.username,
                               autojoins=[self.channel],
                               host=self.server)
        self.bot.log = self.logger

        self.bot.include("irc3.plugins.core")
        self.bot.include("irc3.plugins.userlist")

        x = irc3.event(irc3.rfc.PRIVMSG, self.forward)
        x.compile(None)
        y = irc3.event(r"^:\S+ 353 [^&#]+(?P<channel>\S+) :(?P<nicknames>.*)",
                       self.name_check)
        y.compile(None)
        z = irc3.event(irc3.rfc.JOIN_PART_QUIT, self.announce_irc_join)
        z.compile(None)
        self.bot.attach_events(x)
        self.bot.attach_events(y)
        self.bot.attach_events(z)
        self.bot.create_connection()

        self.discord_active = link_plugin_if_available(self, 'discord_bot')
        if self.discord_active:
            self.discord = self.plugins['discord_bot']
        if link_plugin_if_available(self, "chat_manager"):
            self.chat_manager = self.plugins['chat_manager']

        self.ops = set()
        self.connection = MockConnection(self)
        asyncio.ensure_future(self.update_ops())
Exemple #14
0
 def activate(self):
     super().activate()
     if "owners" not in self.storage:
         self.storage["owners"] = {}
     if "access" not in self.storage:
         self.storage["access"] = {}
     self.max_claims = self.config.get_plugin_config(self.name)[
         "max_claims_per_person"]
     if link_plugin_if_available(self, "planet_announcer"):
         self.planet_announcer = self.plugins["planet_announcer"]
Exemple #15
0
 def activate(self):
     super().activate()
     if "owners" not in self.storage:
         self.storage["owners"] = {}
     if "access" not in self.storage:
         self.storage["access"] = {}
     self.max_claims = self.config.get_plugin_config(
         self.name)["max_claims_per_person"]
     if link_plugin_if_available(self, "planet_announcer"):
         self.planet_announcer = self.plugins["planet_announcer"]
Exemple #16
0
 def activate(self):
     super().activate()
     link_plugin_if_available(self, "irc_bot")
     link_plugin_if_available(self, "chat_enhancements")
Exemple #17
0
 def activate(self):
     super().activate()
     self.irc_active = link_plugin_if_available(self, "irc_bot")
     self.discord_active = link_plugin_if_available(self, "discord_bot")
     self.chat_enhancements = link_plugin_if_available(self,
                                                       "chat_enhancements")
Exemple #18
0
 def activate(self):
     super().activate()
     self.irc_active = link_plugin_if_available(self, "irc_bot")
     self.discord_active = link_plugin_if_available(self, "discord_bot")
     self.chat_enhancements = link_plugin_if_available(
         self, "chat_enhancements")
Exemple #19
0
 def activate(self):
     super().activate()
     link_plugin_if_available(self, "irc_bot")
     link_plugin_if_available(self, "chat_enhancements")