Exemple #1
0
    def whois(self, nickname):
        """
        Return information about user.
        This is an blocking asynchronous method: it has to be called from a coroutine, as follows:

            info = yield self.whois('Nick')
        """
        # Some IRCDs are wonky and send strange responses for spaces in nicknames.
        # We just check if there's a space in the nickname -- if there is,
        # then we immediately set the future's result to None and don't bother checking.
        if protocol.ARGUMENT_SEPARATOR.search(nickname) is not None:
            result = Future()
            result.set_result(None)
            return result

        if nickname not in self._pending['whois']:
            self.rawmsg('WHOIS', nickname)
            self._whois_info[nickname] = {
                'oper': False,
                'idle': 0,
                'away': False,
                'away_message': None
            }

            # Create a future for when the WHOIS requests succeeds.
            self._pending['whois'][nickname] = Future()

        return self._pending['whois'][nickname]
Exemple #2
0
    def whois(self, nickname):
        """
        Return information about user.
        This is an blocking asynchronous method: it has to be called from a coroutine, as follows:

            info = yield self.whois('Nick')
        """
        # Some IRCDs are wonky and send strange responses for spaces in nicknames.
        # We just check if there's a space in the nickname -- if there is,
        # then we immediately set the future's result to None and don't bother checking.
        if protocol.ARGUMENT_SEPARATOR.search(nickname) is not None:
            result = Future()
            result.set_result(None)
            return result

        if nickname not in self._pending['whois']:
            self.rawmsg('WHOIS', nickname)
            self._whois_info[nickname] = {
                'oper': False,
                'idle': 0,
                'away': False,
                'away_message': None
            }

            # Create a future for when the WHOIS requests succeeds.
            self._pending['whois'][nickname] = Future()

        return self._pending['whois'][nickname]
Exemple #3
0
    def whowas(self, nickname):
        """
        Return information about offline user.
        This is an blocking asynchronous method: it has to be called from a coroutine, as follows:

            info = yield self.whowas('Nick')
        """
        # Same treatment as nicknames in whois.
        if protocol.ARGUMENT_SEPARATOR.search(nickname) is not None:
            result = Future()
            result.set_result(None)
            return result

        if nickname not in self._pending['whowas']:
            self.rawmsg('WHOWAS', nickname)
            self._whowas_info[nickname] = {}

            # Create a future for when the WHOWAS requests succeeds.
            self._pending['whowas'][nickname] = Future()

        return self._pending['whowas'][nickname]
Exemple #4
0
    def whowas(self, nickname):
        """
        Return information about offline user.
        This is an blocking asynchronous method: it has to be called from a coroutine, as follows:

            info = yield self.whowas('Nick')
        """
        # Same treatment as nicknames in whois.
        if protocol.ARGUMENT_SEPARATOR.search(nickname) is not None:
            result = Future()
            result.set_result(None)
            return result

        if nickname not in self._pending['whowas']:
            self.rawmsg('WHOWAS', nickname)
            self._whowas_info[nickname] = {}

            # Create a future for when the WHOWAS requests succeeds.
            self._pending['whowas'][nickname] = Future()

        return self._pending['whowas'][nickname]
Exemple #5
0
    def get_metadata(self, target):
        """
        Return user metadata information.
        This is a blocking asynchronous method: it has to be called from a coroutine, as follows:

            metadata = yield self.get_metadata('#foo')
        """
        if target not in self._pending['metadata']:
            self.rawmsg('METADATA', target, 'LIST')

            self._metadata_queue.append(target)
            self._metadata_info[target] = {}
            self._pending['metadata'][target] = Future()
Exemple #6
0
def wait_for_confirmation(storage, account, network, alt_account, alt_network):
    confirmation = Future()
    storage.confirmations[account, network, alt_account,
                          alt_network] = confirmation
    return confirmation