How to use the hangups.hangouts_pb2.ConversationId function in hangups

To help you get started, we’ve selected a few hangups examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hangoutsbot / hangoutsbot / hangupsbot / plugins / linksharing.py View on Github external
def _set_linksharing(bot, convid, status):
    """shared function, sets the link to `status`, or throws an error"""
    if status:
        _status = hangups.hangouts_pb2.GROUP_LINK_SHARING_STATUS_ON
    else:
        _status = hangups.hangouts_pb2.GROUP_LINK_SHARING_STATUS_OFF

    request = hangups.hangouts_pb2.SetGroupLinkSharingEnabledRequest(
        request_header = bot._client.get_request_header(),
        event_request_header = hangups.hangouts_pb2.EventRequestHeader(
            conversation_id = hangups.hangouts_pb2.ConversationId(
                id = convid
            ),
            client_generated_id = bot._client.get_client_generated_id(),
        ),
        group_link_sharing_status=(
            _status
        ),
    )
    yield from bot._client.set_group_link_sharing_enabled(request)
github tdryer / hangups / hangups / conversation.py View on Github external
def _get_event_request_header(self):
        """Return EventRequestHeader for conversation."""
        otr_status = (hangouts_pb2.OFF_THE_RECORD_STATUS_OFF_THE_RECORD
                      if self.is_off_the_record else
                      hangouts_pb2.OFF_THE_RECORD_STATUS_ON_THE_RECORD)
        return hangouts_pb2.EventRequestHeader(
            conversation_id=hangouts_pb2.ConversationId(id=self.id_),
            client_generated_id=self._client.get_client_generated_id(),
            expected_otr=otr_status,
            delivery_medium=self._get_default_delivery_medium(),
        )
github tdryer / hangups / examples / send_message.py View on Github external
async def send_message(client, args):
    request = hangups.hangouts_pb2.SendChatMessageRequest(
        request_header=client.get_request_header(),
        event_request_header=hangups.hangouts_pb2.EventRequestHeader(
            conversation_id=hangups.hangouts_pb2.ConversationId(
                id=args.conversation_id
            ),
            client_generated_id=client.get_client_generated_id(),
        ),
        message_content=hangups.hangouts_pb2.MessageContent(
            segment=[
                hangups.ChatMessageSegment(args.message_text).serialize()
            ],
        ),
    )
    await client.send_chat_message(request)
github ZeWaren / jabber-hangouts-transport / lib / hangups / hangups / conversation.py View on Github external
def _get_event_request_header(self):
        """Return EventRequestHeader for conversation."""
        otr_status = (hangouts_pb2.OFF_THE_RECORD_STATUS_OFF_THE_RECORD
                      if self.is_off_the_record else
                      hangouts_pb2.OFF_THE_RECORD_STATUS_ON_THE_RECORD)
        return hangouts_pb2.EventRequestHeader(
            conversation_id=hangouts_pb2.ConversationId(id=self.id_),
            client_generated_id=self._client.get_client_generated_id(),
            expected_otr=otr_status,
            delivery_medium=self._get_default_delivery_medium(),
        )
github tdryer / hangups / examples / get_conversation.py View on Github external
async def get_conversation(client, args):
    request = hangups.hangouts_pb2.GetConversationRequest(
        request_header=client.get_request_header(),
        conversation_spec=hangups.hangouts_pb2.ConversationSpec(
            conversation_id=hangups.hangouts_pb2.ConversationId(
                id=args.conversation_id
            ),
        ),
        include_event=True,
        max_events_per_conversation=10,
    )
    res = await client.get_conversation(request)
    print(res)
github ZeWaren / jabber-hangouts-transport / lib / hangups / hangups / conversation.py View on Github external
read_timestamp = self.events[-1].timestamp
        if read_timestamp > self.latest_read_timestamp:
            logger.info(
                'Setting {} latest_read_timestamp from {} to {}'
                .format(self.id_, self.latest_read_timestamp, read_timestamp)
            )
            # Prevent duplicate requests by updating the conversation now.
            state = self._conversation.self_conversation_state
            state.self_read_state.latest_read_timestamp = (
                parsers.to_timestamp(read_timestamp)
            )
            try:
                yield from self._client.update_watermark(
                    hangouts_pb2.UpdateWatermarkRequest(
                        request_header=self._client.get_request_header(),
                        conversation_id=hangouts_pb2.ConversationId(
                            id=self.id_
                        ),
                        last_read_timestamp=parsers.to_timestamp(
                            read_timestamp
                        ),
                    )
                )
            except exceptions.NetworkError as e:
                logger.warning('Failed to update read timestamp: {}'.format(e))
                raise
github hangoutsbot / hangoutsbot / hangupsbot / plugins / linksharing.py View on Github external
def _get_linksharing(bot, convid):
    """shared function, returns the url of the group link, or throws an error"""
    request = hangups.hangouts_pb2.GetGroupConversationUrlRequest(
        request_header = bot._client.get_request_header(),
        conversation_id = hangups.hangouts_pb2.ConversationId(
            id = convid,
        )
    )
    response = yield from bot._client.get_group_conversation_url(request)
    url = response.group_conversation_url
    logger.info("linksharing: convid {} url: {}".format(convid, url))

    return url
github hangoutsbot / hangoutsbot / hangupsbot / plugins / convtools.py View on Github external
else:
            logger.debug("addusers: user {} already in {}".format(chat_id, target_conv))
    chat_ids = not_there

    users_added = 0
    chunks = [chat_ids[i:i+batch_max] for i in range(0, len(chat_ids), batch_max)]
    for number, partial_list in enumerate(chunks):
        logger.info("batch add users: {}/{} {} user(s) into {}".format(number+1, len(chunks), len(partial_list), target_conv))

        yield from bot._client.add_user(
            hangups.hangouts_pb2.AddUserRequest(
                request_header = bot._client.get_request_header(),
                invitee_id = [ hangups.hangouts_pb2.InviteeID(gaia_id = chat_id)
                               for chat_id in partial_list ],
                event_request_header = hangups.hangouts_pb2.EventRequestHeader(
                    conversation_id = hangups.hangouts_pb2.ConversationId(id = target_conv),
                    client_generated_id = bot._client.get_client_generated_id() )))

        users_added = users_added + len(partial_list)
        yield from asyncio.sleep(0.5)

    return users_added