From 28219d663a1a21b5faef145c30188c3f90439ed8 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Thu, 24 Mar 2022 13:24:20 +0100 Subject: [PATCH] Run setup --- README.md | 20 ++++++++++++++++++++ main.go | 12 +++++++----- run.ps1 | 5 +++++ run.sh | 5 +++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 README.md create mode 100644 run.ps1 create mode 100644 run.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..0380c78 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# Maudbot rewrite + +## Development setup + +You will need: + +- A healthy fear of the end +- ngrok + +Run `ngrok http 8080` to get an HTTP address for port 8080. + +Then, run `run.sh` or `run.ps1` specifying the bot token and ngrok base HTTPS address, eg. + +```sh +./run.sh 12345:AEEA311_EU https://abcd-12-23-43-112.ngrok.io +``` + +## Deployment + +Build and deploy the docker container using the provided `Dockerfile` diff --git a/main.go b/main.go index cd587a9..6f04c02 100644 --- a/main.go +++ b/main.go @@ -47,6 +47,8 @@ func main() { for _, modname := range strings.Split(*enable, ",") { toActivate[modname] = mods[modname] } + } else { + toActivate = mods } for modname, mod := range toActivate { @@ -56,9 +58,9 @@ func main() { } api.SetWebhook(os.Getenv("CLESSY_WEBHOOK")) - log.Fatal(api.HandleWebhook(bind, os.Getenv("CLESSY_PATH"), webhook)) -} - -func webhook(update tg.APIUpdate) { - + log.Fatal(api.HandleWebhook(bind, os.Getenv("CLESSY_PATH"), func(update tg.APIUpdate) { + for _, mod := range toActivate { + mod.OnUpdate(update) + } + })) } diff --git a/run.ps1 b/run.ps1 new file mode 100644 index 0000000..87ced3f --- /dev/null +++ b/run.ps1 @@ -0,0 +1,5 @@ +# Usage: setenv.ps1 +$env:CLESSY_TOKEN = $args[0] +$env:CLESSY_WEBHOOK = $args[1] + "/test" +$env:CLESSY_PATH = "/test" +go run . \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..6d2bddd --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ +# Usage: setenv.sh +export CLESSY_TOKEN=$1 +export CLESSY_WEBHOOK=$2/test +export CLESSY_PATH=/test +go run . \ No newline at end of file