Add weather command
This commit is contained in:
parent
d9d6ef0a70
commit
b5c2978e4a
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue