Run setup

This commit is contained in:
Hamcha 2022-03-24 13:24:20 +01:00
parent 7e68c8d665
commit 28219d663a
Signed by: hamcha
GPG key ID: 1669C533B8CF6D89
4 changed files with 37 additions and 5 deletions

20
README.md Normal file
View file

@ -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`

10
main.go
View file

@ -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))
log.Fatal(api.HandleWebhook(bind, os.Getenv("CLESSY_PATH"), func(update tg.APIUpdate) {
for _, mod := range toActivate {
mod.OnUpdate(update)
}
func webhook(update tg.APIUpdate) {
}))
}

5
run.ps1 Normal file
View file

@ -0,0 +1,5 @@
# Usage: setenv.ps1 <bot-token> <ngrok url>
$env:CLESSY_TOKEN = $args[0]
$env:CLESSY_WEBHOOK = $args[1] + "/test"
$env:CLESSY_PATH = "/test"
go run .

5
run.sh Normal file
View file

@ -0,0 +1,5 @@
# Usage: setenv.sh <bot-token> <ngrok url>
export CLESSY_TOKEN=$1
export CLESSY_WEBHOOK=$2/test
export CLESSY_PATH=/test
go run .