Reply in Telegram with the current conditions for whatever place someone names in the chat.

UsesOpenWeatherMapTelegram

Look up the weather from Telegram

Whenever a message in your Telegram chat starts with your chosen keyword followed by a place name, the current conditions there are looked up and the reply comes back in the same chat: conditions, temperature and what it feels like, humidity and wind. Multi-word places work, and so does a postal code or a name with a country code when the plain name is ambiguous.

The reply reports the readings that came back and nothing more. It does not warn about severe weather, because a current reading is not a warning, and any reading the service does not return is left out rather than shown as zero. A place that cannot be found gets a reply saying so, with a hint about adding a country code. Messages that do not start with the keyword are ignored, so the bot stays quiet in a busy group.

You need a Telegram bot in the chat and a keyword for it to listen for, and temperatures come back in the units you choose.

TelegramTelegramWhen a new message is received. Save it as message.When a new message is received. Save it as message.
Set weatherKeyword to blank.Set weatherKeyword to blank.
Set units to “metric”.Set units to “metric”.
Set chatId to message.chat_id.Set chatId to message.chat_id.
Set messageText to blank.Set messageText to blank.
If a step below fails, save the error as noTextErrorIf a step below fails, save the error as noTextError
Try
Trim message.text and save it as messageText.Trim message.text and save it as messageText.
On error
Show in the output: “This message carried no text, so there was nothing to look up.”.Show in the output: “This message carried no text, so there was nothing to look up.”.
If messageText is emptyIf messageText is empty
Yes
Finish the run: This message carried no text, so no weather was looked up.Finish the run: This message carried no text, so no weather was looked up.
No
No steps
Split messageText by a space and save it as words.Split messageText by a space and save it as words.
TextMake words[0] lowercase and save it as commandWord.Make words[0] lowercase and save it as commandWord.
If commandWord is not weatherKeyword in lowercaseIf commandWord is not weatherKeyword in lowercase
Yes
Finish the run: This message was not a weather request, so nothing was looked up.Finish the run: This message was not a weather request, so nothing was looked up.
No
No steps
Trim the items from index 1 onward of words joined by a space and save it as place.Trim the items from index 1 onward of words joined by a space and save it as place.
If place is empty or the length of place is greater than 60If place is empty or the length of place is greater than 60
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Send a place after '@weatherKeyword', for example: weatherKeyword London
Finish the run: No usable place name was in the message.Finish the run: No usable place name was in the message.
No
No steps
Set weather to nothing.Set weather to nothing.
Set lookupFailed to false.Set lookupFailed to false.
If a step below fails, save the error as weatherErrorIf a step below fails, save the error as weatherError
Try
OpenWeatherMapOpenWeatherMapGet the current weather. Save it as weather.Get the current weather. Save it as weather.
On error
Change lookupFailed to true.Change lookupFailed to true.
If lookupFailed is yesIf lookupFailed is yes
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not look up the weather for place. Try adding a country code, like London,GB, or a postal code.
Finish the run: No weather was found for place.Finish the run: No weather was found for place.
No
No steps
Set temperatureUnit to “K”.Set temperatureUnit to “K”.
Set windUnit to “ m/s”.Set windUnit to “ m/s”.
If weather.units is “metric”If weather.units is “metric”
Yes
Change temperatureUnit to “°C”.Change temperatureUnit to “°C”.
No
No steps
If weather.units is “imperial”If weather.units is “imperial”
Yes
Change temperatureUnit to “°F”.Change temperatureUnit to “°F”.
Change windUnit to “ mph”.Change windUnit to “ mph”.
No
No steps
Set replyLines to an empty list.Set replyLines to an empty list.
Set heading to place.Set heading to place.
If weather.location isn't emptyIf weather.location isn't empty
Yes
Change heading to weather.location.Change heading to weather.location.
No
No steps
If weather.country isn't emptyIf weather.country isn't empty
Yes
Change heading to “@heading, weather.country”.Change heading to “@heading, weather.country”.
No
No steps
Add heading to the end of replyLines and save it as replyLines.Add heading to the end of replyLines and save it as replyLines.
If weather.conditions isn't emptyIf weather.conditions isn't empty
Yes
Add Conditions: weather.conditions to the end of replyLines and save it as replyLines.Add Conditions: weather.conditions to the end of replyLines and save it as replyLines.
No
No steps
If weather.temperature isn't emptyIf weather.temperature isn't empty
Yes
Add Temperature: weather.temperature formatted as a plain number with 1 decimal place@temperatureUnit to the end of replyLines and save it as replyLines.Add Temperature: weather.temperature formatted as a plain number with 1 decimal place@temperatureUnit to the end of replyLines and save it as replyLines.
No
No steps
If weather.feels_like isn't emptyIf weather.feels_like isn't empty
Yes
Add Feels like: weather.feels_like formatted as a plain number with 1 decimal place@temperatureUnit to the end of replyLines and save it as replyLines.Add Feels like: weather.feels_like formatted as a plain number with 1 decimal place@temperatureUnit to the end of replyLines and save it as replyLines.
No
No steps
If weather.humidity isn't emptyIf weather.humidity isn't empty
Yes
Add Humidity: weather.humidity formatted as a plain number with 0 decimal places% to the end of replyLines and save it as replyLines.Add Humidity: weather.humidity formatted as a plain number with 0 decimal places% to the end of replyLines and save it as replyLines.
No
No steps
If weather.wind_speed isn't emptyIf weather.wind_speed isn't empty
Yes
Add Wind: weather.wind_speed formatted as a plain number with 1 decimal place@windUnit to the end of replyLines and save it as replyLines.Add Wind: weather.wind_speed formatted as a plain number with 1 decimal place@windUnit to the end of replyLines and save it as replyLines.
No
No steps
Add “Current conditions reported by OpenWeatherMap.” to the end of replyLines and save it as replyLines.Add “Current conditions reported by OpenWeatherMap.” to the end of replyLines and save it as replyLines.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.replyLines joined by a new line