Esempio n. 1
0
    def func(self):
        "Implementing the function"
        caller = self.caller
        args = self.args

        if not args:
            caller.msg("Usage: @boot[/switches] <player> [:reason]")
            return

        if ':' in args:
            args, reason = [a.strip() for a in args.split(':', 1)]
        else:
            args, reason = args, ""

        boot_list = []

        if 'sid' in self.switches:
            # Boot a particular session id.
            sessions = SESSIONS.get_sessions(True)
            for sess in sessions:
                # Find the session with the matching session id.
                if sess.sessid == int(args):
                    boot_list.append(sess)
                    break
        else:
            # Boot by player object
            pobj = search.player_search(args)
            if not pobj:
                caller.msg("Player %s was not found." % args)
                return
            pobj = pobj[0]
            if not pobj.access(caller, 'boot'):
                string = "You don't have the permission to boot %s." % (
                    pobj.key, )
                caller.msg(string)
                return
            # we have a bootable object with a connected user
            matches = SESSIONS.sessions_from_player(pobj)
            for match in matches:
                boot_list.append(match)

        if not boot_list:
            caller.msg(
                "No matching sessions found. The Player does not seem to be online."
            )
            return

        # Carry out the booting of the sessions in the boot list.

        feedback = None
        if not 'quiet' in self.switches:
            feedback = "You have been disconnected by %s.\n" % caller.name
            if reason:
                feedback += "\nReason given: %s" % reason

        for session in boot_list:
            session.msg(feedback)
            session.player.disconnect_session_from_player(session)
Esempio n. 2
0
    def func(self):
        """Implementing the function"""
        caller = self.caller
        args = self.args

        if not args:
            caller.msg("Usage: @boot[/switches] <player> [:reason]")
            return

        if ':' in args:
            args, reason = [a.strip() for a in args.split(':', 1)]
        else:
            args, reason = args, ""

        boot_list = []

        if 'sid' in self.switches:
            # Boot a particular session id.
            sessions = SESSIONS.get_sessions(True)
            for sess in sessions:
                # Find the session with the matching session id.
                if sess.sessid == int(args):
                    boot_list.append(sess)
                    break
        else:
            # Boot by player object
            pobj = search.player_search(args)
            if not pobj:
                caller.msg("Player %s was not found." % args)
                return
            pobj = pobj[0]
            if not pobj.access(caller, 'boot'):
                string = "You don't have the permission to boot %s." % (pobj.key, )
                caller.msg(string)
                return
            # we have a bootable object with a connected user
            matches = SESSIONS.sessions_from_player(pobj)
            for match in matches:
                boot_list.append(match)

        if not boot_list:
            caller.msg("No matching sessions found. The Player does not seem to be online.")
            return

        # Carry out the booting of the sessions in the boot list.

        feedback = None
        if 'quiet' not in self.switches:
            feedback = "You have been disconnected by %s.\n" % caller.name
            if reason:
                feedback += "\nReason given: %s" % reason

        for session in boot_list:
            session.msg(feedback)
            session.player.disconnect_session_from_player(session)
Esempio n. 3
0
 def at_repeat(self):
     """
     Called self.interval seconds to keep connection. We cannot use
     the IDLE command from inside the game since the system will
     not catch it (commands executed from the server side usually
     has no sessions). So we update the idle counter manually here
     instead. This keeps the bot getting hit by IDLE_TIMEOUT.
     """
     global _SESSIONS
     if not _SESSIONS:
         from evennia.server.sessionhandler import SESSIONS as _SESSIONS
     for session in _SESSIONS.sessions_from_player(self.player):
         session.update_session_counters(idle=True)
Esempio n. 4
0
    def get_all_sessions(self):
        """
        Get all sessions connected to this player.

        Returns:
            sessions (list): All Sessions currently connected to this
                player.

        """
        global _SESSIONS
        if not _SESSIONS:
            from evennia.server.sessionhandler import SESSIONS as _SESSIONS
        return _SESSIONS.sessions_from_player(self)
Esempio n. 5
0
    def get_all_sessions(self):
        """
        Get all sessions connected to this player.

        Returns:
            sessions (list): All Sessions currently connected to this
                player.

        """
        global _SESSIONS
        if not _SESSIONS:
            from evennia.server.sessionhandler import SESSIONS as _SESSIONS
        return _SESSIONS.sessions_from_player(self)
Esempio n. 6
0
 def at_repeat(self):
     """
     Called self.interval seconds to keep connection. We cannot use
     the IDLE command from inside the game since the system will
     not catch it (commands executed from the server side usually
     has no sessions). So we update the idle counter manually here
     instead. This keeps the bot getting hit by IDLE_TIMEOUT.
     """
     global _SESSIONS
     if not _SESSIONS:
         from evennia.server.sessionhandler import SESSIONS as _SESSIONS
     for session in _SESSIONS.sessions_from_player(self.player):
         session.update_session_counters(idle=True)
Esempio n. 7
0
    def get(self, sessid=None):
        """
        Get the sessions linked to this object.

        Args:
            sessid (int, optional): Specify a given session by
                session id.

        Returns:
            sessions (list): A list of Session objects. If `sessid`
                is given, this is a list with one (or zero) elements.

        """
        global _SESSIONS
        if not _SESSIONS:
            from evennia.server.sessionhandler import SESSIONS as _SESSIONS
        if sessid:
            return make_iter(_SESSIONS.session_from_player(self.player, sessid))
        else:
            return _SESSIONS.sessions_from_player(self.player)
Esempio n. 8
0
    def get(self, sessid=None):
        """
        Get the sessions linked to this object.

        Args:
            sessid (int, optional): Specify a given session by
                session id.

        Returns:
            sessions (list): A list of Session objects. If `sessid`
                is given, this is a list with one (or zero) elements.

        """
        global _SESSIONS
        if not _SESSIONS:
            from evennia.server.sessionhandler import SESSIONS as _SESSIONS
        if sessid:
            return make_iter(_SESSIONS.session_from_player(self.player, sessid))
        else:
            return _SESSIONS.sessions_from_player(self.player)
Esempio n. 9
0
 def get_all_sessions(self):
     "Return all sessions connected to this player"
     global _SESSIONS
     if not _SESSIONS:
         from evennia.server.sessionhandler import SESSIONS as _SESSIONS
     return _SESSIONS.sessions_from_player(self)
Esempio n. 10
0
 def get_all_sessions(self):
     "Return all sessions connected to this player"
     global _SESSIONS
     if not _SESSIONS:
         from evennia.server.sessionhandler import SESSIONS as _SESSIONS
     return _SESSIONS.sessions_from_player(self)