forked from shelomentsevd/mtproto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contacts.go
71 lines (63 loc) · 1.67 KB
/
contacts.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
66
67
68
69
70
71
package mtproto
import "errors"
func (m *MTProto) ContactsGetContacts(hash string) (*TL, error) {
return m.InvokeSync(TL_contacts_getContacts{
Hash: hash,
})
}
func (m *MTProto) ContactsGetTopPeers(correspondents, botsPM, botsInline, groups, channels bool, offset, limit, hash int32) (*TL, error) {
tl, err := m.InvokeSync(TL_contacts_getTopPeers{
Correspondents: correspondents,
Bots_pm: botsPM,
Bots_inline: botsInline,
Groups: groups,
Channels: channels,
Offset: offset,
Limit: limit,
Hash: hash,
})
if err != nil {
return nil, err
}
switch (*tl).(type) {
case TL_contacts_topPeersNotModified:
case TL_contacts_topPeers:
default:
return nil, errors.New("MTProto::ContactsGetTopPeers error: Unknown type")
}
return tl, nil
}
func (m *MTProto) AddContactsByPhone(phoneNumbers []string) (*TL, error){
contacts := make([]TL,0)
for _,phone := range phoneNumbers{
contacts = append(contacts,TL_inputPhoneContact{
Phone:phone,
})
}
return m.InvokeSync(TL_contacts_importContacts{
Contacts:contacts,
Replace:TL_boolTrue{},
})
}
func (m *MTProto) AddContactsByPhones(phoneNumbers []string) (*TL, error){
contacts := make([]TL,0)
for p := range phoneNumbers {
contacts = append(contacts, TL_inputPhoneContact{
Phone: phoneNumbers[p],
})
}
return m.InvokeSync(TL_contacts_importContacts{
Contacts:contacts,
Replace:TL_boolTrue{},
})
}
func (m *MTProto) AddContacts(cont []TL_inputPhoneContact) (*TL, error){
contacts := make([]TL,0)
for _, c := range cont {
contacts = append(contacts, c)
}
return m.InvokeSync(TL_contacts_importContacts{
Contacts:contacts,
Replace:TL_boolTrue{},
})
}