forked from OpenVoiceOS/ovos-audio-transformer-plugin-ggwave
-
Notifications
You must be signed in to change notification settings - Fork 2
/
__init__.py
42 lines (32 loc) · 1.3 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import datetime
from ovos_workshop.skills.ovos import OVOSSkill
from ovos_workshop.decorators import intent_handler
class GGWaveSkill(OVOSSkill):
def initialize(self):
self.add_event("ggwave.enabled", self.handle_ggwave_on)
self.add_event("ggwave.disabled", self.handle_ggwave_off)
self.enabled = False
def handle_ggwave_on(self, message):
self.enabled = True
self.schedule_event(
handler=self.handle_ggwave_off,
when=datetime.datetime.now() + datetime.timedelta(minutes=15),
name="ggwave.timeout"
)
def handle_ggwave_off(self, message):
self.enabled = False
@intent_handler("enable.ggwave.intent")
def handle_enable_ggwave(self, message):
if not self.enabled:
self.bus.emit(message.forward("ovos.ggwave.enable"))
self.speak_dialog("ggwave.enabled")
else:
self.speak_dialog("ggwave.already.enabled")
@intent_handler("disable.ggwave.intent")
def handle_disable_ggwave(self, message):
if self.enabled:
self.bus.emit(message.forward("ovos.ggwave.disable"))
self.cancel_scheduled_event("ggwave.timeout")
self.speak_dialog("ggwave.disabled")
else:
self.speak_dialog("ggwave.already.disabled")