def find(self, token, **kwargs):
     """
     Process find request
     :param token: search token (username prefix)
     :param kwargs: args
     :return: None
     """
     error = self.__checkCooldown(CLIENT_ACTION_ID.FIND_USERS_BY_PREFIX)
     if error:
         self._onSearchFailed(error.getMessage())
         return
     token = token.strip()
     isCorrect, reason = checkAccountName(token)
     if not isCorrect:
         self._onSearchFailed(reason)
         return
     client = self.proto.client
     if client.isConnected():
         query = NicknamePrefixSearchQuery(
             token, limit=self.getSearchResultLimit())
         self._lastRequestID = client.sendIQ(query)
         self.__cooldown.process(CLIENT_ACTION_ID.FIND_USERS_BY_PREFIX)
     else:
         error = ClientActionError(CLIENT_ACTION_ID.FIND_USERS_BY_PREFIX,
                                   CLIENT_ERROR_ID.NOT_CONNECTED)
         self._onSearchFailed(error.getMessage())
Exemple #2
0
 def find(self, token, onlineMode=None):
     token = token.strip()
     isCorrect, reason = checkAccountName(token)
     if not isCorrect:
         self._onSearchFailed(reason)
         return False
     success, reqID = self.proto.users.findUsers(token, onlineMode)
     self._lastRequestID = reqID
     return success
 def find(self, token, onlineMode = None):
     token = token.strip()
     isCorrect, reason = checkAccountName(token)
     if not isCorrect:
         self._onSearchFailed(reason)
         return False
     success, reqID = self.proto.users.findUsers(token, onlineMode)
     self._lastRequestID = reqID
     return success
 def find(self, token, onlineMode = None):
     (result, reason,) = self.isInCooldown()
     if result:
         self._onSearchFailed(reason)
         return False
     (isCorrect, reason,) = checkAccountName(token)
     if not isCorrect:
         self._onSearchFailed(reason)
         return False
     self._lastRequestID = self._makeRequestID()
     self.proto.users.findUsers(token, onlineMode=onlineMode, requestID=self._lastRequestID)
     return True