From 6abb7ff9c238f0343351c15c09210d746086f5f6 Mon Sep 17 00:00:00 2001
From: Bohdan Horbeshko <bodqhrohro@gmail.com>
Date: Thu, 7 Jul 2022 20:38:06 -0400
Subject: Respond to disco with conference identity and groups list

---
 telegram/utils.go | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

(limited to 'telegram')

diff --git a/telegram/utils.go b/telegram/utils.go
index 17e9861..7747acb 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -1065,6 +1065,30 @@ func (c *Client) GetChatDescription(chat *client.Chat) string {
 	return ""
 }
 
+// GetGroupChats obtains all group chats
+func (c *Client) GetGroupChats() []*client.Chat {
+	var groupChats []*client.Chat
+
+	chats, err := c.client.GetChats(&client.GetChatsRequest{
+		Limit: chatsLimit,
+	})
+	if err == nil {
+		for _, id := range chats.ChatIds {
+			chat, _, _ := c.GetContactByID(id, nil)
+			if chat != nil {
+				typ := chat.Type.ChatTypeType()
+				if typ == client.TypeChatTypeBasicGroup {
+					groupChats = append(groupChats, chat)
+				}
+			}
+		}
+	} else {
+		log.Errorf("Could not retrieve chats: %v", err)
+	}
+
+	return groupChats
+}
+
 // subscribe to a Telegram ID
 func (c *Client) subscribeToID(id int64, chat *client.Chat) {
 	var args []args.V
-- 
cgit v1.2.3