This repository has been archived by the owner on Jul 3, 2022. It is now read-only.
forked from Arman92/go-tdlib
/
basicGroupFullInfo.go
65 lines (56 loc) · 2.69 KB
/
basicGroupFullInfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package tdlib
import (
"encoding/json"
"fmt"
)
// BasicGroupFullInfo Contains full information about a basic group
type BasicGroupFullInfo struct {
tdCommon
Photo *ChatPhoto `json:"photo"` // Chat photo; may be null
Description string `json:"description"` // Group description. Updated only after the basic group is opened
CreatorUserId int64 `json:"creator_user_id"` // User identifier of the creator of the group; 0 if unknown
Members []ChatMember `json:"members"` // Group members
InviteLink *ChatInviteLink `json:"invite_link"` // Primary invite link for this group; may be null. For chat administrators with can_invite_users right only. Updated only after the basic group is opened
BotCommands []BotCommands `json:"bot_commands"` // List of commands of bots in the group
}
// MessageType return the string telegram-type of BasicGroupFullInfo
func (basicGroupFullInfo *BasicGroupFullInfo) MessageType() string {
return "basicGroupFullInfo"
}
// NewBasicGroupFullInfo creates a new BasicGroupFullInfo
//
// @param photo Chat photo; may be null
// @param description Group description. Updated only after the basic group is opened
// @param creatorUserId User identifier of the creator of the group; 0 if unknown
// @param members Group members
// @param inviteLink Primary invite link for this group; may be null. For chat administrators with can_invite_users right only. Updated only after the basic group is opened
// @param botCommands List of commands of bots in the group
func NewBasicGroupFullInfo(photo *ChatPhoto, description string, creatorUserId int64, members []ChatMember, inviteLink *ChatInviteLink, botCommands []BotCommands) *BasicGroupFullInfo {
basicGroupFullInfoTemp := BasicGroupFullInfo{
tdCommon: tdCommon{Type: "basicGroupFullInfo"},
Photo: photo,
Description: description,
CreatorUserId: creatorUserId,
Members: members,
InviteLink: inviteLink,
BotCommands: botCommands,
}
return &basicGroupFullInfoTemp
}
// GetBasicGroupFullInfo Returns full information about a basic group by its identifier
// @param basicGroupId Basic group identifier
func (client *Client) GetBasicGroupFullInfo(basicGroupId int64) (*BasicGroupFullInfo, error) {
result, err := client.SendAndCatch(UpdateData{
"@type": "getBasicGroupFullInfo",
"basic_group_id": basicGroupId,
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, fmt.Errorf("error! code: %v msg: %s", result.Data["code"], result.Data["message"])
}
var basicGroupFullInfo BasicGroupFullInfo
err = json.Unmarshal(result.Raw, &basicGroupFullInfo)
return &basicGroupFullInfo, err
}