routing.go 543 B

123456789101112131415161718192021222324
  1. package telegram
  2. import (
  3. "fmt"
  4. "strings"
  5. tgApi "github.com/go-telegram-bot-api/telegram-bot-api"
  6. "github.com/nchursin/formtgbot/telegram/routes"
  7. )
  8. func Routes(update *tgApi.Update) {
  9. if nil != update.CallbackQuery {
  10. callbackQueryRouting(update.CallbackQuery)
  11. }
  12. }
  13. func callbackQueryRouting(query *tgApi.CallbackQuery) {
  14. if strings.HasPrefix(query.Data, "confirm:") {
  15. vacancy := routes.Confirm(query.Data)
  16. GetBot().SendTextMessage(fmt.Sprintf("publishing: %s", string(vacancy.ToJson())))
  17. GetBot().PostToChannel(vacancy)
  18. }
  19. }