@@ -34,8 +34,9 @@ const (
34
34
35
35
// Constant values for ParseMode in MessageConfig
36
36
const (
37
- ModeMarkdown = "Markdown"
38
- ModeHTML = "HTML"
37
+ ModeMarkdown = "Markdown"
38
+ ModeMarkdownV2 = "MarkdownV2"
39
+ ModeHTML = "HTML"
39
40
)
40
41
41
42
// Library errors
@@ -939,11 +940,8 @@ func (config KickChatMemberConfig) params() (Params, error) {
939
940
// RestrictChatMemberConfig contains fields to restrict members of chat
940
941
type RestrictChatMemberConfig struct {
941
942
ChatMemberConfig
942
- UntilDate int64
943
- CanSendMessages * bool
944
- CanSendMediaMessages * bool
945
- CanSendOtherMessages * bool
946
- CanAddWebPagePreviews * bool
943
+ UntilDate int64
944
+ Permissions * ChatPermissions
947
945
}
948
946
949
947
func (config RestrictChatMemberConfig ) method () string {
@@ -956,10 +954,9 @@ func (config RestrictChatMemberConfig) params() (Params, error) {
956
954
params .AddFirstValid ("chat_id" , config .ChatID , config .SuperGroupUsername , config .ChannelUsername )
957
955
params .AddNonZero ("user_id" , config .UserID )
958
956
959
- params .AddNonNilBool ("can_send_messages" , config .CanSendMessages )
960
- params .AddNonNilBool ("can_send_media_messages" , config .CanSendMediaMessages )
961
- params .AddNonNilBool ("can_send_other_messages" , config .CanSendOtherMessages )
962
- params .AddNonNilBool ("can_add_web_page_previews" , config .CanAddWebPagePreviews )
957
+ if err := params .AddInterface ("permissions" , config .Permissions ); err != nil {
958
+ return params , err
959
+ }
963
960
params .AddNonZero64 ("until_date" , config .UntilDate )
964
961
965
962
return params , nil
@@ -968,14 +965,14 @@ func (config RestrictChatMemberConfig) params() (Params, error) {
968
965
// PromoteChatMemberConfig contains fields to promote members of chat
969
966
type PromoteChatMemberConfig struct {
970
967
ChatMemberConfig
971
- CanChangeInfo * bool
972
- CanPostMessages * bool
973
- CanEditMessages * bool
974
- CanDeleteMessages * bool
975
- CanInviteUsers * bool
976
- CanRestrictMembers * bool
977
- CanPinMessages * bool
978
- CanPromoteMembers * bool
968
+ CanChangeInfo bool
969
+ CanPostMessages bool
970
+ CanEditMessages bool
971
+ CanDeleteMessages bool
972
+ CanInviteUsers bool
973
+ CanRestrictMembers bool
974
+ CanPinMessages bool
975
+ CanPromoteMembers bool
979
976
}
980
977
981
978
func (config PromoteChatMemberConfig ) method () string {
@@ -988,14 +985,35 @@ func (config PromoteChatMemberConfig) params() (Params, error) {
988
985
params .AddFirstValid ("chat_id" , config .ChatID , config .SuperGroupUsername , config .ChannelUsername )
989
986
params .AddNonZero ("user_id" , config .UserID )
990
987
991
- params .AddNonNilBool ("can_change_info" , config .CanChangeInfo )
992
- params .AddNonNilBool ("can_post_messages" , config .CanPostMessages )
993
- params .AddNonNilBool ("can_edit_messages" , config .CanEditMessages )
994
- params .AddNonNilBool ("can_delete_messages" , config .CanDeleteMessages )
995
- params .AddNonNilBool ("can_invite_users" , config .CanInviteUsers )
996
- params .AddNonNilBool ("can_restrict_members" , config .CanRestrictMembers )
997
- params .AddNonNilBool ("can_pin_messages" , config .CanPinMessages )
998
- params .AddNonNilBool ("can_promote_members" , config .CanPromoteMembers )
988
+ params .AddBool ("can_change_info" , config .CanChangeInfo )
989
+ params .AddBool ("can_post_messages" , config .CanPostMessages )
990
+ params .AddBool ("can_edit_messages" , config .CanEditMessages )
991
+ params .AddBool ("can_delete_messages" , config .CanDeleteMessages )
992
+ params .AddBool ("can_invite_users" , config .CanInviteUsers )
993
+ params .AddBool ("can_restrict_members" , config .CanRestrictMembers )
994
+ params .AddBool ("can_pin_messages" , config .CanPinMessages )
995
+ params .AddBool ("can_promote_members" , config .CanPromoteMembers )
996
+
997
+ return params , nil
998
+ }
999
+
1000
+ // SetChatAdministratorCustomTitle sets the title of an administrative user
1001
+ // promoted by the bot for a chat.
1002
+ type SetChatAdministratorCustomTitle struct {
1003
+ ChatMemberConfig
1004
+ CustomTitle string
1005
+ }
1006
+
1007
+ func (SetChatAdministratorCustomTitle ) method () string {
1008
+ return "setChatAdministratorCustomTitle"
1009
+ }
1010
+
1011
+ func (config SetChatAdministratorCustomTitle ) params () (Params , error ) {
1012
+ params := make (Params )
1013
+
1014
+ params .AddFirstValid ("chat_id" , config .ChatID , config .SuperGroupUsername , config .ChannelUsername )
1015
+ params .AddNonZero ("user_id" , config .UserID )
1016
+ params .AddNonEmpty ("custom_title" , config .CustomTitle )
999
1017
1000
1018
return params , nil
1001
1019
}
@@ -1041,6 +1059,27 @@ func (ChatAdministratorsConfig) method() string {
1041
1059
return "getChatAdministrators"
1042
1060
}
1043
1061
1062
+ // SetChatPermissionsConfig allows you to set default permissions for the
1063
+ // members in a group. The bot must be an administrator and have rights to
1064
+ // restrict members.
1065
+ type SetChatPermissionsConfig struct {
1066
+ ChatConfig
1067
+ Permissions * ChatPermissions
1068
+ }
1069
+
1070
+ func (SetChatPermissionsConfig ) method () string {
1071
+ return "setChatPermissions"
1072
+ }
1073
+
1074
+ func (config SetChatPermissionsConfig ) params () (Params , error ) {
1075
+ params := make (Params )
1076
+
1077
+ params .AddFirstValid ("chat_id" , config .ChatID , config .SuperGroupUsername )
1078
+ params .AddInterface ("permissions" , config .Permissions )
1079
+
1080
+ return params , nil
1081
+ }
1082
+
1044
1083
// ChatInviteLinkConfig contains information about getting a chat link.
1045
1084
//
1046
1085
// Note that generating a new link will revoke any previous links.
0 commit comments