当前位置: 首页>>代码示例>>Python>>正文


Python SESSIONS.sessions_from_player方法代码示例

本文整理汇总了Python中src.server.sessionhandler.SESSIONS.sessions_from_player方法的典型用法代码示例。如果您正苦于以下问题:Python SESSIONS.sessions_from_player方法的具体用法?Python SESSIONS.sessions_from_player怎么用?Python SESSIONS.sessions_from_player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src.server.sessionhandler.SESSIONS的用法示例。


在下文中一共展示了SESSIONS.sessions_from_player方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: func

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import sessions_from_player [as 别名]
    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)
开发者ID:Aumnren,项目名称:evennia,代码行数:57,代码来源:admin.py

示例2: at_repeat

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import sessions_from_player [as 别名]
 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)
开发者ID:AHecky3,项目名称:evennia,代码行数:15,代码来源:bots.py

示例3: merge_players

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import sessions_from_player [as 别名]
    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))
开发者ID:dbenoy,项目名称:latitude,代码行数:46,代码来源:sys_merge.py

示例4: get_all_sessions

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import sessions_from_player [as 别名]
 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)
开发者ID:Aumnren,项目名称:evennia,代码行数:8,代码来源:models.py

示例5: sessions_get

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import sessions_from_player [as 别名]
 def sessions_get(self):
     "Getter. Retrieve sessions related to this player/user"
     return SESSIONS.sessions_from_player(self)
开发者ID:abbacode,项目名称:avaloria,代码行数:5,代码来源:models.py

示例6: sessions_get

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import sessions_from_player [as 别名]
 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)
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:8,代码来源:models.py

示例7: func

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import sessions_from_player [as 别名]
    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)
开发者ID:OthersGames,项目名称:asylum-jam,代码行数:85,代码来源:admin.py


注:本文中的src.server.sessionhandler.SESSIONS.sessions_from_player方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。