Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Hal-9000-Chatbot/Weather.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (22 sloc)
870 Bytes
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
import discord | |
from discord.ext.commands import bot | |
from discord.ext import commands | |
import asyncio | |
import time | |
from weather import Weather, Unit | |
Client = discord.Client() | |
client = commands.Bot(command_prefix="!") | |
@client.event | |
async def on_ready(): | |
print("Hello Dave") | |
@client.event | |
async def on_message(message): | |
place = message.content | |
weather = Weather(unit=Unit.CELSIUS) | |
location = weather.lookup_by_location(place) | |
forecasts = location.forecast | |
for forecast in forecasts: | |
await client.send_message(message.channel, "Forecast: " + forecast.text + " Date: " + forecast.date ) | |
await client.send_message(message.channel, "High: " + forecast.high + " Low: " + forecast.low) | |
await client.send_message(message.channel, "Day: " + forecast.day) | |
client.run("NTAzNjU2MTc3NjgzMzk4Njc1.Dq5txg.WDWMGBovm-6VOTP86Nipck5YOcw") |