S
S
Sergey Karpov2021-08-17 04:48:25
Python
Sergey Karpov, 2021-08-17 04:48:25

How to link pyowm and telebot?

Hello, I just started learning Python.
I have a specific code that outputs the weather through the API, it has a place variable.
How to make the user text he sends pyowm code see as a variable tried like this:

if message.chat.type == 'private':
        if  message.text == "Москва" :
            owm = OWM('MyAPI')
            mgr = owm.weather_manager()
            place = input(message.text)
            observation = mgr.weather_at_place(place)

at the end the code is:
bot.send_message(message.chat.id,"В городе "+place+" сейчас температура: " + str(kelvin_to_celsius(w.temp['temp'])) + " по Цельсию. ")

I don’t want to watch ready-made lessons, where it is explained point by point how to do it, I tried to think it all over myself for 3 hours, I received only this answer from the bot: "Weather in the specified city: '+ observation.location.name"
It is clear that the part of the code that recognizes the weather, just does not see what the user enters.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-08-17
@SoreMix

Do you just need a city? So he message.textlies in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question