Skip to content
Permalink
Browse files

Sound and Light Plugins

  • Loading branch information...
System administrator
System administrator committed Sep 2, 2016
1 parent 3c9dbe2 commit e64e9ae408bf93b3c46afe593ade11bfc0cebcce
Showing with 114 additions and 2 deletions.
  1. +10 −0 README.md
  2. +20 −0 config.ini.example
  3. +14 −2 language.ini
  4. +33 −0 plugins/light.py
  5. +36 −0 plugins/sound.py
  6. +1 −0 requirements.txt
@@ -78,6 +78,16 @@ wunderground = http://api.wunderground.com/api/a5744ceb15b96090/conditions/q/pws
satzgenerator = on
markov = on
markovfile = /usr/local/rezeptionistin/corpus.txt
[Licht]
host = 127.0.0.1
port = 31338
id = xpa
[Geraeusche]
host = 127.0.0.1
port = 31338
id = voE
```

# Language
@@ -19,3 +19,23 @@ url = http://[2001:dead:beef::1]:80/status.json

[Language]
language = de

[Temperature]
host = 2001:dead:beef::1
port = 31337
wunderground = http://api.wunderground.com/api/a5744ceb15b96090/conditions/q/pws:INUREMBE2.json

[Sentences]
satzgenerator = off
markov = on
markovfile = /path/to/corpus.txt

[Licht]
host = 127.0.0.1
port = 31338
id = xpa

[Geraeusche]
host = 127.0.0.1
port = 31338
id = voE
@@ -55,14 +55,20 @@ tell_cmd = !sage

# temperature.py - Temperature Plugin
temp_help = !kt - Zeige aktuelle Temperatur in der K4CG.
temp_str1 = Die aktuelle Temperatur in der K4CG ist {temp}°C innen
temp_str1 = Die aktuelle Temperatur in der K4CG ist {temp}°C innen
temp_str2 = und {temp}°C aussen.
temp_str3 = Ich konnte die Temperatur in der K4CG *nicht* abfragen. Die aktuelle Temperatur aussen ist {temp}°C.

# urls.py - URLs Plugin
url_help = !private <link> - Einen Link teilen ohne dass er im Wiki gelistet wird. (alternativ: !pr, !nsfw)
url_help2 = oder dir den Titel von URLs sagen die du in den Channel postest

# licht.py
licht_help = !licht - Zeige aktuelle UV Strahlung in der K4CG

# sound.py
sound_help = !geraeusche - Zeige aktuellen Geraeuschpegel in der K4CG

[en]
# alive.py - Alive Plugin
alive_help = !gt - Wish a good day
@@ -120,11 +126,17 @@ tell_cmd = !tell

# temperature.py - Temperature Plugin
temp_help = !kt - Tell the current temperature at K4CG.
temp_str1 = The actual temperature at K4CG is {temp}°C inside
temp_str1 = The actual temperature at K4CG is {temp}°C inside
temp_str2 = and {temp}°C outside.
temp_str3 = The actual temperature outside is {temp}°C. I failed to check the temperature at K4CG.
temp_str3 = I failed to check the temperature at K4CG. The actual temperature outside is {temp}°C.

# urls.py - URLs Plugin
url_help = !private <link> - Share a link that is not listed in the wiki. (alternative: !pr, !nsfw)
url_help2 = or say the URL title that you post on the channel.

# licht.py
licht_help = !licht - Show current UV Light at the hackerspace

# sound.py
sound_help = !geraeusche - Show current noise in the hackerspace
@@ -0,0 +1,33 @@
# coding: utf8

import socket
from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_uv_light import BrickletUVLight
from plugin import Plugin

class Licht(Plugin):

def __init__(self, config=None):
try:
self.licht_host = config.get('Licht', 'host')
self.licht_port = config.get('Licht', 'port')
self.licht_id = config.get('Licht', 'id')
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
print "Licht was not properly configured in your config.ini"
super(Licht, self).__init__()

def help_text(self, bot):
return bot.translate("licht_help")

def get_light(self):
ipcon = IPConnection()
uvl = BrickletUVLight(self.licht_id, ipcon)
ipcon.connect(self.licht_host, int(self.licht_port))
uv_light = uvl.get_uv_light()
ipcon.disconnect()
return(str(uv_light) + " µW/cm²")

def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!licht'):
m = self.get_light()
bot.send_message(channel, 'Momentane Lichtverhaeltnisse: ' + m)
@@ -0,0 +1,36 @@
# coding: utf8

import socket
from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_sound_intensity import BrickletSoundIntensity
from plugin import Plugin

class Sound(Plugin):

def __init__(self, config=None):
try:
self.sound_host = config.get('Geraeusche', 'host')
self.sound_port = config.get('Geraeusche', 'port')
self.sound_id = config.get('Geraeusche', 'id')
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
print "Geraeusche was not properly configured in your config.ini"
super(Sound, self).__init__()

def help_text(self, bot):
return bot.translate("sound_help")

def get_sound(self):
ipcon = IPConnection()
uvl = BrickletSoundIntensity(self.sound_id, ipcon)
ipcon.connect(self.sound_host, int(self.sound_port))
intensity = uvl.get_intensity()
ipcon.disconnect()
return(str(intensity))

def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!geraeusche') or message.lower().startswith('!sound'):
m = self.get_sound()
if not m == '':
bot.send_message(channel, 'Momentane Geraeuschintensitaet: ' + m + '/3300')
else:
bot.send_message(channel, 'Geraeuschintensitaet konnte *nicht* abgefragt werden')
@@ -2,3 +2,4 @@ wikitools
beautifulsoup4
git+https://github.com/k4cg/AsyncIRC.git
markovify
tinkerforge

0 comments on commit e64e9ae

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