示例#1
0
def message_actions():

    # Parse the request payload
    form_json = json.loads(request.form["payload"])

    # Check to see what the user's selection was and update the message accordingly
    # app.logger.info(form_json)
    user_id = form_json.get('user').get('id')
    channel = form_json.get('channel').get('id')
    value = form_json.get('actions')[0].get('selected_option').get('value')
    ts = form_json.get('actions')[0].get('action_ts')[0:10]

    user = User.query.get(user_id)
    poopable = Poopable.query.get(int(value))
    app.logger.info(value)
    app.logger.info(int(value))
    app.logger.info(user)
    app.logger.info(poopable)

    user.prefered_poopables.append(poopable)
    db.session.add(poopable)
    db.session.add(user)
    db.session.commit()

    subscriptions[channel] = {"start_time": ts, "user_id": user_id}
    onboarding_tutorial = OnboardingTutorial(channel)

    message = onboarding_tutorial.get_successfully_subscribe_message_payload()

    response = slack_web_client.chat_postMessage(**message)
    push_poopable_status(channel, get_poopable(int(value)))

    return "", 200
def start_onboarding(user_id: str, user_name: str, real_name: str,
                     channel: str):
    onboarding_tutorial = OnboardingTutorial(user_id, user_name, real_name,
                                             channel)
    message = onboarding_tutorial.get_message_payload()
    response = slack_web_client.chat_postMessage(**message)
    onboarding_tutorial.timestamp = response['ts']
    hyeonMsgSentItem = getDynamo_hyeonMsgSentItem(channel,
                                                  dynamodbTb_hyeonmsgsent)
    if not hyeonMsgSentItem or channel not in hyeonMsgSentItem['channel']:
        putDynamo_hyeonOperation(channel,
                                 user_id=user_id,
                                 payload=onboarding_tutorial)
示例#3
0
def start_onboarding(user_id: str, channel: str):
    # Create a new onboarding tutorial.
    onboarding_tutorial = OnboardingTutorial(channel)
    # Get the onboarding message payload
    message = onboarding_tutorial.get_message_payload()
    # Post the onboarding message in Slack
    response = slack_web_client.chat_postMessage(**message)
    # Capture the timestamp of the message we've just posted so
    # we can use it to update the message after a user
    # has completed an onboarding task.
    onboarding_tutorial.timestamp = response["ts"]
    # Store the message sent in onboarding_tutorials_sent
    if channel not in onboarding_tutorials_sent:
	    onboarding_tutorials_sent[channel] = {}
	    onboarding_tutorials_sent[channel][user_id] = onboarding_tutorial
示例#4
0
def start_onboarding(user_id: str, channel_id: str):

    # create user and give a default poopable
    exists = db.session.query(
        db.exists().where(User.slack_user_id == user_id)).scalar()
    if not exists:
        user = User(slack_user_id=user_id)
        db.session.add(user)
        db.session.commit()

    # create on boarding tutorial and sent it to user
    onboarding_tutorial = OnboardingTutorial(channel_id)

    message = onboarding_tutorial.get_message_payload()

    response = slack_web_client.chat_postMessage(**message)
示例#5
0
def start_onboarding(user_id: str, channel: str):
    # Create a new onboarding tutorial.
    onboarding_tutorial = OnboardingTutorial(channel)

    # Get the onboarding message payload
    message = onboarding_tutorial.get_message_payload()

    # Post the onboarding message in Slack
    response = slack_web_client.chat_postMessage(**message)

    # Update the timestamp
    onboarding_tutorial.timestamp = response["ts"]

    # Store the message sent in onboarding_tutorials_sent
    if channel not in onboarding_tutorials_sent:
        onboarding_tutorials_sent[channel] = {}
    onboarding_tutorials_sent[channel][user_id] = onboarding_tutorial
示例#6
0
async def start_onboarding(web_client: slack.WebClient, user_id: str, channel: str):
    # Create a new onboarding tutorial.
    onboarding_tutorial = OnboardingTutorial(channel)

    # Get the onboarding message payload
    message = onboarding_tutorial.get_message_payload()

    # Post the onboarding message in Slack
    response = await web_client.chat_postMessage(**message)

    # Capture the timestamp of the message we've just posted so
    # we can use it to update the message after a user
    # has completed an onboarding task.
    onboarding_tutorial.timestamp = response["ts"]

    # Store the message sent in onboarding_tutorials_sent
    if channel not in onboarding_tutorials_sent:
        onboarding_tutorials_sent[channel] = {}
    onboarding_tutorials_sent[channel][user_id] = onboarding_tutorial
示例#7
0
    def start_onboardings(user_id: str, channel: str):

        onboarding_tutorial = OnboardingTutorial(channel)

        message = {
            'channel':
            "C018BA3SERK",
            'blocks': [{
                'type': 'section',
                'text': {
                    'type': 'mrkdwn',
                    'text':
                    f'@here\na new channel: #{channel_name} was created!'
                }
            }]
        }
        response = slack_web_client.chat_postMessage(**message)

        onboarding_tutorial.timestamp = response["ts"]

        if channel not in onboarding_tutorials_sent:
            onboarding_tutorials_sent[channel] = {}
        onboarding_tutorials_sent[channel][user_id] = onboarding_tutorial