Skip to content

Commit

Permalink
fixes to make new sensors work
Browse files Browse the repository at this point in the history
  • Loading branch information
noqqe committed Feb 7, 2017
1 parent 8e9e004 commit 045cfa2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions language.ini
Expand Up @@ -65,13 +65,13 @@ url_help2 = oder dir den Titel von URLs sagen die du in den Channel postest

# light.py
light_help = !licht - Zeige aktuelle UV Strahlung in der K4CG
light_str1 = "Es ist gerade {light} hell"
light_str2 = "Es ist gerade sehr dunkel"
light_str1 = Es ist gerade {light} hell
light_str2 = Es ist gerade sehr dunkel

# sound.py
sound_help = !geraeusche - Zeige aktuellen Geraeuschpegel in der K4CG
sound_str1 = Momentane Geraeuschintensitaet: {sound}/3300
sound_str1 = Totale stille in der CG. {sound}/3300
sound_str2 = Totale stille in der CG. {sound}/3300

[en]
# alive.py - Alive Plugin
Expand Down
2 changes: 1 addition & 1 deletion plugins/light.py
Expand Up @@ -11,7 +11,7 @@ def help_text(self, bot):
def on_msg(self, bot, user_nick, host, channel, message):
if message.startswith("!licht") or message.startswith("!light"):
msg = bot.get_spacestatus_data()
f = msg['light']
f = str(msg['light'])

if float(f) > 0:
bot.send_message(channel, bot.translate("Light_str1").format(light=f), user_nick)
Expand Down
2 changes: 1 addition & 1 deletion plugins/sound.py
Expand Up @@ -13,7 +13,7 @@ def help_text(self, bot):
def on_msg(self, bot, user_nick, host, channel, message):
if message.startswith("!noise") or message.startswith("!geraeusche"):
msg = bot.get_spacestatus_data()
f = msg['sound']
f = str(msg['sound'])

if float(f) > 0:
bot.send_message(channel, bot.translate("Sound_str1").format(sound=f), user_nick)
Expand Down
4 changes: 2 additions & 2 deletions plugins/spacestatus.py
Expand Up @@ -3,10 +3,10 @@
import ConfigParser
from plugin import Plugin

class Open(Plugin):
class SpaceStatus(Plugin):

def __init__(self, config=None):
super(Open, self).__init__()
super(SpaceStatus, self).__init__()

def help_text(self, bot):
return bot.translate("spacestatus_help")
Expand Down
2 changes: 1 addition & 1 deletion plugins/temperature.py
Expand Up @@ -19,7 +19,7 @@ def help_text(self, bot):

def get_indoor_temp(self, bot):
msg = bot.get_spacestatus_data()
temp = msg['temp']
temp = str(msg['temp'])
return temp

def get_outdoor_temp(self, bot):
Expand Down
11 changes: 9 additions & 2 deletions rezeptionistin.py
Expand Up @@ -2,13 +2,15 @@
# -*- coding: utf-8 -*-

import re
import json
import time
import random
import socket
import string
import codecs
import urllib2
import ConfigParser
import logging
from plugin import Plugin
from vendor import importdir
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -46,6 +48,7 @@ def __init__(self):
self.debugchan=self.config.get('IRC', 'debugchan')
self.useragent=self.config.get('HTTP', 'useragent')
self.language=self.config.get('Language','language')
self.spacestatus=self.config.get('SpaceStatus', 'url')

try:
self.ignore=self.config.get('IRC','ignore').split(',')
Expand Down Expand Up @@ -103,6 +106,9 @@ def netcat(self, hostname, port, content):
s.close()
return f

def debug(self, msg):
logging.debug(msg)

def geturlsfrommsg(self, message):
url = re.findall("(?P<url>https?://[^\s]+)", message)
return url
Expand All @@ -112,12 +118,13 @@ def getpage(self, url):
soup = BeautifulSoup(urllib2.urlopen(req),"html.parser")
return soup

def get_spacestatus_data(self, url):
def get_spacestatus_data(self):
data = None
try:
self.spacestatus = config.get('SpaceStatus', 'url')
data = self.getpage(self.spacestatus)
data = self.sanitize(data)
data = json.loads(data)
self.debug(data)
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
print "SpaceStatus was not properly configured in your config.ini"

Expand Down

0 comments on commit 045cfa2

Please sign in to comment.