Beispiel #1
0
 def log(self, message, channel=True):
     """
     Emits session info to the appropriate outputs and info channels.
     """
     if channel:
         try:
             cchan = settings.CHANNEL_CONNECTINFO
             cchan = ChannelDB.objects.get_channel(cchan[0])
             cchan.msg("[%s]: %s" % (cchan.key, message))
         except Exception:
             pass
     logger.log_infomsg(message)
Beispiel #2
0
 def all_to_category(self, default_category):
     """
     Shifts all help entries in database to default_category.
     This action cannot be reverted. It is used primarily by
     the engine when importing a default help database, making
     sure this ends up in one easily separated category.
     """
     topics = self.all()
     for topic in topics:
         topic.help_category = default_category
         topic.save()
     string = "Help database moved to category %s" % default_category
     logger.log_infomsg(string)
Beispiel #3
0
 def func(self):
     "Define function"
     try:
         # Only allow shutdown if caller has session
         self.caller.sessions[0]
     except Exception:
         return
     self.msg('Shutting down server ...')
     announcement = "\nServer is being SHUT DOWN!\n"
     if self.args:
         announcement += "%s\n" % self.args
     logger.log_infomsg('Server shutdown by %s.' % self.caller.name)
     SESSIONS.announce_all(announcement)
     SESSIONS.portal_shutdown()
     SESSIONS.server.shutdown(mode='shutdown')
Beispiel #4
0
 def _send_to_connect_channel(self, message):
     "Helper method for loading the default comm channel"
     global _CONNECT_CHANNEL
     if not _CONNECT_CHANNEL:
         try:
             _CONNECT_CHANNEL = ChannelDB.objects.filter(db_key=settings.CHANNEL_CONNECTINFO[0])[0]
         except Exception:
             logger.log_trace()
     now = datetime.datetime.now()
     now = "%02i-%02i-%02i(%02i:%02i)" % (now.year, now.month,
                                          now.day, now.hour, now.minute)
     if _CONNECT_CHANNEL:
         _CONNECT_CHANNEL.tempmsg("[%s, %s]: %s" % (_CONNECT_CHANNEL.key, now, message))
     else:
         logger.log_infomsg("[%s]: %s" % (now, message))
Beispiel #5
0
    def connectionMade(self):
        """
        Triggered after connecting to the IMC2 network.
        """

        self.stopping = False
        self.factory.bot = self
        address = "%s@%s" % (self.mudname, self.network)
        self.init_session("ircbot", address, self.factory.sessionhandler)
        # link back and log in
        self.uid = int(self.factory.uid)
        self.logged_in = True
        self.factory.sessionhandler.connect(self)
        logger.log_infomsg("IMC2 bot connected to %s." % self.network)
        # Send authentication packet. The reply will be caught by lineReceived
        self._send_packet(pck.IMC2PacketAuthPlaintext())
Beispiel #6
0
 def signedOn(self):
     """
     This is called when we successfully connect to
     the network. We make sure to now register with
     the game as a full session.
     """
     self.join(self.channel)
     self.stopping = False
     self.factory.bot = self
     address = "%s@%s" % (self.channel, self.network)
     self.init_session("ircbot", address, self.factory.sessionhandler)
     # we link back to our bot and log in
     self.uid = int(self.factory.uid)
     self.logged_in = True
     self.factory.sessionhandler.connect(self)
     logger.log_infomsg(
         "IRC bot '%s' connected to %s at %s:%s." %
         (self.nickname, self.channel, self.network, self.port))
Beispiel #7
0
    def _imc_login(self, line):
        "Connect and identify to imc network"

        if self.auth_type == "plaintext":
            # Only support Plain text passwords.
            # SERVER Sends: PW <servername> <serverpw> version=<version#> <networkname>

            logger.log_infomsg("IMC2: AUTH< %s" % line)

            line_split = line.split(' ')
            pw_present = line_split[0] == 'PW'
            autosetup_present = line_split[0] == 'autosetup'

            if "reject" in line_split:
                auth_message = _("IMC2 server rejected connection.")
                logger.log_infomsg(auth_message)
                return

            if pw_present:
                self.server_name = line_split[1]
                self.network_name = line_split[4]
            elif autosetup_present:
                logger.log_infomsg(_("IMC2: Autosetup response found."))
                self.server_name = line_split[1]
                self.network_name = line_split[3]
            self.is_authenticated = True
            self.sequence = int(time())

            # Log to stdout and notify over MUDInfo.
            logger.log_infomsg('IMC2: Authenticated to %s' %
                               self.factory.network)

            # Ask to see what other MUDs are connected.
            self._send_packet(pck.IMC2PacketKeepAliveRequest())
            # IMC2 protocol states that KeepAliveRequests should be followed
            # up by the requester sending an IsAlive packet.
            self._send_packet(pck.IMC2PacketIsAlive())
            # Get a listing of channels.
            self._send_packet(pck.IMC2PacketIceRefresh())
Beispiel #8
0
 def startedConnecting(self, connector):
     "Tracks reconnections for debugging"
     logger.log_infomsg("(re)connecting to %s" % self.channel)