This repository has been archived by the owner on Jul 3, 2022. It is now read-only.
forked from Arman92/go-tdlib
/
notificationSettingsScope.go
128 lines (103 loc) · 5.28 KB
/
notificationSettingsScope.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package tdlib
import (
"encoding/json"
"fmt"
)
// NotificationSettingsScope Describes the types of chats to which notification settings are relevant
type NotificationSettingsScope interface {
GetNotificationSettingsScopeEnum() NotificationSettingsScopeEnum
}
// NotificationSettingsScopeEnum Alias for abstract NotificationSettingsScope 'Sub-Classes', used as constant-enum here
type NotificationSettingsScopeEnum string
// NotificationSettingsScope enums
const (
NotificationSettingsScopePrivateChatsType NotificationSettingsScopeEnum = "notificationSettingsScopePrivateChats"
NotificationSettingsScopeGroupChatsType NotificationSettingsScopeEnum = "notificationSettingsScopeGroupChats"
NotificationSettingsScopeChannelChatsType NotificationSettingsScopeEnum = "notificationSettingsScopeChannelChats"
)
func unmarshalNotificationSettingsScope(rawMsg *json.RawMessage) (NotificationSettingsScope, error) {
if rawMsg == nil {
return nil, nil
}
var objMap map[string]interface{}
err := json.Unmarshal(*rawMsg, &objMap)
if err != nil {
return nil, err
}
switch NotificationSettingsScopeEnum(objMap["@type"].(string)) {
case NotificationSettingsScopePrivateChatsType:
var notificationSettingsScopePrivateChats NotificationSettingsScopePrivateChats
err := json.Unmarshal(*rawMsg, ¬ificationSettingsScopePrivateChats)
return ¬ificationSettingsScopePrivateChats, err
case NotificationSettingsScopeGroupChatsType:
var notificationSettingsScopeGroupChats NotificationSettingsScopeGroupChats
err := json.Unmarshal(*rawMsg, ¬ificationSettingsScopeGroupChats)
return ¬ificationSettingsScopeGroupChats, err
case NotificationSettingsScopeChannelChatsType:
var notificationSettingsScopeChannelChats NotificationSettingsScopeChannelChats
err := json.Unmarshal(*rawMsg, ¬ificationSettingsScopeChannelChats)
return ¬ificationSettingsScopeChannelChats, err
default:
return nil, fmt.Errorf("Error UnMarshaling, unknown type:" + objMap["@type"].(string))
}
}
// NotificationSettingsScopePrivateChats Notification settings applied to all private and secret chats when the corresponding chat setting has a default value
type NotificationSettingsScopePrivateChats struct {
tdCommon
}
// MessageType return the string telegram-type of NotificationSettingsScopePrivateChats
func (notificationSettingsScopePrivateChats *NotificationSettingsScopePrivateChats) MessageType() string {
return "notificationSettingsScopePrivateChats"
}
// NewNotificationSettingsScopePrivateChats creates a new NotificationSettingsScopePrivateChats
//
func NewNotificationSettingsScopePrivateChats() *NotificationSettingsScopePrivateChats {
notificationSettingsScopePrivateChatsTemp := NotificationSettingsScopePrivateChats{
tdCommon: tdCommon{Type: "notificationSettingsScopePrivateChats"},
}
return ¬ificationSettingsScopePrivateChatsTemp
}
// GetNotificationSettingsScopeEnum return the enum type of this object
func (notificationSettingsScopePrivateChats *NotificationSettingsScopePrivateChats) GetNotificationSettingsScopeEnum() NotificationSettingsScopeEnum {
return NotificationSettingsScopePrivateChatsType
}
// NotificationSettingsScopeGroupChats Notification settings applied to all basic groups and supergroups when the corresponding chat setting has a default value
type NotificationSettingsScopeGroupChats struct {
tdCommon
}
// MessageType return the string telegram-type of NotificationSettingsScopeGroupChats
func (notificationSettingsScopeGroupChats *NotificationSettingsScopeGroupChats) MessageType() string {
return "notificationSettingsScopeGroupChats"
}
// NewNotificationSettingsScopeGroupChats creates a new NotificationSettingsScopeGroupChats
//
func NewNotificationSettingsScopeGroupChats() *NotificationSettingsScopeGroupChats {
notificationSettingsScopeGroupChatsTemp := NotificationSettingsScopeGroupChats{
tdCommon: tdCommon{Type: "notificationSettingsScopeGroupChats"},
}
return ¬ificationSettingsScopeGroupChatsTemp
}
// GetNotificationSettingsScopeEnum return the enum type of this object
func (notificationSettingsScopeGroupChats *NotificationSettingsScopeGroupChats) GetNotificationSettingsScopeEnum() NotificationSettingsScopeEnum {
return NotificationSettingsScopeGroupChatsType
}
// NotificationSettingsScopeChannelChats Notification settings applied to all channels when the corresponding chat setting has a default value
type NotificationSettingsScopeChannelChats struct {
tdCommon
}
// MessageType return the string telegram-type of NotificationSettingsScopeChannelChats
func (notificationSettingsScopeChannelChats *NotificationSettingsScopeChannelChats) MessageType() string {
return "notificationSettingsScopeChannelChats"
}
// NewNotificationSettingsScopeChannelChats creates a new NotificationSettingsScopeChannelChats
//
func NewNotificationSettingsScopeChannelChats() *NotificationSettingsScopeChannelChats {
notificationSettingsScopeChannelChatsTemp := NotificationSettingsScopeChannelChats{
tdCommon: tdCommon{Type: "notificationSettingsScopeChannelChats"},
}
return ¬ificationSettingsScopeChannelChatsTemp
}
// GetNotificationSettingsScopeEnum return the enum type of this object
func (notificationSettingsScopeChannelChats *NotificationSettingsScopeChannelChats) GetNotificationSettingsScopeEnum() NotificationSettingsScopeEnum {
return NotificationSettingsScopeChannelChatsType
}