Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: k4cg/Rezeptionistin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 24033a12498b
Choose a base ref
...
head repository: k4cg/Rezeptionistin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8e9e004818f8
Choose a head ref
  • 2 commits
  • 10 files changed
  • 1 contributor

Commits on Feb 4, 2017

  1. keepalive failed

    noqqe committed Feb 4, 2017
    Copy the full SHA
    0b3a617 View commit details

Commits on Feb 6, 2017

  1. reworked sensor part

    noqqe committed Feb 6, 2017
    Copy the full SHA
    8e9e004 View commit details
Showing with 71 additions and 127 deletions.
  1. +1 −13 README.md
  2. +1 −12 config.ini.example
  3. +0 −7 keepalive.sh
  4. +14 −10 language.ini
  5. +12 −25 plugins/light.py
  6. +0 −34 plugins/openstatus.py
  7. +8 −23 plugins/sound.py
  8. +22 −0 plugins/spacestatus.py
  9. +2 −3 plugins/temperature.py
  10. +11 −0 rezeptionistin.py
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -63,31 +63,19 @@ wikiapiurl = https://k4cg.org/api.php
user = Rezeptionistin
password = passw0rd

[OpenStatus]
[SpaceStatus]
url = http://[2001:dead:beef::1]:80/status.json

[Language]
language = de

[Temperature]
host = 2001:a60:f073:0:21d:92ff:fe25:2a23
port = 31337
wunderground = http://api.wunderground.com/api/a5744ceb15b96090/conditions/q/pws:INUREMBE2.json

[Sentences]
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
13 changes: 1 addition & 12 deletions config.ini.example
Original file line number Diff line number Diff line change
@@ -15,28 +15,17 @@ wikiapiurl = https://k4cg.org/api.php
user = Rezeptionistin
password = passw0rd

[OpenStatus]
[SpaceStatus]
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
7 changes: 0 additions & 7 deletions keepalive.sh

This file was deleted.

24 changes: 14 additions & 10 deletions language.ini
Original file line number Diff line number Diff line change
@@ -37,10 +37,10 @@ lineart_help = !lineart - Zeige eine lineart
# nickserv.py - NickServ Plugin
nickserv_help = Mich beim freenode NickServ authentifizieren.

# openstatus.py - Open Status Plugin
openstatus_help = !offen - Aktuelle Geraete in der K4CG anzeigen lassen
openstatus_str1 = Wahrscheinlich. Momentan sind {d} Geraete in der K4CG
openstatus_str2 = Sorry, sieht nicht so aus als waere jemand in der K4CG
# spacestatus.py - Open Status Plugin
spacestatus_help = !offen - Aktuelle Geraete in der K4CG anzeigen lassen
spacestatus_str1 = Wahrscheinlich. Momentan sind {d} Geraete in der K4CG
spacestatus_str2 = Sorry, sieht nicht so aus als waere jemand in der K4CG

# playlist.py - Playlist plugin
playlist_help = !np - Dir sagen welche Musik so laeuft.
@@ -63,11 +63,15 @@ temp_str3 = Ich konnte die Temperatur in der K4CG *nicht* abfragen. Die aktuelle
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
# 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"

# 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

[en]
# alive.py - Alive Plugin
@@ -108,10 +112,10 @@ lineart_help = !lineart - Show a lineart
# nickserv.py - NickServ Plugin
nickserv_help = Authenticate to freenode NickServ.
# openstatus.py - Open Status Plugin
openstatus_help = !open - Current connected devices at K4CG
openstatus_str1 = Probably. Currently there are {d} devices at K4CG
openstatus_str2 = Sorry, it doesn't look like there is anyone at K4CG at the moment
# spacestatus.py - Open Status Plugin
spacestatus_help = !open - Current connected devices at K4CG
spacestatus_str1 = Probably. Currently there are {d} devices at K4CG
spacestatus_str2 = Sorry, it doesn't look like there is anyone at K4CG at the moment

# playlist.py - Playlist plugin
playlist_help = !np - Tells you which music we hear
37 changes: 12 additions & 25 deletions plugins/light.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
# coding: utf8

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

class Licht(Plugin):
class Light(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__()
super(Light, 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²")
return bot.translate("light_help")

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, user_nick)
if message.startswith("!licht") or message.startswith("!light"):
msg = bot.get_spacestatus_data()
f = msg['light']

if float(f) > 0:
bot.send_message(channel, bot.translate("Light_str1").format(light=f), user_nick)
else:
bot.send_message(channel, bot.translate("Light_str2").format(light=f), user_nick)

34 changes: 0 additions & 34 deletions plugins/openstatus.py

This file was deleted.

31 changes: 8 additions & 23 deletions plugins/sound.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
# 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', user_nick)
else:
bot.send_message(channel, 'Geraeuschintensitaet konnte *nicht* abgefragt werden', user_nick)
if message.startswith("!noise") or message.startswith("!geraeusche"):
msg = bot.get_spacestatus_data()
f = msg['sound']

if float(f) > 0:
bot.send_message(channel, bot.translate("Sound_str1").format(sound=f), user_nick)
else:
bot.send_message(channel, bot.translate("Sound_str2").format(sound=f), user_nick)
22 changes: 22 additions & 0 deletions plugins/spacestatus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import re
import json
import ConfigParser
from plugin import Plugin

class Open(Plugin):

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

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

def on_msg(self, bot, user_nick, host, channel, message):
if message.startswith("!offen") or message.startswith("!open"):
msg = bot.get_spacestatus_data()
f = msg['online']

if int(f) > 0:
bot.send_message(channel, bot.translate("spacestatus_str1").format(d=f), user_nick)
else:
bot.send_message(channel, bot.translate("spacestatus_str2").format(d=f), user_nick)
5 changes: 2 additions & 3 deletions plugins/temperature.py
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@ class Temperature(Plugin):

def __init__(self, config=None):
try:
self.temp_host = config.get('Temperature', 'host')
self.temp_port = config.get('Temperature', 'port')
self.wunderground = config.get('Temperature', 'wunderground')
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
print "Temperature was not properly configured in your config.ini"
@@ -20,7 +18,8 @@ def help_text(self, bot):
return bot.translate("temp_help")

def get_indoor_temp(self, bot):
temp = bot.netcat(self.temp_host, int(self.temp_port), "9001").strip()
msg = bot.get_spacestatus_data()
temp = msg['temp']
return temp

def get_outdoor_temp(self, bot):
11 changes: 11 additions & 0 deletions rezeptionistin.py
Original file line number Diff line number Diff line change
@@ -112,6 +112,17 @@ def getpage(self, url):
soup = BeautifulSoup(urllib2.urlopen(req),"html.parser")
return soup

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

return data

def geturltitle(self, url):
try:
page = self.getpage(url)