Skip to content

Commit

Permalink
tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejgray committed Jun 15, 2024
1 parent d6c0f45 commit 0644bcd
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
57 changes: 40 additions & 17 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# pylint: disable=unused-import,missing-docstring,invalid-name
import random
from datetime import datetime
from os import getenv, listdir
from os.path import dirname, join
from datetime import datetime
from dateutil.tz import gettz

from dateutil.tz import gettz
from lingua_franca.time import default_timezone
from ovos_bus_client.apis.ocp import OCPInterface
from ovos_bus_client.message import Message
from ovos_bus_client.util.scheduler import EventScheduler
from ovos_mark1_utils.faceplate import FallingDots
from ovos_workshop.decorators import skill_api_method, intent_handler
from ovos_mark1.faceplate.animations import FallingDots
from ovos_workshop.intents import IntentBuilder
from ovos_workshop.decorators import intent_handler, skill_api_method
from ovos_workshop.skills import OVOSSkill
from ovos_bus_client.apis.ocp import OCPInterface

from skill_easter_eggs.constants import ANNUAL, ASCII_SNOW, SPICY_SOUNDS
from skill_easter_eggs.stardate import StarDate
from skill_easter_eggs.constants import SPICY_SOUNDS
from .constants import ANNUAL, ASCII_SNOW, SPICY_SOUNDS


class EasterEggsSkill(OVOSSkill):
Expand All @@ -26,6 +25,7 @@ def initialize(self):
self._event_scheduler = EventScheduler(bus=self.bus)
self.bus.on(f"{self.skill_id}.christmas_day", self.handle_christmas_day)
self._set_easter_egg_events()

@property
def event_scheduler(self) -> EventScheduler:
"""
Expand All @@ -48,25 +48,48 @@ def _get_user_tz(self):
:param message: Message associated with request
:return: timezone object
"""
return gettz(self.location_timezone) if self.location_timezone else \
default_timezone()
return (
gettz(self.location_timezone)
if self.location_timezone
else default_timezone()
)

def _set_easter_egg_events(self):
self.event_scheduler.schedule_event(Message("christmas_day"), {
"event": f"{self.skill_id}.christmas_day",
"time": datetime(year=datetime.now().year, month=12, day=25, hour=8, tzinfo=self._get_user_tz()),
"repeat": ANNUAL
})
self.event_scheduler.schedule_event(
"Christmas Day",
datetime(
year=datetime.now().year,
month=12,
day=25,
hour=8,
tzinfo=self._get_user_tz(),
).timestamp(),
ANNUAL,
Message("christmas_day").data,
{
"event": f"{self.skill_id}.christmas_day",
"time": datetime(
year=datetime.now().year,
month=12,
day=25,
hour=8,
tzinfo=self._get_user_tz(),
),
"repeat": ANNUAL,
},
)

def handle_christmas_day(self, _: Message):
# Mark 1
FallingDots(bus=self.bus).run()
# GUI
if self.gui:
self.gui.show_text(ASCII_SNOW)
self.speak("Ho ho ho")
self.speak_dialog("santa")

@intent_handler(IntentBuilder("grandma_mode_intent").require("grandma_mode_keyword").build())
@intent_handler(
IntentBuilder("grandma_mode_intent").require("grandma_mode_keyword").build()
)
def handle_grandma_mode(self, _):
self.settings["grandma_mode_enabled"] = True
self.speak("Ok, we'll tone it down a bit.")
Expand Down
2 changes: 2 additions & 0 deletions locale/en-us/dialog/santa.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ho Ho Ho!
Merry Christmas! Ho Ho Ho!
4 changes: 2 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
lingua_franca
ovos-lingua-franca
python-dateutil
ovos-utils~=0.0, >=0.0.38
ovos_workshop~=0.0, >=0.0.15
ovos_bus_client~=0.0, >=0.0.6
ovos-mark1-utils
ovos-mark1-utils~=0.0.0a2
1 change: 1 addition & 0 deletions test/test_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dialog:
- rule2
- rule3
- stardate
- santa

# regex entities, not necessarily filenames
regex:
Expand Down

0 comments on commit 0644bcd

Please sign in to comment.