Fixed weather command

This commit is contained in:
g1n 2021-12-18 15:35:11 +00:00
parent d9bc203053
commit 36e1e93590
2 changed files with 7 additions and 4 deletions

2
irc.py
View File

@ -75,7 +75,7 @@ class IRC:
return resp
def shutdown(self, sig=None, frame=None, msg=None):
self.rawsend(b"QUIT Catched SIGINT\n") if msg == None else self.rawsend(bytes(f"QUIT bye\n", "UTF-8"))
self.rawsend(b"QUIT Caught SIGINT\n") if msg == None else self.rawsend(bytes(f"QUIT bye\n", "UTF-8"))
self.sock.shutdown(2) #SHUT_RDWR
self.sock.close()
sys.exit(0)

View File

@ -1,6 +1,9 @@
import requests
def getweather(bot, channel, message):
location = message.split()[1:]
page = requests.get(f"https://wttr.in/{'+'.join(location)}?format=%l+|+%t+|+%C+|+Humidity:+%h+|+Wind:+%w")
bot.send(channel, page.text)
try:
location = message.split()[1:]
page = requests.get(f"http://wttr.in/{'+'.join(location)}?format=%l+|+%t+|+%C+|+Humidity:+%h+|+Wind:+%w")
bot.send(channel, page.text)
except:
bot.send(channel, "Failed to get weather")