Skip to content
Permalink
Browse files

fixes to make new sensors work

  • Loading branch information...
noqqe committed Feb 7, 2017
1 parent 8e9e004 commit 045cfa284559c6b1b6ae0451a2011d312111c680
Showing with 17 additions and 10 deletions.
  1. +3 −3 language.ini
  2. +1 −1 plugins/light.py
  3. +1 −1 plugins/sound.py
  4. +2 −2 plugins/spacestatus.py
  5. +1 −1 plugins/temperature.py
  6. +9 −2 rezeptionistin.py
@@ -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
@@ -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)
@@ -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)
@@ -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")
@@ -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):
@@ -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
@@ -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(',')
@@ -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
@@ -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"

0 comments on commit 045cfa2

Please sign in to comment.
You can’t perform that action at this time.