How to use the hangups.hangouts_pb2.EventRequestHeader 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 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 / 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 hangoutsbot / hangoutsbot / hangupsbot / plugins / convtools.py View on Github external
not_there.append(chat_id)
        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
github tdryer / hangups / examples / enable_group_link_sharing.py View on Github external
async def enable_group_link_sharing(client, args):
    request = hangups.hangouts_pb2.SetGroupLinkSharingEnabledRequest(
        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(),
        ),
        group_link_sharing_status=(
            hangups.hangouts_pb2.GROUP_LINK_SHARING_STATUS_ON
        ),
    )
    await client.set_group_link_sharing_enabled(request)
    print('enabled group link sharing for conversation {}'.format(
        args.conversation_id
    ))

    request = hangups.hangouts_pb2.GetGroupConversationUrlRequest(
        request_header=client.get_request_header(),
github tdryer / hangups / examples / send_map_location.py View on Github external
async def send_map_location(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(),
        ),
        location=hangups.hangouts_pb2.Location(
            place=hangups.hangouts_pb2.Place(
                name=args.name,
                address=hangups.hangouts_pb2.EmbedItem(
                    postal_address=hangups.hangouts_pb2.EmbedItem.PostalAddress(
                        street_address=args.address
                    ),
                ),
                geo=hangups.hangouts_pb2.EmbedItem(
                    geo_coordinates=hangups.hangouts_pb2.EmbedItem.GeoCoordinates(
                        latitude=float(args.latitude),
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(),
        )