Created
December 30, 2015 15:25
-
-
Save EspressoCake/e378928eddd231e8d242 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 pprint | |
import pywapi | |
import time | |
import requests | |
import json | |
def hipchatWeatherAPI(): | |
while True: | |
noaa = pywapi.get_weather_from_weather_com('replace_with_your_zip_code') | |
rightnow = time.strftime("%H:%M") | |
temperature = int(float(noaa['current_conditions']['temperature']) * float(9/5) + 32) | |
generalweather = noaa['current_conditions']['text'] | |
messagesForRoom = ("It is currently " + str(temperature) + "F, and " + str(generalweather).upper() + " as of " + str(rightnow)) | |
room = 'https://hipchat_base_url/v2/room/replace_with_number/notification' | |
headers = {'Authorization':'Bearer your_api_token', 'Content-type':'application/json'} | |
requests.post(url = room, data = json.dumps({'message':messagesForRoom, 'color':'random'}), headers = headers, verify=False) | |
time.sleep(1800) | |
hipchatWeatherAPI() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment