Skip to content

Commit

Permalink
Added request logging
Browse files Browse the repository at this point in the history
  • Loading branch information
FileGo committed Jun 19, 2022
1 parent 9bdb97a commit 347826e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type Env struct {
Airports []Airport
httpClient *http.Client
NOAAinterval int
logRequests bool
}

// FindAirport returns an airport
Expand Down Expand Up @@ -149,6 +150,11 @@ func main() {
log.Fatal("TELEGRAM_TOKEN not set. Unable to start the bot.")
}

// Logging
if os.Getenv("LOG_REQUESTS") != "" {
env.logRequests = true
}

// Set httpClient
env.httpClient = &http.Client{
Timeout: 10 * time.Second,
Expand Down Expand Up @@ -225,6 +231,10 @@ KLAX JFK LHR or KLAX,JFK,LHR`)
// Send "typing..." to client
c.SendChatAction(m.Chat.ID, tbot.ActionTyping)

if env.logRequests {
log.Printf("Received request from %s %s (%s): %s", m.From.FirstName, m.From.LastName, m.Chat.ID, m.Text)
}

var messages []string

// Get airports from received message
Expand Down

0 comments on commit 347826e

Please sign in to comment.