Documentation ¶
Overview ¶
Package messenger allows you to interact with Facebook chat/Messenger using an unofficial API ported from https://github.com/Schmavery/facebook-chat-api.
Index ¶
- Variables
- type Attachment
- type ListenError
- type Message
- type ParseError
- type Session
- func (s *Session) AllUserProfileInfo() (map[string]UserProfile, error)
- func (s *Session) Close() error
- func (s *Session) ConnectToChat() error
- func (s *Session) DumpSession() ([]byte, error)
- func (s *Session) Listen()
- func (s *Session) Login(email, password string) error
- func (s *Session) MarkAsRead(thread Thread) error
- func (s *Session) NewMessageWithThread(thread Thread) *Message
- func (s *Session) OnError(handler func(err error))
- func (s *Session) OnMessage(handler func(msg *Message))
- func (s *Session) OnRead(handler func(thread Thread, userID string))
- func (s *Session) OnTyping(handler func(thread Thread, userID string, typing bool))
- func (s *Session) RestoreSession(data []byte) error
- func (s *Session) SendMessage(msg *Message) (string, error)
- func (s *Session) SetTypingIndicator(thread Thread, typing bool) error
- func (s *Session) UserProfileInfo(userID string) (UserProfile, error)
- type Thread
- type UserProfile
Constants ¶
This section is empty.
Variables ¶
var ( ErrLoggedOut = errors.New("messenger: (probably) logged out") ErrUnknown = errors.New("messenger: unknown error from server") )
A subset of possible errors returned by OnError
var ( ErrLoginError = errors.New("messenger: incorrect login credentials") ErrLoginCheckpoint = errors.New("messenger: login checkpoint") )
Errors that are returned by Login.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
Attachment represents an attachment
type ListenError ¶
ListenError is the type of error that will always be passed to OnError. It contains information about the operation that caused the error, and the actual underlying error.
func (ListenError) Error ¶
func (l ListenError) Error() string
type Message ¶
type Message struct { FromUserID string Thread Thread Body string Attachments []Attachment MessageID string // contains filtered or unexported fields }
Message represents a message object.
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError is returned if an error due to parsing occurs.
func (ParseError) Error ¶
func (p ParseError) Error() string
Error returns the detailed parse error message.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a Facebook session.
func (*Session) AllUserProfileInfo ¶
func (s *Session) AllUserProfileInfo() (map[string]UserProfile, error)
AllUserProfileInfo returns all the users' profiles in the session's friend list as a map indexed by the user's ID.
func (*Session) ConnectToChat ¶
ConnectToChat connects the session to chat after you've successfully logged in.
func (*Session) DumpSession ¶
DumpSession dumps the session (i.e. cookies) and returns it as a []byte. Note that if you restore the session, you may not need to login, but you must reconnect to chat.
func (*Session) Listen ¶
func (s *Session) Listen()
Listen starts listening for events and messages from Facebook's chat servers and blocks.
func (*Session) MarkAsRead ¶
MarkAsRead marks the specified thread as read.
func (*Session) NewMessageWithThread ¶
NewMessageWithThread creates a new message for the given thread.
func (*Session) OnMessage ¶
OnMessage sets the handler for when a message is received.
Receiving attachments isn't supported yet.
func (*Session) RestoreSession ¶
RestoreSession restores the session (i.e. cookies) stored as a []byte back into the session. Note that you may not need to login again, but you must reconnect to chat.
func (*Session) SendMessage ¶
SendMessage sends the message to the session. Only the Thread, Body and Attachments fields are used for sending. The message ID and error is returned.
TODO: Sending does not support attachments yet.
func (*Session) SetTypingIndicator ¶
SetTypingIndicator sets the typing indicator seen by members of the thread.
func (*Session) UserProfileInfo ¶
func (s *Session) UserProfileInfo(userID string) (UserProfile, error)
UserProfileInfo returns the user's profile given their ID.