messenger

package
v0.0.0-...-102e137 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Sources       []string
	EmailFrom     string
	EmailHost     string
	EmailPort     int
	EmailLogin    string
	EmailPassword string
	TelegramToken string
	VkToken       string
}

Config is the configuration object.

func NewConfig

func NewConfig() *Config

NewConfig returns the configuration object.

type ContactsConverter

type ContactsConverter interface {
	Convert(contact ContactsGetter) map[string]string
}

ContactsConverter is the interface for converting contacts to map.

type ContactsGetter

type ContactsGetter interface {
	GetEmail() string
	GetTelegram() string
	GetVK() string
}

ContactsGetter is the interface for contacts.

type ContactsMapper

type ContactsMapper struct{}

ContactsMapper maps contacts to the sources.

func NewContactsConverter

func NewContactsConverter() *ContactsMapper

NewContactsConverter creates a new contacts mapper.

func (*ContactsMapper) Convert

func (c *ContactsMapper) Convert(contact ContactsGetter) map[string]string

Convert converts contacts to map.

type EmailDialer

type EmailDialer interface {
	DialAndSend(m ...*gomail.Message) error
}

Dialer is the interface for dialing.

type EmailSender

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

EmailSender is a email sender.

func NewEmailSender

func NewEmailSender(config *Config) *EmailSender

NewEmailSender creates a new email sender.

func (*EmailSender) Send

func (s *EmailSender) Send(id string, message MessageGetter, ch chan error)

Send sends a message.

type Logger

type Logger interface {
	Error(args ...interface{})
	Infof(format string, args ...interface{})
}

Logger logs errors.

type MessageGetter

type MessageGetter interface {
	GetText() string
	GetHTML() string
	GetSubject() string
}

MessageGetter is the interface for messages.

type Messenger

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

Messenger is the struct to send messages via different sources to contact.

func NewMessenger

func NewMessenger(logger Logger) *Messenger

NewMessenger creates a new messenger.

func (*Messenger) Send

func (s *Messenger) Send(
	contact ContactsGetter, message MessageGetter, sources ...string,
)

Send the message to the contact.

type Sender

type Sender interface {
	Send(id string, message MessageGetter, ch chan error)
}

Sender is the interface for sending messages.

type SenderFactory

type SenderFactory struct{}

SenderFactory is a factory to create senders.

func NewSenderFactory

func NewSenderFactory() *SenderFactory

NewSenderFactory creates a new sender factory.

func (*SenderFactory) New

func (s *SenderFactory) New(id string, config *Config) Sender

type TelegramBotSender

type TelegramBotSender interface {
	Send(c tgbotapi.Chattable) (tgbotapi.Message, error)
}

TelegramBotSender is the interface for sending telegram messages.

type TelegramSender

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

TelegramSender is a telegram sender.

func NewTelegramSender

func NewTelegramSender(config *Config) *TelegramSender

NewTelegramSender creates a new telegram sender.

func (*TelegramSender) Send

func (s *TelegramSender) Send(id string, message MessageGetter, ch chan error)

Send sends a message to the channel.

type VkAPISender

type VkAPISender interface {
	MessagesSend(b api.Params) (response int, err error)
}

type VkSender

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

VkSender is a vk sender.

func NewVkSender

func NewVkSender(config *Config) *VkSender

NewVkSender creates a new vk sender.

func (*VkSender) Send

func (s *VkSender) Send(id string, message MessageGetter, ch chan error)

Send sends message to the user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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