diff --git a/config.go b/config.go index 52f8018..70d8d39 100644 --- a/config.go +++ b/config.go @@ -62,7 +62,5 @@ func loadConfig() (*Config, error) { fl.Close() } - println(cfg.Activity.Type, cfg.Activity.Name) - return cfg, env.ParseWithOptions(cfg, env.Options{Prefix: "OWOBOT_"}) } diff --git a/internal/systems/about/about.go b/internal/systems/about/about.go index 14a5ca7..ddc167d 100644 --- a/internal/systems/about/about.go +++ b/internal/systems/about/about.go @@ -2,6 +2,7 @@ package about import ( "fmt" + "runtime/debug" "time" "github.com/bwmarrin/discordgo" @@ -12,6 +13,9 @@ const aboutTmpl = `**Copyright © %d owobot contributors** This program comes with **ABSOLUTELY NO WARRANTY**. This is free software, and you are welcome to redistribute it under certain conditions. See [here](https://www.gnu.org/licenses/agpl-3.0.html) for details. +**Running Commit:** +%s + **Source Code:** https://gitea.elara.ws/owobot/owobot **GitHub Mirror:** @@ -31,9 +35,32 @@ func aboutCmd(s *discordgo.Session, i *discordgo.InteractionCreate) error { Data: &discordgo.InteractionResponseData{ Flags: discordgo.MessageFlagsEphemeral, Embeds: []*discordgo.MessageEmbed{{ - Title: "About owobot", - Description: fmt.Sprintf(aboutTmpl, time.Now().Year()), + Title: "About owobot", + Description: fmt.Sprintf( + aboutTmpl, + time.Now().Year(), + getCommit(), + ), }}, }, }) } + +func getCommit() string { + info, ok := debug.ReadBuildInfo() + if !ok { + return "``" + } + var commit = "``" + for _, setting := range info.Settings { + switch setting.Key { + case "vcs.revision": + commit = "`" + setting.Value + "`" + case "vcs.modified": + if setting.Value == "true" { + commit += " (dirty)" + } + } + } + return commit +}