aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-07-09 00:43:56 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-07-09 00:43:56 +0300
commit63521b8f90af65cad9ca7510be3c2b76307d8090 (patch)
tree441a0f1a2f9923078d26bd6d1662935c08d59f88 /telegram/utils.go
parent7ef32096af6017607f70a0b5aa2fbc03925c72d1 (diff)
Extended room disco info
Diffstat (limited to 'telegram/utils.go')
-rw-r--r--telegram/utils.go35
1 files changed, 32 insertions, 3 deletions
diff --git a/telegram/utils.go b/telegram/utils.go
index 5244803..377b784 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -1039,7 +1039,7 @@ func (c *Client) GetChatDescription(chat *client.Chat) string {
return fullInfo.Description
}
} else {
- log.Warnf("Coudln't retrieve private chat info: %v", err.Error())
+ log.Warnf("Couldn't retrieve private chat info: %v", err.Error())
}
} else if chatType == client.TypeChatTypeBasicGroup {
basicGroupType, _ := chat.Type.(*client.ChatTypeBasicGroup)
@@ -1049,7 +1049,7 @@ func (c *Client) GetChatDescription(chat *client.Chat) string {
if err == nil {
return fullInfo.Description
} else {
- log.Warnf("Coudln't retrieve basic group info: %v", err.Error())
+ log.Warnf("Couldn't retrieve basic group info: %v", err.Error())
}
} else if chatType == client.TypeChatTypeSupergroup {
supergroupType, _ := chat.Type.(*client.ChatTypeSupergroup)
@@ -1059,12 +1059,41 @@ func (c *Client) GetChatDescription(chat *client.Chat) string {
if err == nil {
return fullInfo.Description
} else {
- log.Warnf("Coudln't retrieve supergroup info: %v", err.Error())
+ log.Warnf("Couldn't retrieve supergroup info: %v", err.Error())
}
}
return ""
}
+// GetChatMemberCount obtains the member count depending on the chat type
+func (c *Client) GetChatMemberCount(chat *client.Chat) int32 {
+ chatType := chat.Type.ChatTypeType()
+ if chatType == client.TypeChatTypePrivate {
+ return 2
+ } else if chatType == client.TypeChatTypeBasicGroup {
+ basicGroupType, _ := chat.Type.(*client.ChatTypeBasicGroup)
+ basicGroup, err := c.client.GetBasicGroup(&client.GetBasicGroupRequest{
+ BasicGroupId: basicGroupType.BasicGroupId,
+ })
+ if err == nil {
+ return basicGroup.MemberCount
+ } else {
+ log.Warnf("Couldn't retrieve basic group: %v", err.Error())
+ }
+ } else if chatType == client.TypeChatTypeSupergroup {
+ supergroupType, _ := chat.Type.(*client.ChatTypeSupergroup)
+ supergroup, err := c.client.GetSupergroup(&client.GetSupergroupRequest{
+ SupergroupId: supergroupType.SupergroupId,
+ })
+ if err == nil {
+ return supergroup.MemberCount
+ } else {
+ log.Warnf("Couldn't retrieve supergroup: %v", err.Error())
+ }
+ }
+ return 0
+}
+
// GetGroupChats obtains all group chats
func (c *Client) GetGroupChats() []*client.Chat {
var groupChats []*client.Chat