Documentation ¶
Index ¶
- Constants
- func ExtractMsgJid(message string) string
- type DisconnectEvent
- type Event
- type EventType
- type EventsHandler
- type HelpEvent
- type LoginEvent
- type LogoutEvent
- type ReplyEvent
- type StartEvent
- type TextMessageEvent
- type WhatsappClient
- type WhatsappContact
- type WhatsappMessage
- type WhatsappMessageType
- type WhatsappTextMessage
Constants ¶
const TextMessageFmt = "From: %s [jid: %s] \n= = = = = = = = = = = =\nMessage: %s"
TextMessageFmt represents a message format that will be sent to a user in case incoming text messages from whatsapp.
const WhatsappTextMessageType = "text_message"
Variables ¶
This section is empty.
Functions ¶
func ExtractMsgJid ¶
ExtractMsgJid returns remote jid from the message if it has one, otherwise - empty string.
Types ¶
type DisconnectEvent ¶ added in v0.2.0
type DisconnectEvent struct { // ChatID is telegram bot chat identifier. ChatID int64 }
DisconnectEvent represents a disconnect event.
func (*DisconnectEvent) Type ¶ added in v0.2.0
func (de *DisconnectEvent) Type() EventType
type EventType ¶
type EventType string
EventType represents an event type.
const ( StartEventType EventType = "start" LoginEventType EventType = "login" LogoutEventType EventType = "logout" HelpEventType EventType = "help" TextMessageEventType EventType = "text_message" // whatsapp only ReplyEventType EventType = "reply" // telegram only DisconnectEventType EventType = "disconnect_event" )
type EventsHandler ¶
type EventsHandler interface { HandleStartEvent(*StartEvent) error HandleLoginEvent(*LoginEvent) error HandleLogoutEvent(*LogoutEvent) error HandleHelpEvent(*HelpEvent) error HandleRepeatedLoginEvent(*LoginEvent) error HandleTextMessageEvent(*TextMessageEvent) error HandleReplyEvent(*ReplyEvent) error HandleDisconnectEvent(*DisconnectEvent) error IsLoggedIn() bool }
EventsHandler describes events handler API.
type HelpEvent ¶ added in v0.2.0
type HelpEvent struct { // ChatID is telegram bot chat identifier. ChatID int64 // FromUser is a telegram username of the client that interacts with the bot. FromUser string }
HelpEvent represents a help event.
type LoginEvent ¶
type LoginEvent struct { // ChatID is telegram bot chat identifier. ChatID int64 // FromUser is a telegram username of the client that interacts with the bot. FromUser string }
LoginEvent represents a login event.
func (*LoginEvent) Type ¶
func (le *LoginEvent) Type() EventType
type LogoutEvent ¶ added in v0.2.0
type LogoutEvent struct { // ChatID is telegram bot chat identifier. ChatID int64 // FromUser is a telegram username of the client that interacts with the bot. FromUser string }
LogoutEvent represents a logout event.
func (*LogoutEvent) Type ¶ added in v0.2.0
func (lo *LogoutEvent) Type() EventType
type ReplyEvent ¶
type ReplyEvent struct { // ChatID is telegram bot chat identifier. ChatID int64 // FromUser is a telegram username of the client that interacts with the bot. FromUser string // Reply is a reply text message body. Reply string // RemoteJid is a whatsapp user identifier. RemoteJid string }
ReplyEvent represents a message reply event.
func (*ReplyEvent) Type ¶
func (re *ReplyEvent) Type() EventType
type StartEvent ¶
type StartEvent struct { // ChatID is telegram bot chat identifier. ChatID int64 // FromUser is a telegram username of the client that interacts with the bot. FromUser string }
StartEvent represents an initial event.
func (*StartEvent) Type ¶
func (se *StartEvent) Type() EventType
type TextMessageEvent ¶
type TextMessageEvent struct { // ChatID is telegram bot chat identifier. ChatID int64 // WhatsappRemoteJid is a whatsapp client identifier that sent the message. WhatsappRemoteJid string // WhatsappSenderName is a whatsapp client's name that sent the message. WhatsappSenderName string // Text is a text message body. Text string }
TextMessageEvent represents an incoming text message event.
func (*TextMessageEvent) Type ¶
func (te *TextMessageEvent) Type() EventType
type WhatsappClient ¶
type WhatsappClient interface { Restore() error GetContacts() map[string]WhatsappContact Send(msg WhatsappMessage) error Logout() error }
WhatsappClient represents a common interface that describes whatsapp client behaviour.
type WhatsappContact ¶
type WhatsappContact struct { // Jid is a contact's identifier. Jid string // Name is a name of the contact. Name string }
WhatsappContact represents whatsapp contact.
type WhatsappMessage ¶
type WhatsappMessage interface {
Type() WhatsappMessageType
}
WhatsappMessage is an interface that represents whatsapp messages in general.
type WhatsappMessageType ¶
type WhatsappMessageType string
WhatsappMessageType represents whatsapp message type.
type WhatsappTextMessage ¶
type WhatsappTextMessage struct { // RemoteJid is an identifier of a user the message is sent to. RemoteJid string // Text is a text of the message. Text string }
WhatsappTextMessage represents a whatsapp text message.
func (*WhatsappTextMessage) Type ¶
func (msg *WhatsappTextMessage) Type() WhatsappMessageType
Type method returns type of the message.