messenger

package
v0.0.0-...-d68ec4c Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BotAPITokenEnvName = "TELEGRAM_BOT_API_TOKEN"
	UpdatesTimeout     = 60
)
View Source
const (
	DeviceStorePath        = "db/whatsapp.db"
	DeviceNotLinkedMessage = "Device is not linked yet. Please go to WhatsApp -> Settings -> Linked Devices and scan the QR code"
)

Variables

View Source
var (
	ErrNoTokenSpecified = errors.New("no bot API token available (please set the TELEGRAM_BOT_API_TOKEN environment variable)")
)

Functions

This section is empty.

Types

type Messenger

type Messenger interface {
	OnMessage(func(sender string, recipient string, isGroup bool, message string))
	SendMessage(recipient string, message string) error
	Disconnect()
}

func CreateMessenger

func CreateMessenger(clientType MessengerClientType) (Messenger, error)

type MessengerClientType

type MessengerClientType int64
const (
	WhatsApp MessengerClientType = iota
	Telegram
)

type TelegramMessenger

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

TelegramMessenger uses the Telegram Bot API to send and receive Telegram messages. To obtain a bot token follow the instructions at https://core.telegram.org/bots/tutorial#obtain-your-bot-token.

By default your bot can be added to any group. If you want to disable this use /setjoingroups Also by default, in group chats, your bot will only receive messages that either start with a / (bot command) or mention your bot's username. This can be disabled (making it receive all messages) by using /setprivacy.

func NewTelegramMessenger

func NewTelegramMessenger() (*TelegramMessenger, error)

func (*TelegramMessenger) Disconnect

func (messenger *TelegramMessenger) Disconnect()

func (*TelegramMessenger) OnMessage

func (messenger *TelegramMessenger) OnMessage(handler func(sender string, recipient string, isGroup bool, message string))

func (*TelegramMessenger) SendMessage

func (messenger *TelegramMessenger) SendMessage(recipient string, message string) error

type WhatsAppMessenger

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

WhatsAppMessenger uses the whatsmeow package to create a client that allows sending and receiving of messages through WhatsApp. The multi-device functionality of WhatsApp is used to talk to the API.

func NewWhatsAppMessenger

func NewWhatsAppMessenger() (*WhatsAppMessenger, error)

func (*WhatsAppMessenger) Disconnect

func (messenger *WhatsAppMessenger) Disconnect()

func (*WhatsAppMessenger) OnMessage

func (messenger *WhatsAppMessenger) OnMessage(handler func(sender string, recipient string, isGroup bool, message string))

func (*WhatsAppMessenger) SendMessage

func (messenger *WhatsAppMessenger) SendMessage(recipient string, message string) error

Jump to

Keyboard shortcuts

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