Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get supergroup_id in *tdlib.Chat #49

Open
Lifelong-Study opened this issue Oct 14, 2020 · 1 comment
Open

How to get supergroup_id in *tdlib.Chat #49

Lifelong-Study opened this issue Oct 14, 2020 · 1 comment

Comments

@Lifelong-Study
Copy link

Hello guys, I want get supergroup info, but I don't know how to get the supergroup_id form *tdlib.Chat

My develop language is: Golang

@Lifelong-Study
Copy link
Author

Lifelong-Study commented Oct 14, 2020

share how to get supergroup_id

import "github.com/fatih/structs"

// Code
chat, err := client.GetChat(chatID)
if err != nil {
	panic(err)
}

if chat.Type.GetChatTypeEnum() == tdlib.ChatTypeSupergroupType {

	Map 		 := structs.Map(chat)
	Type 		 := Map["Type"].(map[string]interface {})
	SupergroupID	 := Type["SupergroupID"].(int32)
	IsChannel 	 := Type["IsChannel"].(bool)

	log.Printf("%s: %v, %d", chat.Title, IsChannel, SupergroupID)

	group, err := client.GetSupergroup(SupergroupID)
	if err != nil {
		panic(err)
	}

	log.Print(group.Username)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant