-
Notifications
You must be signed in to change notification settings - Fork 0
Homework final 2 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Homework final 2 #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardcoded parameters is bad practice
ErrFunc(err) | ||
|
||
updateConfig := tgbotapi.NewUpdate(0) | ||
updateConfig.Timeout = 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same thing - hardcoded parameters is evil.
|
||
for update := range updates { | ||
if update.Message != nil { | ||
conn, _ = net.Dial("tcp", "127.0.0.1:8080") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again
|
||
id := update.Message.Chat.ID | ||
|
||
if len(update.Message.Text) > 100 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you limiting message here?
default: | ||
message = "incorrect request" | ||
} | ||
conn.Write([]byte(message + "\v")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unhandled error
|
||
|
||
func MakeUrl(city string)(string, error){ | ||
KeyWeather, err := ReadToken("./weather_token.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardcode
return "", err | ||
} | ||
|
||
URL := "https://api.openweathermap.org/data/2.5/weather?q=" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same
} | ||
|
||
cityStr := strings.Replace(request, "/city ", "", 1) | ||
url, _ := MakeUrl(cityStr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't extract different layers in application. All in one file - handle requests, app logic, work with db.
No description provided.