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


Python SESSIONS.sessions_from_account方法代码示例

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


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

示例1: func

# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import sessions_from_account [as 别名]
    def func(self):
        """Implementing the function"""
        caller = self.caller
        args = self.args

        if not args:
            caller.msg("Usage: @boot[/switches] <account> [: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 account object
            pobj = search.account_search(args)
            if not pobj:
                caller.msg("Account %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_account(pobj)
            for match in matches:
                boot_list.append(match)

        if not boot_list:
            caller.msg("No matching sessions found. The Account 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.account.disconnect_session_from_account(session)
开发者ID:RyanStein,项目名称:evennia,代码行数:57,代码来源:admin.py

示例2: at_repeat

# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import sessions_from_account [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 evennia.server.sessionhandler import SESSIONS as _SESSIONS
        for session in _SESSIONS.sessions_from_account(self.account):
            session.update_session_counters(idle=True)
开发者ID:BlauFeuer,项目名称:evennia,代码行数:16,代码来源:bots.py

示例3: get

# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import sessions_from_account [as 别名]
    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_account(self.account, sessid))
        else:
            return _SESSIONS.sessions_from_account(self.account)
开发者ID:SJonesy,项目名称:evennia,代码行数:22,代码来源:accounts.py


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