Files
limoka/Fl1yd/FTG-Modules/weather.py
2025-07-11 08:27:20 +00:00

26 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
from .. import loader, utils
def register(cb):
cb(WeatherMod())
class WeatherMod(loader.Module):
"""Погода с сайта wttr.in"""
strings = {'name': 'Weather'}
async def pwcmd(self, message):
""""Кидает погоду картинкой.\nИспользование: .pw <город>; ничего."""
args = utils.get_args_raw(message).replace(' ', '+')
await message.edit("Узнаем погоду...")
city = requests.get(f"https://wttr.in/{args if args != None else ''}.png").content
await message.client.send_file(message.to_id, city)
await message.delete()
async def awcmd(self, message):
"""Кидает погоду ascii-артом.\nИспользование: .aw <город>; ничего."""
city = utils.get_args_raw(message)
await message.edit("Узнаем погоду...")
r = requests.get(f"https://wttr.in/{city if city != None else ''}?0?q?T&lang=ru")
await message.edit(f"<code>Город: {r.text}</code>")