Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions Return Types #23

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pritunl_slack_app/function/pritunl_slack_app/pritunl_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@

@app.middleware
def log_request(logger, body, next):
"""Log incoming requests"""
logger.debug(body)
return next()


def validate_command(body):
def validate_command(body: dict) -> bool:
"""Validate incoming command"""
command_args = body.get("text")
if command_args is None or len(command_args) == 0:
return False
Expand All @@ -52,7 +54,8 @@ def validate_command(body):
return False


def initial_acknowledgement(body, ack):
def initial_acknowledgement(body: dict, ack):
"""Send initial acknowledgement response"""
def command_usage():
return str(f"*:book: Usage:* `{body['command']} profile-key [ORGANIZATION]`")

Expand All @@ -61,8 +64,8 @@ def command_accepted():

ack(command_accepted() if validate_command(body) else command_usage())


def processing_request(respond, body):
def processing_request(respond, body: dict):
"""Process incoming request"""
if validate_command(body):
respond(f"Hi <@{body['user_id']}>, please kindly wait while we process your request.")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pritunl-slack-app"
version = "0.1.9"
version = "0.1.10"
description = "Pritunl Slack App Slash Commands"
authors = ["Nathaniel Varona <nathaniel.varona+pypi@gmail.com>"]
license = "MIT"
Expand Down
Loading