mirror of
https://github.com/tiennm99/export-telegram-group-members.git
synced 2026-10-14 06:17:44 +00:00
feat(core): echo bot
This commit is contained in:
1 parent
382e4f7fbf
commit
0880189a13
1 file changed
+22
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user