From 0880189a13519b4336cc493c0b2e96d50bad4bf1 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Thu, 11 Dec 2025 23:04:08 +0700 Subject: [PATCH] feat(core): echo bot --- main.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.go b/main.go index 8264dd8..932c384 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "log" "os" "strconv" + "strings" "github.com/celestix/gotgproto" "github.com/celestix/gotgproto/dispatcher/handlers" @@ -38,6 +39,22 @@ func main() { log.Fatal("APP_HASH not set") return } + groupIdsStr, isExist := os.LookupEnv("GROUP_IDS") + if !isExist { + log.Fatal("GROUP_IDS not set") + return + } + parts := strings.Split(groupIdsStr, ",") + groupIds := make([]int64, 0, len(parts)) + + for _, p := range parts { + v, err := strconv.ParseInt(strings.TrimSpace(p), 10, 64) + if err != nil { + log.Fatal(err) + return + } + groupIds = append(groupIds, v) + } client, err := gotgproto.NewClient( // Get AppID from https://my.telegram.org/apps @@ -57,6 +74,11 @@ func main() { fmt.Printf("client (@%s) has been started...\n", client.Self.Username) + ctx := client.CreateContext() + groupId := groupIds[0] + group, err := ctx.GetChat(groupId) + group.GetAbout() + clientDispatcher := client.Dispatcher clientDispatcher.AddHandlerToGroup(handlers.NewMessage(filters.Message.Text, echo), 1)