hangups

package module
v0.0.0-...-4e20ca4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 21 Imported by: 0

README

Go-Hangups

An (incomplete) go lang port of hangups. Currently only implements the REST API and not the BrowserChannel interface. Based on Tom Dryer's work on hangups python library. Library is still very new so use it at your own risk! Contributions are welcome!

Projects using go-hangups

Development Notes

Below are useful notes for developing/debugging.

# Compile ProtoBuf
$protoc --go_out=. proto/*.proto

# Debug ProtoBuf
$protoc --decode_raw < proto.bin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthHeaders

func GetAuthHeaders(sapisid string) map[string]string

GetAuthHeaders returns authentication header

Types

type Client

type Client struct {
	Session   *Session
	ClientID  string
	UserAgent string
}

Client is a hangouts client

func (*Client) APIRequest

func (c *Client) APIRequest(endpointURL, responseType string, headers map[string]string, payload []byte) ([]byte, error)

APIRequest performs an API Request

func (*Client) AddUser

func (c *Client) AddUser(inviteesGaiaIds []string, conversationID string) (*hangouts.AddUserResponse, error)

AddUser Invite users to join an existing group conversation.

func (*Client) Create1On1Conversation

func (c *Client) Create1On1Conversation(id string) (*hangouts.Conversation, error)

Create1On1Conversation create an 1 on 1 private conversation

func (*Client) CreateConversation

func (c *Client) CreateConversation(inviteesGaiaIds []string, name string, oneOnOne bool) (*hangouts.CreateConversationResponse, error)

CreateConversation Create a new conversation.

func (*Client) DeleteConversation

func (c *Client) DeleteConversation(conversationID string, deleteUpperBoundTimestamp uint64) (*hangouts.DeleteConversationResponse, error)

DeleteConversation Leave a one-to-one conversation. One-to-one conversations are "sticky"; they can't actually be deleted. This API clears the event history of the specified conversation up to delete_upper_bound_timestamp, hiding it if no events remain.

func (*Client) EasterEgg

func (c *Client) EasterEgg(conversationID string, message string) (*hangouts.EasterEggResponse, error)

EasterEgg send an easter egg event to a conversation.

func (*Client) GetConversation

func (c *Client) GetConversation(conversationID string, includeEvent bool, maxEventsPerConversation uint64) (*hangouts.GetConversationResponse, error)

GetConversation return conversation info and recent events.

func (*Client) GetEntities

func (c *Client) GetEntities(id string) (*hangouts.Entity, error)

GetEntities returns entities of a specific id

func (*Client) GetEntityByID

func (c *Client) GetEntityByID(Ids []string) (*hangouts.GetEntityByIdResponse, error)

GetEntityByID return info about a list of users.

func (*Client) GetGroupConversationURL

func (c *Client) GetGroupConversationURL(conversationID string) (string, error)

GetGroupConversationURL get the group conversation join URL

func (*Client) GetSelfInfo

func (c *Client) GetSelfInfo() (*hangouts.GetSelfInfoResponse, error)

GetSelfInfo return info about the current user.

func (*Client) GetSuggestedEntities

func (c *Client) GetSuggestedEntities(maxCount uint64) (*hangouts.GetSuggestedEntitiesResponse, error)

GetSuggestedEntities return suggested contacts

func (*Client) ModifyOTRStatus

func (c *Client) ModifyOTRStatus(conversationID string, otrStatus hangouts.OffTheRecordStatus) (*hangouts.ModifyOTRStatusResponse, error)

ModifyOTRStatus modify the otrstatus of current conversation

func (*Client) NewEventRequestHeaders

func (c *Client) NewEventRequestHeaders(conversationID string, offTheRecord bool,
	deliveryMedium hangouts.DeliveryMediumType) *hangouts.EventRequestHeader

NewEventRequestHeaders creates basic event request header

func (*Client) NewRequestHeaders

func (c *Client) NewRequestHeaders() *hangouts.RequestHeader

NewRequestHeaders creates basic request header

func (*Client) ProtobufAPIRequest

func (c *Client) ProtobufAPIRequest(apiEndpoint string, requestStruct, responseStruct proto.Message) error

ProtobufAPIRequest do a protobuf API request

func (*Client) QueryPresence

func (c *Client) QueryPresence(gaiaID string) (*hangouts.QueryPresenceResponse, error)

QueryPresence return presence status for a list of users. doesnt support passing an array of gaiaIds. fails with: {"status":4,"error_description":"Duplicate ParticipantIds in request"}

func (*Client) RemoveUser

func (c *Client) RemoveUser(conversationID string) (*hangouts.RemoveUserResponse, error)

RemoveUser leave a group conversation.

func (*Client) RenameConversation

func (c *Client) RenameConversation(conversationID, newName string) (*hangouts.RenameConversationResponse, error)

RenameConversation rename a conversation. Both group and one-to-one conversations may be renamed, but the official Hangouts clients have mixed support for one-to-one conversations with custom names.

func (*Client) SearchEntities

func (c *Client) SearchEntities(query string, maxCount uint64) (*hangouts.SearchEntitiesResponse, error)

SearchEntities return info for users based on a query.

func (*Client) SendChatImage

func (c *Client) SendChatImage(conversationID, imageID string) (*hangouts.SendChatMessageResponse, error)

SendChatImage send a image to a conversation, keep this for backward compatibility Deprecated: SendChatImage is deprecated since it has some hardcoded parameters, use SendMessage instead

func (*Client) SendChatMessage

func (c *Client) SendChatMessage(conversationID, message string) (*hangouts.SendChatMessageResponse, error)

SendChatMessage send a chat message to a conversation, keep this for backward compatibility Deprecated: SendChatMessage is deprecated since it has some hardcoded parameters, use SendMessage instead

func (*Client) SendImage

func (c *Client) SendImage(to, image string) error

SendImage send image to a user or group to can be phoneNumber, email chatID/GaiaID or conversation ID image can be a file path or base64 encoded image

func (*Client) SendMessage

func (c *Client) SendMessage(to, content string) error

SendMessage sends a message to a user/group to can be phoneNumber, email chatID/GaiaID or conversation ID

func (*Client) SendOffNetworkInvitation

func (c *Client) SendOffNetworkInvitation(email string) (*hangouts.SendOffnetworkInvitationResponse, error)

SendOffNetworkInvitation send an invitation to a non-contact.

func (*Client) SendPhotoID

func (c *Client) SendPhotoID(to, photoID string) error

SendPhotoID send image to a user or group to can be phoneNumber, email chatID/GaiaID or conversation ID photoID is a photo id from hangouts message

func (*Client) SetActiveClient

func (c *Client) SetActiveClient(email string, isActive bool, timeoutSecs uint64) (*hangouts.SetActiveClientResponse, error)

SetActiveClient set the active client. timeout is 120 secs in hangups

func (*Client) SetConversationNotificationLevel

func (c *Client) SetConversationNotificationLevel(conversationID string,
	setQuiet bool) (*hangouts.SetConversationNotificationLevelResponse, error)

SetConversationNotificationLevel set the notification level of a conversation.

func (*Client) SetFocus

func (c *Client) SetFocus(conversationID string, unfocus bool, timeoutSecs uint32) (*hangouts.SetFocusResponse, error)

SetFocus set focus to a conversation.

func (*Client) SetGroupLinkSharingEnabled

func (c *Client) SetGroupLinkSharingEnabled(conversationID string,
	status hangouts.GroupLinkSharingStatus) (*hangouts.SetGroupLinkSharingEnabledResponse, error)

SetGroupLinkSharingEnabled enable/disable group link sharing

func (*Client) SetPresence

func (c *Client) SetPresence(presenceState int32, timeoutSecs uint64) (*hangouts.SetPresenceResponse, error)

SetPresence set the presence status. presenceState: 1=NONE 30=IDLE 40=ACTIVE

func (*Client) SetTyping

func (c *Client) SetTyping(conversationID string, typingState int32) (*hangouts.SetTypingResponse, error)

SetTyping set the typing status of a conversation. typingState: 1=Started 2=Paused 3=Stopped

func (*Client) SyncAllNewEvents

func (c *Client) SyncAllNewEvents(lastSyncTimestamp, maxResponseSizeBytes uint64) (*hangouts.SyncAllNewEventsResponse, error)

SyncAllNewEvents list all events occurring at or after a timestamp.

func (*Client) SyncRecentConversations

func (c *Client) SyncRecentConversations(maxConversations, maxEventsPerConversation uint64) (*hangouts.SyncRecentConversationsResponse, error)

SyncRecentConversations return info on recent conversations and their events.

func (*Client) UpdateWatermark

func (c *Client) UpdateWatermark(conversationID string, lastReadTimestamp uint64) (*hangouts.UpdateWatermarkResponse, error)

UpdateWatermark update the watermark (read timestamp) of a conversation.

func (*Client) UploadImage

func (c *Client) UploadImage(image string) (*Photo, error)

UploadImage uploads an image to google and returns the imageID for chat message sending image can be a file path or base64 encoded image

type Photo

type Photo struct {
	ImageID string `json:"photoid"`
	URL     string `json:"url"`
}

Photo contains information of image upload for message sending

type Session

type Session struct {
	RefreshToken string
	Cookies      string
	Sapisid      string
}

Session represent a hangouts session

func (*Session) Init

func (s *Session) Init() error

Init a session

type UploadFile

type UploadFile struct {
	// contains filtered or unexported fields
}

UploadFile contains information of image before and after image Upload

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL