Skip to main content

Lambda bot

Project description

Xavier is a bot framework. Specially built to operate on AWS Lambda.

Example

import os
import logging
import sys

from xavier.active import register_brain
from xavier.brain import Brain
from xavier.aws.func import build_lambda_router
from xavier.slack.slash import SlashCommandEvent
from xavier.http import Response, Router
from xavier.offline import BackgroundQueue
from xavier.aws.sns import publish_sns_message, handle_sns_message, handle_sns_schedule

xavier = Brain(env=env)
register_brain(xavier_bot)

background_queue = BackgroundQueue(publish_sns_message('arn:background_task'))
router = Router()

@background_queue.task()
def offline_find(slash_command):
    if slash_command.text == 'Hi':
        slash_command.respond({'text': "Howdy"})
        else:
                slash_command.respond({'text': "Hi"})


@router.add_route("/slack/commands/hello", methods=['POST'])
def handle_find(request):
    slash_command = SlashCommandEvent.from_request(request)
    offline_task.delay(slash_command)
    return Response(204, "")


@background_queue.task(schedule=['aaa'])
def offline_cron(slash_command):
        ...

lambda_schedule_hander = handle_sns_schedule(background_queue.process_schedule)
lambda_sns_handler = handle_sns_messages(background_queue.process_event)
lambda_http_handler = build_lambda_router(router)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xavier-0.0.10.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file xavier-0.0.10.tar.gz.

File metadata

  • Download URL: xavier-0.0.10.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xavier-0.0.10.tar.gz
Algorithm Hash digest
SHA256 8c13fe930b913f344c7f11e196ec8e127e019ba7991d4c225e4daa1a4bf508f4
MD5 e07b87c545c5950efbb5b12eabf2c05e
BLAKE2b-256 02b51a1f186059d832e781bab70d6a69f7586d3d570e9d4739c34d60302ed912

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page