Пример #1
0
# Private Imports
# -----------------------------------------------------------------------------

from commands.demo.cli import slash_demo, demo_cmds

# -----------------------------------------------------------------------------
#
#                                 CODE BEGINS
#
# -----------------------------------------------------------------------------

# define the CLI command "/demo blocks"

cmd = demo_cmds.add_parser(
    'block',
    help='Run the block test example',
    description='Block test'
)


# bind the entrypoint handler for when the User enters the complete "/demo
# block" command in the Slack client.

@slash_demo.cli.on(cmd.prog)
def slash_main(rqst: CommandRequest):
    return main(rqst)


# bind the entrypoint handler for when the User selects this demo item from the
# /demo menu-selector
from commands.demo.cli import demo_cmds, slash_demo

# -----------------------------------------------------------------------------
#
#                                 CODE BEGINS
#
# -----------------------------------------------------------------------------

ASYNC_SLEEP_TIME_SEC = 5
MAX_SLEEP_TIME_SEC = 20

# define the CLI parser for the command "/demo async-modal"

cmd = demo_cmds.add_parser('async-modal',
                           help='Run the async update modal test example',
                           description='Async Update Modal')


class DelayArgument(argparse.Action):
    def __call__(self, parser, namespace, values, option_string=None):
        # optional value
        if not values:
            return

        delay = int(values)
        if not (1 <= delay <= MAX_SLEEP_TIME_SEC):
            parser.error(
                f"{self.dest} must be between 1 and {MAX_SLEEP_TIME_SEC}.")

        setattr(namespace, self.dest, delay)
Пример #3
0
# Private Imports
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
#
#                                 CODE BEGINS
#
# -----------------------------------------------------------------------------


# create a Argsparser for the "/demo modal" command

cmd = demo_cmds.add_parser(
    'modal',
    help='Run the Modal test example',
    description='Modal Test'
)


# The user session key will be the program name of the parser, i.e. "demo
# modal" but demonstrating this use programatically.  The User interactions
# will be stored in the sessions in 'params'.

SESSION_KEY = cmd.prog


def session_init():
    # discard previous if exists
    session.pop(SESSION_KEY, None)
    session[SESSION_KEY] = dict()
# -----------------------------------------------------------------------------
# Private Imports
# -----------------------------------------------------------------------------

from commands.demo.cli import demo_cmds, slash_demo

# -----------------------------------------------------------------------------
#
#                                 CODE BEGINS
#
# -----------------------------------------------------------------------------

# create an Argsparser for the "/demo update-modal" command.

cmd = demo_cmds.add_parser('update-modal',
                           help='Run the update modal test example',
                           description='Update Modal')

# bind the entrypoint handler for when the User enters the complete "/demo
# update-modal" command in the Slack client.


@slash_demo.cli.on(cmd.prog)
def slash_main(rqst: CommandRequest):
    return main(rqst)


# bind the entrypoint handler for when the User selects this demo item from the
# /demo menu-selector