summaryrefslogtreecommitdiff
path: root/client/conversation.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-10-03 13:44:56 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2014-10-03 13:44:56 +0200
commitc263709078c096faef891502e06cc9e9ade65777 (patch)
tree3cc100c2390db9d9db9b49d24c053234e98f683f /client/conversation.py
parent5da45db2bd435c249229b816a1c68ff520c54c7a (diff)
parent66264fa47e264e2518abaaad5f44424c1c2e0864 (diff)
downloadjasper-client-c263709078c096faef891502e06cc9e9ade65777.tar.gz
jasper-client-c263709078c096faef891502e06cc9e9ade65777.zip
Merge pull request #209 from Holzhaus/musicmode-as-module
Musicmode as module
Diffstat (limited to 'client/conversation.py')
-rw-r--r--client/conversation.py33
1 files changed, 1 insertions, 32 deletions
diff --git a/client/conversation.py b/client/conversation.py
index 0746b7f..9b86295 100644
--- a/client/conversation.py
+++ b/client/conversation.py
@@ -1,10 +1,7 @@
# -*- coding: utf-8-*-
import logging
from notifier import Notifier
-from musicmode import *
from brain import Brain
-from mpd import MPDClient
-
class Conversation(object):
@@ -16,34 +13,6 @@ class Conversation(object):
self.brain = Brain(mic, profile)
self.notifier = Notifier(profile)
- def delegateInput(self, texts):
- """A wrapper for querying brain."""
-
- # check if input is meant to start the music module
- for text in texts:
- if any(x in text.upper() for x in ["SPOTIFY", "MUSIC"]):
- self._logger.debug("Preparing to start music module")
- # check if mpd client is running
- try:
- client = MPDClient()
- client.timeout = None
- client.idletimeout = None
- client.connect("localhost", 6600)
- except:
- self._logger.critical("Can't connect to mpd client, cannot start music mode.", exc_info=True)
- self.mic.say(
- "I'm sorry. It seems that Spotify is not enabled. Please read the documentation to learn how to configure Spotify.")
- return
-
- self.mic.say("Please give me a moment, I'm loading your Spotify playlists.")
- self._logger.debug("Starting music mode")
- music_mode = MusicMode(self.persona, self.mic)
- music_mode.handleForever()
- self._logger.debug("Exiting music mode")
- return
-
- self.brain.query(texts)
-
def handleForever(self):
"""Delegates user input to the handling function when activated."""
self._logger.info("Starting to handle conversation with keyword '%s'.", self.persona)
@@ -67,6 +36,6 @@ class Conversation(object):
self._logger.debug("Stopped to listen actively with threshold: %r", threshold)
if input:
- self.delegateInput(input)
+ self.brain.query(input)
else:
self.mic.say("Pardon?")