Created
January 13, 2022 16:11
-
-
Save mishailovic/3fe9766b9af37a77cc793853e5bb1a68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .. import loader, utils # pylint: disable=relative-beyond-top-level | |
import logging | |
import requests | |
logger = logging.getLogger(__name__) | |
def register(cb): | |
cb(WWTrMod()) | |
@loader.tds | |
class WWWTrMod(loader.Module): | |
"""Get weather using wttr.in""" | |
strings = {"name": "wttr", "processing": "Getting weather..."} | |
@loader.unrestricted | |
async def wttrcmd(self, message): | |
""".wttr <city> for weather | |
can also work with multiple cities separated with spaces""" | |
city = utils.get_args(message) | |
if city: | |
msg_text = [] | |
msg = await utils.answer(message, self.strings("processing", message)) | |
for i in city: | |
r = requests.get("https://wttr.in/" + i + "?format=%l:+%c+%t,+%w+%m&m") | |
msg_text.append(r.text) | |
await msg[0].edit("\n".join(msg_text)) | |
else: | |
msg = await utils.answer(message, self.strings("processing", message)) | |
r = requests.get("https://wttr.in/?format=%l:+%c+%t,+%w+%m&m") | |
await msg[0].edit(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment