Example #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 'port' in self.switches:
            # Boot a particular port.
            sessions = SESSIONS.get_session_list(True)
            for sess in sessions:
                # Find the session with the matching port number.
                if sess.getClientAddress()[1] == int(args):
                    boot_list.append(sess)
                    break
        else:
            # Boot by player object
            pobj = search.player_search(args)
            if not pobj:
                self.caller("Player %s was not found." % pobj.key)
                return
            pobj = pobj[0]
            if not pobj.access(caller, 'boot'):
                string = "You don't have the permission to boot %s."
                pobj.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)
            pobj.disconnect_session_from_player(session.sessid)
Example #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 "port" in self.switches:
            # Boot a particular port.
            sessions = SESSIONS.get_session_list(True)
            for sess in sessions:
                # Find the session with the matching port number.
                if sess.getClientAddress()[1] == int(args):
                    boot_list.append(sess)
                    break
        else:
            # Boot by player object
            pobj = search.player_search(args)
            if not pobj:
                self.caller("Player %s was not found." % pobj.key)
                return
            pobj = pobj[0]
            if not pobj.access(caller, "boot"):
                string = "You don't have the permission to boot %s."
                pobj.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)
            pobj.disconnect_session_from_player(session.sessid)
Example #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 src.server.sessionhandler import SESSIONS as _SESSIONS
     for session in _SESSIONS.sessions_from_player(self.player):
         session.update_session_counters(idle=True)
Example #4
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 src.server.sessionhandler import SESSIONS as _SESSIONS
     for session in _SESSIONS.sessions_from_player(self.player):
         session.update_session_counters(idle=True)
Example #5
0
    def merge_players(self, to_player, from_player):
        self.msg('Merging "%s" into "%s"...' % (from_player, to_player))
        self.msg('  Disconnecting %s (if applicable)...' % (from_player))
        from_player.unpuppet_all()
        for session in SESSIONS.sessions_from_player(from_player):
            from_player.msg('\nYour account has been merged into "%s".\n' % (to_player), sessid=session.sessid)
            from_player.disconnect_session_from_player(session.sessid)
        self.msg('  Transfering characters...')
        transfer_characters = from_player.get_characters()
        if transfer_characters:
            for character in transfer_characters:
                character.set_owner(to_player)
                character.locks.add("puppet:id(%i) or pid(%i) or perm(Janitors)" % (character.id, to_player.id))
                self.msg('    %s' % (character.key))
        else:
            self.msg('    No characters.')
        self.msg('  Transfering friends...')
        if from_player.db.friends_list:
            for friend in from_player.db.friends_list:
                if friend == to_player:
                    # Your other account is friends with you?
                    continue
                self.msg('      ' + friend.key)
                to_player.db.friends_list.add(friend)
        self.msg('  Transfering outstanding friend requests...')
        if from_player.db.friends_requests:
            for request_player in from_player.db.friends_requests:
                if request_player == to_player:
                    # Your other account sent you a friend request?
                    continue
                self.msg('      ' + request_player.key)
                to_player.db.friends_requests.add(request_player)
                # Alter this requesting player's friend roster if needed
                if from_player in request_player.db.friends_list:
                    request_player.db.friends_list.remove(from_player)
                    request_player.db.friends_list.add(to_player)
        self.msg('  Transfering bonuses...')
        if from_player.db.bonus_lat1:
            self.msg('    lat1')
            to_player.db.bonus_lat1 = True
        self.msg('  Deleting "%s"...' % (from_player))
#        from_player.user.delete()
        from_player.delete()
        self.msg('Merge from "%s" to "%s" complete.' % (from_player, to_player))
Example #6
0
 def get_all_sessions(self):
     "Return all sessions connected to this player"
     global _SESSIONS
     if not _SESSIONS:
         from src.server.sessionhandler import SESSIONS as _SESSIONS
     return _SESSIONS.sessions_from_player(self)
Example #7
0
 def get_all_sessions(self):
     "Return all sessions connected to this player"
     global _SESSIONS
     if not _SESSIONS:
         from src.server.sessionhandler import SESSIONS as _SESSIONS
     return _SESSIONS.sessions_from_player(self)
Example #8
0
 def sessions_get(self):
     "Getter. Retrieve sessions related to this player/user"
     return SESSIONS.sessions_from_player(self)
Example #9
0
 def sessions_get(self):
     "Getter. Retrieve sessions related to this player/user"
     global _SESSIONS
     if not _SESSIONS:
         from src.server.sessionhandler import SESSIONS as _SESSIONS
     return _SESSIONS.sessions_from_player(self)
Example #10
0
    def func(self):
        "Implements the command."

        caller = self.caller
        args = self.args

        if hasattr(caller, 'player'):
            caller = caller.player

        if not args:
            self.msg("Usage: @delplayer[/delobj] <player/user name or #id> [: reason]")
            return

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

        # We use player_search since we want to be sure to find also players
        # that lack characters.
        players = caller.search_player(args, quiet=True)

        if not players:
            # try to find a user instead of a Player
            try:
                user = User.objects.get(id=args)
            except Exception:
                try:
                    user = User.objects.get(username__iexact=args)
                except Exception:
                    string = "No Player nor User found matching '%s'." % args
                    self.msg(string)
                    return
            try:
                player = user.get_profile()
            except Exception:
                player = None

            if player and not player.access(caller, 'delete'):
                string = "You don't have the permissions to delete this player."
                self.msg(string)
                return

            string = ""
            name = user.username
            user.delete()
            if player:
                name = player.name
                player.delete()
                string = "Player %s was deleted." % name
            else:
                string += "The User %s was deleted. It had no Player associated with it." % name
            self.msg(string)
            return

        elif utils.is_iter(players):
            string = "There were multiple matches:"
            for player in players:
                string += "\n %s %s" % (player.id, player.key)
            return
        else:
            # one single match

            player = players
            user = player.user

            if not player.access(caller, 'delete'):
                string = "You don't have the permissions to delete that player."
                self.msg(string)
                return

            uname = user.username
            # boot the player then delete
            self.msg("Informing and disconnecting player ...")
            string = "\nYour account '%s' is being *permanently* deleted.\n" %  uname
            if reason:
                string += " Reason given:\n  '%s'" % reason
            player.unpuppet_all()
            for session in SESSIONS.sessions_from_player(player):
                player.msg(string, sessid=session.sessid)
                player.disconnect_session_from_player(session.sessid)
            user.delete()
            player.delete()
            self.msg("Player %s was successfully deleted." % uname)