|
|
@@ -1,9 +1,9 @@
|
|
|
import logging
|
|
|
import requests
|
|
|
import requests.exceptions
|
|
|
-import tts
|
|
|
import ears
|
|
|
import base
|
|
|
+import output
|
|
|
|
|
|
_RECIPIENTS = {
|
|
|
'martin': 'martin@gerner.co',
|
|
|
@@ -36,7 +36,7 @@ class Email(base.BaseFunction):
|
|
|
def _send(self, recipient):
|
|
|
logging.info('email _send: %s', recipient)
|
|
|
|
|
|
- tts.tts(recipient)
|
|
|
+ output.text(recipient)
|
|
|
|
|
|
lines, terminator = ears.listen_until_terminated()
|
|
|
|
|
|
@@ -45,13 +45,13 @@ class Email(base.BaseFunction):
|
|
|
logging.info('Sending email: %s: %s', _RECIPIENTS[recipient], lines)
|
|
|
try:
|
|
|
_send_by_sendgrid(_RECIPIENTS[recipient], 'snowbody email', body)
|
|
|
- tts.tts('done')
|
|
|
+ output.success()
|
|
|
except requests.exceptions.HTTPError, e:
|
|
|
- tts.tts('error')
|
|
|
+ output.failure()
|
|
|
logging.error(e)
|
|
|
|
|
|
else:
|
|
|
- tts.tts('cancelled')
|
|
|
+ output.cancelled()
|
|
|
|
|
|
def call(self, additional_tokens=None, **_):
|
|
|
logging.info('email: %s', additional_tokens)
|
|
|
@@ -61,7 +61,7 @@ class Email(base.BaseFunction):
|
|
|
self._send(t)
|
|
|
return
|
|
|
|
|
|
- tts.tts('to whom?')
|
|
|
+ output.text('to whom?')
|
|
|
recipient = ears.listen(pause_threshold=1, preferred_phrases=self.preferred_phrases())
|
|
|
if recipient in _RECIPIENTS:
|
|
|
self._send(recipient)
|