Ejemplo n.º 1
0
    def doConnect(self, session, input=None, args=None):
        errmsg = "Unknown player name or password."
        username, password = args

        matches = match_objlist(username,
                                self.game.db.descendants(BasePlayer),
                                exact=True)

        if len(matches) > 1:
            # This hopefully won't happen...
            session.send_output(errmsg)
            return
        elif len(matches) == 0:
            session.send_output(errmsg)
            return

        #: @type: BasePlayer
        player = matches[0]
        try:
            auth = player.authenticate(password, session)
        except TypeError:
            auth = False
            logging.exception("Auth failed.")
        except Exception:
            logging.exception("Login failed")
            session.send_output("Error logging in!")
            return
        if auth:
            session.attach_to_player(player)
        else:
            session.send_output(errmsg)
Ejemplo n.º 2
0
 def match_role(self, search):
     """
     Find a role.
     @param search: The role name to search for.
     @rtype: mudsling.perms.Role
     """
     matches = match_objlist(search, self.roles, varname="name")
     if len(matches) == 1:
         return matches[0]
     elif len(matches) > 1:
         raise errors.AmbiguousMatch(query=search, matches=matches)
     else:
         raise errors.FailedMatch(query=search)
Ejemplo n.º 3
0
 def match_children(self, search, cls, varname="names", exactOnly=False):
     """
     Convenience method for matching the children of a given class.
     """
     objlist = self.children(cls)
     return match_objlist(search, objlist, varname, exactOnly)
Ejemplo n.º 4
0
 def match_descendants(self, search, cls, varname="names", exactOnly=False):
     """
     Convenience method for matching the descendants of a given class.
     """
     objlist = self.descendants(cls)
     return match_objlist(search, objlist, varname, exactOnly)
Ejemplo n.º 5
0
 def match_rank(self, search, exact=False, err=False):
     return match.match_objlist(search, self.ranks.values(), exact=exact,
                                err=err)
Ejemplo n.º 6
0
 def match_rank(self, search, exact=False, err=False):
     return match.match_objlist(search,
                                self.ranks.values(),
                                exact=exact,
                                err=err)