You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
telebot/examples/awslambdaechobot
Demian 1a9d4b1333 mod: tidy 4 years ago
..
README.md examples: add awslambdaechobot 4 years ago
deploy.sh examples: add awslambdaechobot 4 years ago
go.mod mod: tidy 4 years ago
go.sum mod: tidy 4 years ago
init.sh examples: add awslambdaechobot 4 years ago
main.go examples: add awslambdaechobot 4 years ago
main.tf examples: add awslambdaechobot 4 years ago

README.md

This example shows how to write an echo telebot for AWS Lambda and how to launch it using Terraform.

This bot is different from a typical bot in two ways:

  1. It is configured with Settings.Synchronous = true. This disables asynchronous handlers to let Lambda wait for their completion:

    b, _ := tb.NewBot(tb.Settings{Token: token, Synchronous: true})
    
  2. Instead of Settings.Poller and bot.Start it calls bot.ProcessUpdate inside lambda.Start:

    lambda.Start(func(req events.APIGatewayProxyRequest) (err error) {
        var u tb.Update
        if err = json.Unmarshal([]byte(req.Body), &u); err == nil {
            b.ProcessUpdate(u)
        }
        return
    })
    

To launch the bot install Terraform, run ./init.sh and then ./deploy.sh. To tear down the cloud infrastructure run terraform destroy.