Add weather command

This commit is contained in:
g1n 2021-11-28 09:04:45 +00:00
parent d9d6ef0a70
commit b5c2978e4a
2 changed files with 10 additions and 1 deletions

View File

@ -4,9 +4,10 @@ from config import pygbot as c
from config import changeobj
import youtube as yt
import web
import weather as w
def bothelp(bot, channel):
helpmsg = """Hi I am pygbot. Created by g1n. My commands: help, ping, echo, yt (youtube), t (title) but more features are planing"""
helpmsg = """Hi I am pygbot. Created by g1n. My commands: help, ping, echo, yt (youtube), t (title), w (weather) but more features are planing"""
bot.send(channel, helpmsg)
def isadmin(user):
@ -47,6 +48,8 @@ def bot_command_parser(config, bot, user, channel, message):
yt.gettitle(bot, channel, message)
elif message.split()[0] == (c.prefix + "t") or message.split()[0] == (c.prefix + "title"):
web.gettitle(bot, channel, message)
elif message.split()[0] == (c.prefix + "w") or message.split()[0] == (c.prefix + "weather"):
w.getweather(bot, channel, message)
else:
parseiflink(bot, channel, message)

6
weather.py Normal file
View File

@ -0,0 +1,6 @@
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)