Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
DEADSEC-SECURITY committed Feb 21, 2024
1 parent 03a93e7 commit 07ec2fa
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions lambda/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# SET TO FALSE IF YOU DO NOT WANT TO SHARE CRASH REPORTS AND SKILL PERFORMANCE DATA WITH US.
# We really appreciate if you keep this True as we use this to help us identify bugs and fix them.
# Check sentry.io to see what information is collected
ALLOW_ANONYMOUS_DATA_COLLECTION = True
ALLOW_ANONYMOUS_DATA_COLLECTION = True

""" NO NEED TO EDIT ANYTHING UNDER THE LINE """
# Built-In Imports
Expand Down Expand Up @@ -61,17 +61,12 @@
if ALLOW_ANONYMOUS_DATA_COLLECTION:
sentry_sdk.init(
dsn="https://5f56ef84a1063487a1b1c27f5b6f8391@o4506077312385024.ingest.sentry.io/4506077313630208",
integrations=[
AwsLambdaIntegration(),
LoggingIntegration(
level=logging.INFO,
event_level=logging.ERROR
)
],
integrations=[AwsLambdaIntegration(), LoggingIntegration(level=logging.INFO, event_level=logging.ERROR)],
traces_sample_rate=0.1,
profiles_sample_rate=0.1,
)


def _handle_response(handler, speak_out: Optional[str]):
"""
This function has the purpose of allowing the suspension of the default Okay response
Expand Down Expand Up @@ -484,7 +479,7 @@ def iso8601_duration_to_seconds(duration) -> int:
@return:
"""
# Check if the string starts with 'P'
if duration[0] != 'P':
if duration[0] != "P":
raise ValueError("Invalid ISO-8601 duration format")

duration = duration[1:] # Remove the 'P' prefix
Expand All @@ -496,35 +491,31 @@ def iso8601_duration_to_seconds(duration) -> int:
seconds = 0

# Split the duration string by 'T' if it's present
if 'T' in duration:
date_part, time_part = duration.split('T')
if "T" in duration:
date_part, time_part = duration.split("T")
else:
date_part = duration
time_part = ''
time_part = ""

# Parse the date part
if 'D' in date_part:
days = int(date_part.split('D')[0])
if "D" in date_part:
days = int(date_part.split("D")[0])

# Parse the time part
if time_part:
if 'H' in time_part:
hours = int(time_part.split('H')[0])
if 'M' in time_part:
minutes = int(time_part.split('M')[0])
if 'S' in time_part:
seconds = float(time_part.split('S')[0])
if "H" in time_part:
hours = int(time_part.split("H")[0])
if "M" in time_part:
minutes = int(time_part.split("M")[0])
if "S" in time_part:
seconds = float(time_part.split("S")[0])

# Calculate the total duration in seconds
total_seconds = (
days * 24 * 60 * 60 +
hours * 60 * 60 +
minutes * 60 +
seconds
)
total_seconds = days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds

return total_seconds


class DateTimeIntentHandler(AbstractRequestHandler):
"""Handler for Date Time Intent."""

Expand Down

0 comments on commit 07ec2fa

Please sign in to comment.