package main import ( "html/template" "log" "sync" ) type Sender interface { Send(msg GenericMessage, tpl *template.Template) error } type Sleeper interface { Sleep(ch chan<- interface{}) } type ChatId interface { GetTgIds() *[]int64 } type TgChatId struct { tgChatId int64 } func (self TgChatId) GetTgIds() *[]int64 { return &[]int64{self.tgChatId} } func Consume(events <-chan GenericMessage) { go func() { for range events { } }() } func SendToTg(events <-chan GenericMessage, s Sender, wg *sync.WaitGroup, logger *log.Logger, tpl *template.Template) <-chan GenericMessage { returnEvents := make(chan GenericMessage) go func() { wg.Add(1) defer wg.Done() for e := range events { returnEvents <- e err := s.Send(e, tpl) if err != nil { // TODO: handle it better panic(err) } } close(returnEvents) }() return returnEvents }