Homework final 2 - #13
Conversation
dimonl
left a comment
There was a problem hiding this comment.
I didn't see any tests in app, Whole app is written in non testable style.
I didn't see any containerisation and automatisation of deploying
By the way - It seems . At least this app will work, but it needs some improvements
| var conn net.Conn | ||
|
|
||
| /// connect with telegram bot | ||
| token, err := ReadToken("./telegram_token.json") |
There was a problem hiding this comment.
hardcoded parameters is bad practice
| ErrFunc(err) | ||
|
|
||
| updateConfig := tgbotapi.NewUpdate(0) | ||
| updateConfig.Timeout = 60 |
There was a problem hiding this comment.
the same thing - hardcoded parameters is evil.
|
|
||
| for update := range updates { | ||
| if update.Message != nil { | ||
| conn, _ = net.Dial("tcp", "127.0.0.1:8080") |
|
|
||
| id := update.Message.Chat.ID | ||
|
|
||
| if len(update.Message.Text) > 100 { |
There was a problem hiding this comment.
Why are you limiting message here?
| default: | ||
| message = "incorrect request" | ||
| } | ||
| conn.Write([]byte(message + "\v")) |
|
|
||
|
|
||
| func MakeUrl(city string)(string, error){ | ||
| KeyWeather, err := ReadToken("./weather_token.json") |
| return "", err | ||
| } | ||
|
|
||
| URL := "https://api.openweathermap.org/data/2.5/weather?q=" + |
| } | ||
|
|
||
| cityStr := strings.Replace(request, "/city ", "", 1) | ||
| url, _ := MakeUrl(cityStr) |
There was a problem hiding this comment.
if you declare func as (result, error) - why you don't handle error?
| } | ||
|
|
||
| InitDB() | ||
| err = AddDBRequest(cityStr, message) |
There was a problem hiding this comment.
you don't extract different layers in application. All in one file - handle requests, app logic, work with db.
No description provided.