mirror of
https://github.com/tucnak/telebot
synced 2024-11-11 01:10:39 +00:00
.. | ||
deploy.sh | ||
go.mod | ||
go.sum | ||
init.sh | ||
main.go | ||
main.tf | ||
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:
-
It is configured with
Settings.Synchronous = true
. This disables asynchronous handlers to let Lambda wait for their completion:b, _ := tele.NewBot(tele.Settings{Token: token, Synchronous: true})
-
Instead of
Settings.Poller
andbot.Start
it callsbot.ProcessUpdate
insidelambda.Start
:lambda.Start(func(req events.APIGatewayProxyRequest) (err error) { var u tele.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
.