Last active
August 29, 2015 14:02
-
-
Save davemenninger/86f3013797b69cc30b62 to your computer and use it in GitHub Desktop.
Hive13 supybot plugin. uses hackerspace api, so usable by any hackerspace.
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 supybot.utils as utils | |
from supybot.commands import * | |
import supybot.plugins as plugins | |
import supybot.ircutils as ircutils | |
import supybot.callbacks as callbacks | |
from urllib2 import urlopen | |
from json import load | |
class Hive13(callbacks.Plugin): | |
"""Add the help for "@plugin help Hive13" here | |
This should describe *how* to use this plugin.""" | |
threaded = True | |
def hive(self, irc, msg, args): | |
"""uses the hackerspaces api to find out the current state of the hive | |
""" | |
url = "http://www.hive13.org/isOpen/api.php" | |
response = urlopen(url) | |
j = load(response) | |
summary = "Current state of the Hive: " | |
if ( j['open'] ): | |
summary += "The hive is open! " | |
else: | |
summary += "The hive is closed. " | |
summary += "Current temp: " + j['sensors'][0]['temp']['hive13'] | |
irc.reply(summary) | |
hive = wrap(hive) | |
Class = Hive13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment