👽 Added Bot API 4.4 changes
This commit is contained in:
parent
b9272596e9
commit
f898f5f5a0
1
const.go
1
const.go
|
@ -106,6 +106,7 @@ const (
|
||||||
MethodSendVideoNote = "sendVideoNote"
|
MethodSendVideoNote = "sendVideoNote"
|
||||||
MethodSendVoice = "sendVoice"
|
MethodSendVoice = "sendVoice"
|
||||||
MethodSetChatDescription = "setChatDescription"
|
MethodSetChatDescription = "setChatDescription"
|
||||||
|
MethodSetChatPermissions = "setChatPermissions"
|
||||||
MethodSetChatPhoto = "setChatPhoto"
|
MethodSetChatPhoto = "setChatPhoto"
|
||||||
MethodSetChatStickerSet = "setChatStickerSet"
|
MethodSetChatStickerSet = "setChatStickerSet"
|
||||||
MethodSetChatTitle = "setChatTitle"
|
MethodSetChatTitle = "setChatTitle"
|
||||||
|
|
35
restrict.go
Normal file
35
restrict.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package telegram
|
||||||
|
|
||||||
|
type RestrictChatMemberParameters struct {
|
||||||
|
// Unique identifier for the target chat
|
||||||
|
ChatID int64 `json:"chat_id"`
|
||||||
|
|
||||||
|
// Unique identifier of the target user
|
||||||
|
UserID int `json:"user_id"`
|
||||||
|
|
||||||
|
// New user permissions
|
||||||
|
Permissions ChatPermissions `json:"permissions"`
|
||||||
|
|
||||||
|
// Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days
|
||||||
|
// or less than 30 seconds from the current time, they are considered to be restricted forever
|
||||||
|
UntilDate int64 `json:"until_date,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have
|
||||||
|
// the appropriate admin rights. Pass True for all permissions to lift restrictions from a user. Returns True on
|
||||||
|
// success.
|
||||||
|
func (b *Bot) RestrictChatMember(params RestrictChatMemberParameters) (bool, error) {
|
||||||
|
dst, err := parser.Marshal(¶ms)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := b.request(dst, MethodRestrictChatMember)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var ok bool
|
||||||
|
err = parser.Unmarshal(resp.Result, &ok)
|
||||||
|
return ok, err
|
||||||
|
}
|
27
set.go
27
set.go
|
@ -119,6 +119,15 @@ type (
|
||||||
// New sticker position in the set, zero-based
|
// New sticker position in the set, zero-based
|
||||||
Position int `json:"position"`
|
Position int `json:"position"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetChatPermissionsParameters represents data for SetChatPermissions method.
|
||||||
|
SetChatPermissionsParameters struct {
|
||||||
|
// Unique identifier for the target chat
|
||||||
|
ChatID int64 `json:"chat_id"`
|
||||||
|
|
||||||
|
// New default chat permissions
|
||||||
|
Permissions ChatPermissions `json:"permissions"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewWebhook creates new SetWebhookParameters only with required parameters.
|
// NewWebhook creates new SetWebhookParameters only with required parameters.
|
||||||
|
@ -341,3 +350,21 @@ func (b *Bot) SetStickerPositionInSet(sticker string, position int) (bool, error
|
||||||
err = parser.Unmarshal(resp.Result, &ok)
|
err = parser.Unmarshal(resp.Result, &ok)
|
||||||
return ok, err
|
return ok, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetChatPermissions set default chat permissions for all members. The bot must be an administrator in the group or a
|
||||||
|
// supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success.
|
||||||
|
func (b *Bot) SetChatPermissions(params SetChatPermissionsParameters) (bool, error) {
|
||||||
|
dst, err := parser.Marshal(¶ms)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := b.request(dst, MethodSetChatPermissions)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var ok bool
|
||||||
|
err = parser.Unmarshal(resp.Result, &ok)
|
||||||
|
return ok, err
|
||||||
|
}
|
||||||
|
|
96
types.go
96
types.go
|
@ -116,14 +116,10 @@ type (
|
||||||
// Last name of the other party in a private chat
|
// Last name of the other party in a private chat
|
||||||
LastName string `json:"last_name,omitempty"`
|
LastName string `json:"last_name,omitempty"`
|
||||||
|
|
||||||
// True if a group has ‘All Members Are Admins’ enabled.
|
|
||||||
AllMembersAreAdministrators bool `json:"all_members_are_administrators,omitempty"`
|
|
||||||
|
|
||||||
// Chat photo. Returned only in getChat.
|
// Chat photo. Returned only in getChat.
|
||||||
Photo *ChatPhoto `json:"photo,omitempty"`
|
Photo *ChatPhoto `json:"photo,omitempty"`
|
||||||
|
|
||||||
// Description, for supergroups and channel chats. Returned only in
|
// Description, for groups, supergroups and channel chats. Returned only in getChat.
|
||||||
// getChat.
|
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
|
|
||||||
// Chat invite link, for supergroups and channel chats. Returned only in
|
// Chat invite link, for supergroups and channel chats. Returned only in
|
||||||
|
@ -133,6 +129,9 @@ type (
|
||||||
// Pinned message, for groups, supergroups and channels. Returned only in getChat.
|
// Pinned message, for groups, supergroups and channels. Returned only in getChat.
|
||||||
PinnedMessage *Message `json:"pinned_message,omitempty"`
|
PinnedMessage *Message `json:"pinned_message,omitempty"`
|
||||||
|
|
||||||
|
// Default chat member permissions, for groups and supergroups. Returned only in getChat.
|
||||||
|
Permissions *ChatPermissions `json:"permissions,omitempty"`
|
||||||
|
|
||||||
// For supergroups, name of Group sticker set. Returned only in getChat.
|
// For supergroups, name of Group sticker set. Returned only in getChat.
|
||||||
StickerSetName string `json:"sticker_set_name,omitempty"`
|
StickerSetName string `json:"sticker_set_name,omitempty"`
|
||||||
|
|
||||||
|
@ -763,11 +762,13 @@ type (
|
||||||
// ChatPhoto represents a chat photo.
|
// ChatPhoto represents a chat photo.
|
||||||
ChatPhoto struct {
|
ChatPhoto struct {
|
||||||
// Unique file identifier of small (160x160) chat photo. This file_id can
|
// Unique file identifier of small (160x160) chat photo. This file_id can
|
||||||
// be used only for photo download.
|
// be used only for photo download. This file_id can be used only for photo download and only for as
|
||||||
|
// long as the photo is not changed.
|
||||||
SmallFileID string `json:"small_file_id"`
|
SmallFileID string `json:"small_file_id"`
|
||||||
|
|
||||||
// Unique file identifier of big (640x640) chat photo. This file_id can
|
// Unique file identifier of big (640x640) chat photo. This file_id can
|
||||||
// be used only for photo download.
|
// be used only for photo download. This file_id can be used only for photo download and only for as
|
||||||
|
// long as the photo is not changed.
|
||||||
BigFileID string `json:"big_file_id"`
|
BigFileID string `json:"big_file_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,52 +777,46 @@ type (
|
||||||
// Information about the user
|
// Information about the user
|
||||||
User *User `json:"user"`
|
User *User `json:"user"`
|
||||||
|
|
||||||
// The member's status in the chat. Can be "creator", "administrator",
|
// The member's status in the chat. Can be "creator", "administrator", "member", "restricted", "left"
|
||||||
// "member", "restricted", "left" or "kicked"
|
// or "kicked"
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Restictred and kicked only. Date when restrictions will be lifted for
|
// Restictred and kicked only. Date when restrictions will be lifted for this user, unix time
|
||||||
// this user, unix time
|
|
||||||
UntilDate int64 `json:"until_date,omitempty"`
|
UntilDate int64 `json:"until_date,omitempty"`
|
||||||
|
|
||||||
// Administrators only. True, if the bot is allowed to edit administrator
|
// Administrators only. True, if the bot is allowed to edit administrator privileges of that user
|
||||||
// privileges of that user
|
|
||||||
CanBeEdited bool `json:"can_be_edited,omitempty"`
|
CanBeEdited bool `json:"can_be_edited,omitempty"`
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can change the chat
|
// Administrators only. True, if the administrator can post in the channel, channels only
|
||||||
// title, photo and other settings
|
|
||||||
CanChangeInfo bool `json:"can_change_info,omitempty"`
|
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can post in the
|
|
||||||
// channel, channels only
|
|
||||||
CanPostMessages bool `json:"can_post_messages,omitempty"`
|
CanPostMessages bool `json:"can_post_messages,omitempty"`
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can edit messages of
|
// Administrators only. True, if the administrator can edit messages of other users, channels only
|
||||||
// other users, channels only
|
|
||||||
CanEditMessages bool `json:"can_edit_messages,omitempty"`
|
CanEditMessages bool `json:"can_edit_messages,omitempty"`
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can delete messages of
|
// Administrators only. True, if the administrator can delete messages of other users
|
||||||
// other users
|
|
||||||
CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
|
CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can invite new users
|
|
||||||
// to the chat
|
|
||||||
CanInviteUsers bool `json:"can_invite_users,omitempty"`
|
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can restrict, ban or
|
// Administrators only. True, if the administrator can restrict, ban or
|
||||||
// unban chat members
|
// unban chat members
|
||||||
CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
|
CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can pin messages,
|
|
||||||
// supergroups only
|
|
||||||
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
|
||||||
|
|
||||||
// Administrators only. True, if the administrator can add new
|
// Administrators only. True, if the administrator can add new
|
||||||
// administrators with a subset of his own privileges or demote
|
// administrators with a subset of his own privileges or demote
|
||||||
// administrators that he has promoted, directly or indirectly (promoted
|
// administrators that he has promoted, directly or indirectly (promoted
|
||||||
// by administrators that were appointed by the user)
|
// by administrators that were appointed by the user)
|
||||||
CanPromoteMembers bool `json:"can_promote_members,omitempty"`
|
CanPromoteMembers bool `json:"can_promote_members,omitempty"`
|
||||||
|
|
||||||
|
// Administrators and restricted only. True, if the user is allowed to change the chat title, photo
|
||||||
|
// and other settings
|
||||||
|
CanChangeInfo bool `json:"can_change_info,omitempty"`
|
||||||
|
|
||||||
|
// Administrators and restricted only. True, if the user is allowed to invite new users to the chat
|
||||||
|
CanInviteUsers bool `json:"can_invite_users,omitempty"`
|
||||||
|
|
||||||
|
// Administrators and restricted only. True, if the user is allowed to pin messages; groups and
|
||||||
|
// supergroups only
|
||||||
|
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
||||||
|
|
||||||
// Restricted only. True, if the user is a member of the chat at the moment of the request
|
// Restricted only. True, if the user is a member of the chat at the moment of the request
|
||||||
IsMember bool `json:"is_member,omitempty"`
|
IsMember bool `json:"is_member,omitempty"`
|
||||||
|
|
||||||
|
@ -833,6 +828,9 @@ type (
|
||||||
// videos, video notes and voice notes, implies can_send_messages
|
// videos, video notes and voice notes, implies can_send_messages
|
||||||
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
|
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
|
||||||
|
|
||||||
|
// Restricted only. True, if the user is allowed to send polls
|
||||||
|
CanSendPolls bool `json:"can_send_polls,omitempty"`
|
||||||
|
|
||||||
// Restricted only. True, if the user can send animations, games,
|
// Restricted only. True, if the user can send animations, games,
|
||||||
// stickers and use inline bots, implies can_send_media_messages
|
// stickers and use inline bots, implies can_send_media_messages
|
||||||
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
|
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
|
||||||
|
@ -842,6 +840,36 @@ type (
|
||||||
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
|
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChatPermissions describes actions that a non-administrator user is allowed to take in a chat.
|
||||||
|
ChatPermissions struct {
|
||||||
|
// True, if the user is allowed to send text messages, contacts, locations and venues
|
||||||
|
CanSendMessages bool `json:"can_send_messages,omitempty"`
|
||||||
|
|
||||||
|
// True, if the user is allowed to send audios, documents, photos, videos, video notes and voice
|
||||||
|
// notes, implies can_send_messages
|
||||||
|
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
|
||||||
|
|
||||||
|
// True, if the user is allowed to send polls, implies can_send_messages
|
||||||
|
CanSendPolls bool `json:"can_send_polls,omitempty"`
|
||||||
|
|
||||||
|
// True, if the user is allowed to send animations, games, stickers and use inline bots, implies
|
||||||
|
// can_send_media_messages
|
||||||
|
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
|
||||||
|
|
||||||
|
// True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages
|
||||||
|
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
|
||||||
|
|
||||||
|
// True, if the user is allowed to change the chat title, photo and other settings. Ignored in public
|
||||||
|
// supergroups
|
||||||
|
CanChangeInfo bool `json:"can_change_info,omitempty"`
|
||||||
|
|
||||||
|
// True, if the user is allowed to invite new users to the chat
|
||||||
|
CanInviteUsers bool `json:"can_invite_users,omitempty"`
|
||||||
|
|
||||||
|
// True, if the user is allowed to pin messages. Ignored in public supergroups
|
||||||
|
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// ResponseParameters contains information about why a request was
|
// ResponseParameters contains information about why a request was
|
||||||
// unsuccessful.
|
// unsuccessful.
|
||||||
ResponseParameters struct {
|
ResponseParameters struct {
|
||||||
|
@ -2693,6 +2721,9 @@ type (
|
||||||
|
|
||||||
// For mask stickers, the position where the mask should be placed
|
// For mask stickers, the position where the mask should be placed
|
||||||
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
|
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
|
||||||
|
|
||||||
|
// true, if the sticker is animated
|
||||||
|
IsAnimated bool `json:"is_animated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StickerSet represents a sticker set.
|
// StickerSet represents a sticker set.
|
||||||
|
@ -2708,6 +2739,9 @@ type (
|
||||||
|
|
||||||
// List of all set stickers
|
// List of all set stickers
|
||||||
Stickers []Sticker `json:"stickers"`
|
Stickers []Sticker `json:"stickers"`
|
||||||
|
|
||||||
|
// true, if the sticker set contains animated stickers
|
||||||
|
IsAnimated bool `json:"is_animated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaskPosition describes the position on faces where a mask should be placed
|
// MaskPosition describes the position on faces where a mask should be placed
|
||||||
|
|
Loading…
Reference in New Issue
Block a user