server.go 734 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. api "github.com/nchursin/formtgbot/api"
  7. "github.com/nchursin/formtgbot/telegram"
  8. )
  9. func main() {
  10. go getBotUpdates()
  11. listenAndServe()
  12. }
  13. func listenAndServe() {
  14. fmt.Printf("Starting server for Bot Careers API...\n")
  15. http.ListenAndServe(":8080", api.Routes())
  16. }
  17. func getBotUpdates() {
  18. bot := telegram.GetBot()
  19. channel := bot.ListenForUpdates()
  20. for update := range channel {
  21. log.Printf("----------------------------------------------------")
  22. log.Printf("[%s] %+v", "update.InlineQuery", update.InlineQuery)
  23. log.Printf("[%s] %+v", "update.CallbackQuery", update.CallbackQuery)
  24. log.Printf("[%s] %+v", "update.Message", update.Message)
  25. telegram.Routes(&update)
  26. }
  27. }