-func recv_task(bot *tgbotapi.BotAPI, sendChannel chan tgbotapi.Chattable, ctx context.Context) {
- u := tgbotapi.NewUpdate(0)
- u.Timeout = 60
-
- updates, _ := bot.GetUpdatesChan(u)
-
- for {
- select {
- case update := <-updates:
- log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
-
- msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
- msg.ReplyToMessageID = update.Message.MessageID
- sendChannel <- msg
- case <-ctx.Done():
- return
- }
- }
-}
-
-func send_task(bot *tgbotapi.BotAPI, sendChannel chan tgbotapi.Chattable, ctx context.Context) {
- for {
- select {
- case msg := <-sendChannel:
- bot.Send(msg)
- case <-ctx.Done():
- return
- }
- }
-}
-