Documentation ¶
Index ¶
- func NotifyDevChatOnFinish(chatID int64) func(*SenderWithBots)
- func NotifyDevChatOnFinishEach(chatID int64) func(*Mailing)
- func NotifyDevChatOnStart(chatID int64) func(*SenderWithBots)
- type AdProvider
- type BotsProvider
- type ChatsProvider
- type DataFetcher
- type Mailing
- type SenderWithBots
- func (s *SenderWithBots) Run() error
- func (s *SenderWithBots) SetAfterFinishEachHook(f func(*Mailing)) *SenderWithBots
- func (s *SenderWithBots) SetAfterFinishHook(f func(*SenderWithBots)) *SenderWithBots
- func (s *SenderWithBots) SetAfterStartEachHook(f func(*Mailing)) *SenderWithBots
- func (s *SenderWithBots) SetAfterStartHook(f func(*SenderWithBots)) *SenderWithBots
- func (s *SenderWithBots) SetServiceChat(chatID int64) *SenderWithBots
- func (s *SenderWithBots) Statistics() dto.MultipleBotsStatistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NotifyDevChatOnFinish ¶
func NotifyDevChatOnFinish(chatID int64) func(*SenderWithBots)
DefaultAfterFinishEachHook notifies about mailing finish to dev chat for each bot
func NotifyDevChatOnFinishEach ¶
NotifyDevChatOnFinishEach notifies about mailing finish to dev chat for each bot
func NotifyDevChatOnStart ¶
func NotifyDevChatOnStart(chatID int64) func(*SenderWithBots)
NotifyDevChatOnStart notifies about mailing start to dev chat
Types ¶
type AdProvider ¶
type AdProvider interface {
GetScheduledAd(year, month, day int) (dto.ScheduledAd, error)
}
type BotsProvider ¶
BotsProvider is created for fetching bots which will send mailing
type DataFetcher ¶
type DataFetcher interface { ChatsProvider AdProvider }
type Mailing ¶
type Mailing struct { Statistics dto.Statistics `json:"statistics"` ServiceChat dto.Chat // Hooks AfterStart func(*Mailing) `json:"-"` AfterFinish func(*Mailing) `json:"-"` Bot *tb.Bot `json:"-"` // telegram client Chats []dto.Chat `json:"chats"` // list of chats to send post Retries []dto.Chat `json:"retries"` // list of chats which did not recieve the post due to rate limits Post dto.ScheduledAd `json:"post"` // the post to send // contains filtered or unexported fields }
func New ¶
func New(bot dto.Bot, chatsFetcher ChatsProvider, adFetcher AdProvider, svcChat dto.Chat) (*Mailing, error)
New returns new instance of mailing
One instance works for one bot. The function sets up telegram client, fetches the ad post and list of chats, and uploads media to telegram cloud if needed.
func (*Mailing) SetAfterFinishHook ¶
SetAfterFinishHook sets the function which will be executed after mailing finish
func (*Mailing) SetAfterStartHook ¶
SetAfterStartHook sets the function which will be executed after mailing start
type SenderWithBots ¶
type SenderWithBots struct { ID int64 `json:"id"` // Hooks AfterStart func(*SenderWithBots) `json:"-"` AfterFinish func(*SenderWithBots) `json:"-"` AfterStartEach func(*Mailing) `json:"-"` AfterFinishEach func(*Mailing) `json:"-"` Mailings []*Mailing `json:"mailings"` StartTime time.Time `json:"start_time"` BotsProvider BotsProvider `json:"-"` ChatsFetcher ChatsProvider `json:"-"` AdFetcher AdProvider `json:"-"` ServiceChat dto.Chat `json:"service_chat"` }
SenderWithBots sends mailing via multiple bots
func NewSenderWithBots ¶
func NewSenderWithBots(botsProvider BotsProvider, chatsFetcher ChatsProvider, adFetcher AdProvider) *SenderWithBots
NewSenderWithBots returns new instance of mailing sender for multiple bots
func (*SenderWithBots) Run ¶
func (s *SenderWithBots) Run() error
Run starts the mailing. Stops when all bots complete its mailings.
func (*SenderWithBots) SetAfterFinishEachHook ¶
func (s *SenderWithBots) SetAfterFinishEachHook(f func(*Mailing)) *SenderWithBots
SetAfterFinishEachHook sets the function which will be executed after mailing finish for each bot
func (*SenderWithBots) SetAfterFinishHook ¶
func (s *SenderWithBots) SetAfterFinishHook(f func(*SenderWithBots)) *SenderWithBots
SetAfterFinishHook sets the function which will be executed after mailing finish
func (*SenderWithBots) SetAfterStartEachHook ¶
func (s *SenderWithBots) SetAfterStartEachHook(f func(*Mailing)) *SenderWithBots
SetAfterStartEachHook sets the function which will be executed after mailing start for each bot
func (*SenderWithBots) SetAfterStartHook ¶
func (s *SenderWithBots) SetAfterStartHook(f func(*SenderWithBots)) *SenderWithBots
SetAfterStartHook sets the function which will be executed after mailing start
func (*SenderWithBots) SetServiceChat ¶
func (s *SenderWithBots) SetServiceChat(chatID int64) *SenderWithBots
SetServiceChat sets the chat which will be used to upload files
func (*SenderWithBots) Statistics ¶
func (s *SenderWithBots) Statistics() dto.MultipleBotsStatistics
Statistics returns mailing metrics