Beispiel #1
0
 async def set_typing(self, conversation_id: str, typing: bool) -> None:
     self.log.debug(f"set_typing({conversation_id}, {typing})")
     await self.client.set_typing(hangouts.SetTypingRequest(
         request_header=self.client.get_request_header(),
         conversation_id=hangouts.ConversationId(id=conversation_id),
         type=hangouts.TYPING_TYPE_STARTED if typing else hangouts.TYPING_TYPE_STOPPED,
     ))
Beispiel #2
0
    def set_typing(self, typing):
        global client
        if typing == "typing":
            t = hangouts_pb2.TYPING_TYPE_STARTED
        elif typing == "paused":
            t = hangouts_pb2.TYPING_TYPE_PAUSED
        else:
            t = hangouts_pb2.TYPING_TYPE_STOPPED

        request = hangouts_pb2.SetTypingRequest(
            request_header=client.get_request_header(),
            conversation_id=hangouts_pb2.ConversationId(id=self.conv.id_),
            type=t,
        )

        asyncio.async(client.set_typing(request))
    def set_typing(self, typing=hangouts_pb2.TYPING_TYPE_STARTED):
        """Set typing status.

        TODO: Add rate-limiting to avoid unnecessary requests.

        Raises hangups.NetworkError if typing status cannot be set.
        """
        try:
            yield from self._client.set_typing(
                hangouts_pb2.SetTypingRequest(
                    request_header=self._client.get_request_header(),
                    conversation_id=hangouts_pb2.ConversationId(id=self.id_),
                    type=typing,
                ))
        except exceptions.NetworkError as e:
            logger.warning('Failed to set typing status: {}'.format(e))
            raise
Beispiel #4
0
    def settyping(self, conversation_id,
                  typing=hangouts_pb2.TYPING_TYPE_STARTED):
        """Send typing notification.

        conversation_id must be a valid conversation ID.
        typing must be a hangups.TypingType Enum.

        Raises hangups.NetworkError if the request fails.
        """
        request = hangouts_pb2.SetTypingRequest(
            request_header=self._get_request_header_pb(),
            conversation_id=hangouts_pb2.ConversationId(id=conversation_id),
            type=typing,
        )
        response = hangouts_pb2.SetTypingResponse()
        yield from self._pb_request('conversations/settyping', request,
                                    response)
        return response
Beispiel #5
0
    def set_typing(self, typing=hangouts_pb2.TYPING_TYPE_STARTED):
        """Set your typing status in this conversation.

        Args:
            typing: (optional) ``TYPING_TYPE_STARTED``, ``TYPING_TYPE_PAUSED``,
                or ``TYPING_TYPE_STOPPED`` to start, pause, or stop typing,
                respectively. Defaults to ``TYPING_TYPE_STARTED``.

        Raises:
            .NetworkError: If typing status cannot be set.
        """
        # TODO: Add rate-limiting to avoid unnecessary requests.
        try:
            yield from self._client.set_typing(
                hangouts_pb2.SetTypingRequest(
                    request_header=self._client.get_request_header(),
                    conversation_id=hangouts_pb2.ConversationId(id=self.id_),
                    type=typing,
                ))
        except exceptions.NetworkError as e:
            logger.warning('Failed to set typing status: {}'.format(e))
            raise