Skip to content

Commit e64e9ae

Browse files
author
System administrator
committedSep 2, 2016
Sound and Light Plugins
1 parent 3c9dbe2 commit e64e9ae

File tree

6 files changed

+114
-2
lines changed

6 files changed

+114
-2
lines changed
 

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ wunderground = http://api.wunderground.com/api/a5744ceb15b96090/conditions/q/pws
7878
satzgenerator = on
7979
markov = on
8080
markovfile = /usr/local/rezeptionistin/corpus.txt
81+
82+
[Licht]
83+
host = 127.0.0.1
84+
port = 31338
85+
id = xpa
86+
87+
[Geraeusche]
88+
host = 127.0.0.1
89+
port = 31338
90+
id = voE
8191
```
8292

8393
# Language

‎config.ini.example

+20
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,23 @@ url = http://[2001:dead:beef::1]:80/status.json
1919

2020
[Language]
2121
language = de
22+
23+
[Temperature]
24+
host = 2001:dead:beef::1
25+
port = 31337
26+
wunderground = http://api.wunderground.com/api/a5744ceb15b96090/conditions/q/pws:INUREMBE2.json
27+
28+
[Sentences]
29+
satzgenerator = off
30+
markov = on
31+
markovfile = /path/to/corpus.txt
32+
33+
[Licht]
34+
host = 127.0.0.1
35+
port = 31338
36+
id = xpa
37+
38+
[Geraeusche]
39+
host = 127.0.0.1
40+
port = 31338
41+
id = voE

‎language.ini

+14-2
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,20 @@ tell_cmd = !sage
5555

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

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

66+
# licht.py
67+
licht_help = !licht - Zeige aktuelle UV Strahlung in der K4CG
68+
69+
# sound.py
70+
sound_help = !geraeusche - Zeige aktuellen Geraeuschpegel in der K4CG
71+
6672
[en]
6773
# alive.py - Alive Plugin
6874
alive_help = !gt - Wish a good day
@@ -120,11 +126,17 @@ tell_cmd = !tell
120126

121127
# temperature.py - Temperature Plugin
122128
temp_help = !kt - Tell the current temperature at K4CG.
123-
temp_str1 = The actual temperature at K4CG is {temp}°C inside
129+
temp_str1 = The actual temperature at K4CG is {temp}°C inside
124130
temp_str2 = and {temp}°C outside.
125131
temp_str3 = The actual temperature outside is {temp}°C. I failed to check the temperature at K4CG.
126132
temp_str3 = I failed to check the temperature at K4CG. The actual temperature outside is {temp}°C.
127133

128134
# urls.py - URLs Plugin
129135
url_help = !private <link> - Share a link that is not listed in the wiki. (alternative: !pr, !nsfw)
130136
url_help2 = or say the URL title that you post on the channel.
137+
138+
# licht.py
139+
licht_help = !licht - Show current UV Light at the hackerspace
140+
141+
# sound.py
142+
sound_help = !geraeusche - Show current noise in the hackerspace

‎plugins/light.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# coding: utf8
2+
3+
import socket
4+
from tinkerforge.ip_connection import IPConnection
5+
from tinkerforge.bricklet_uv_light import BrickletUVLight
6+
from plugin import Plugin
7+
8+
class Licht(Plugin):
9+
10+
def __init__(self, config=None):
11+
try:
12+
self.licht_host = config.get('Licht', 'host')
13+
self.licht_port = config.get('Licht', 'port')
14+
self.licht_id = config.get('Licht', 'id')
15+
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
16+
print "Licht was not properly configured in your config.ini"
17+
super(Licht, self).__init__()
18+
19+
def help_text(self, bot):
20+
return bot.translate("licht_help")
21+
22+
def get_light(self):
23+
ipcon = IPConnection()
24+
uvl = BrickletUVLight(self.licht_id, ipcon)
25+
ipcon.connect(self.licht_host, int(self.licht_port))
26+
uv_light = uvl.get_uv_light()
27+
ipcon.disconnect()
28+
return(str(uv_light) + " µW/cm²")
29+
30+
def on_msg(self, bot, user_nick, host, channel, message):
31+
if message.lower().startswith('!licht'):
32+
m = self.get_light()
33+
bot.send_message(channel, 'Momentane Lichtverhaeltnisse: ' + m)

‎plugins/sound.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# coding: utf8
2+
3+
import socket
4+
from tinkerforge.ip_connection import IPConnection
5+
from tinkerforge.bricklet_sound_intensity import BrickletSoundIntensity
6+
from plugin import Plugin
7+
8+
class Sound(Plugin):
9+
10+
def __init__(self, config=None):
11+
try:
12+
self.sound_host = config.get('Geraeusche', 'host')
13+
self.sound_port = config.get('Geraeusche', 'port')
14+
self.sound_id = config.get('Geraeusche', 'id')
15+
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
16+
print "Geraeusche was not properly configured in your config.ini"
17+
super(Sound, self).__init__()
18+
19+
def help_text(self, bot):
20+
return bot.translate("sound_help")
21+
22+
def get_sound(self):
23+
ipcon = IPConnection()
24+
uvl = BrickletSoundIntensity(self.sound_id, ipcon)
25+
ipcon.connect(self.sound_host, int(self.sound_port))
26+
intensity = uvl.get_intensity()
27+
ipcon.disconnect()
28+
return(str(intensity))
29+
30+
def on_msg(self, bot, user_nick, host, channel, message):
31+
if message.lower().startswith('!geraeusche') or message.lower().startswith('!sound'):
32+
m = self.get_sound()
33+
if not m == '':
34+
bot.send_message(channel, 'Momentane Geraeuschintensitaet: ' + m + '/3300')
35+
else:
36+
bot.send_message(channel, 'Geraeuschintensitaet konnte *nicht* abgefragt werden')

‎requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ wikitools
22
beautifulsoup4
33
git+https://github.com/k4cg/AsyncIRC.git
44
markovify
5+
tinkerforge

0 commit comments

Comments
 (0)
Please sign in to comment.