add info command
This commit is contained in:
parent
18a3295e50
commit
ecd25cf553
2 changed files with 27 additions and 1 deletions
2
build.sh
2
build.sh
|
@ -1,4 +1,4 @@
|
||||||
###!/usr/bin/env bash
|
###!/usr/bin/env bash
|
||||||
|
|
||||||
HASH=$(git log -1 --pretty=%h)
|
HASH=$(git log -1 --pretty=%h)
|
||||||
docker build -t bloaterbot:latest -t bloaterbot:$HASH .
|
docker build -t bloaterbot:latest -t bloaterbot:$HASH --build-arg=COMMIT=$(git log -1 --pretty=%h) .
|
|
@ -3,6 +3,7 @@ package commands
|
||||||
import (
|
import (
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -31,6 +32,8 @@ func Commands(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
notify.Reminder(update, bot)
|
notify.Reminder(update, bot)
|
||||||
case "help":
|
case "help":
|
||||||
help(update, bot)
|
help(update, bot)
|
||||||
|
case "info":
|
||||||
|
info(update, bot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,3 +65,26 @@ func help(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
botIO.SendMessage(message, bot)
|
botIO.SendMessage(message, bot)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func info(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
|
me, _ := bot.GetMe()
|
||||||
|
commit := os.Getenv("COMMIT")
|
||||||
|
if commit == "" {
|
||||||
|
commit = "not available"
|
||||||
|
}
|
||||||
|
info, _ := os.Stat("./bloater.db")
|
||||||
|
dbSizeInKiloBytes := info.Size() / 1000
|
||||||
|
|
||||||
|
textInfo := "<b>" + me.FirstName + "</b>" + "\n\n" +
|
||||||
|
"<b>Commit:</b> " + "<code>" + commit + "</code>" + "\n" +
|
||||||
|
"<b>DB Size:</b> " + "<code>" + strconv.FormatInt(dbSizeInKiloBytes, 10) + "KB" + "</code>"
|
||||||
|
|
||||||
|
message := tgbotapi.MessageConfig{
|
||||||
|
BaseChat: tgbotapi.BaseChat{ChatID: update.Message.Chat.ID, ReplyToMessageID: update.Message.MessageID},
|
||||||
|
ParseMode: "html",
|
||||||
|
DisableWebPagePreview: false,
|
||||||
|
Text: textInfo,
|
||||||
|
}
|
||||||
|
botIO.SendMessage(message, bot)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue