Skip to content

BotAPI 8.2 implementation #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,81 @@ func (config SendGiftConfig) params() (Params, error) {
return params, nil
}

// VerifyUserConfig verifies a user on behalf of the organization
// which is represented by the bot.
// Returns True on success.
type VerifyUserConfig struct {
UserID int64 // required
CustomDescription string
}

func (config VerifyUserConfig) method() string {
return "verifyUser"
}

func (config VerifyUserConfig) params() (Params, error) {
params := make(Params)
params.AddNonZero64("user_id", config.UserID)
params.AddNonEmpty("custom_description", config.CustomDescription)

return params, nil
}

// VerifyChatConfig verifies a chat on behalf of the organization
// which is represented by the bot.
// Returns True on success.
type VerifyChatConfig struct {
Chat ChatConfig
CustomDescription string
}

func (config VerifyChatConfig) method() string {
return "verifyChat"
}

func (config VerifyChatConfig) params() (Params, error) {
params, err := config.Chat.params()
if err != nil {
return params, err
}
params.AddNonEmpty("custom_description", config.CustomDescription)

return params, nil
}

// RemoveUserVerificationConfig removes verification from a user who is currently
// verified on behalf of the organization represented by the bot.
// Returns True on success.
type RemoveUserVerificationConfig struct {
UserID int64 // required
}

func (config RemoveUserVerificationConfig) method() string {
return "removeUserVerification"
}

func (config RemoveUserVerificationConfig) params() (Params, error) {
params := make(Params)
params.AddNonZero64("user_id", config.UserID)

return params, nil
}

// RemoveChatVerificationConfig removes verification from a chat who is currently
// verified on behalf of the organization represented by the bot.
// Returns True on success.
type RemoveChatVerificationConfig struct {
Chat ChatConfig
}

func (config RemoveChatVerificationConfig) method() string {
return "removeChatVerification"
}

func (config RemoveChatVerificationConfig) params() (Params, error) {
return config.Chat.params()
}

// PinChatMessageConfig contains information of a message in a chat to pin.
type PinChatMessageConfig struct {
BaseChatMessage
Expand Down
34 changes: 34 additions & 0 deletions helper_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,40 @@ func NewDeleteMessages(chatID int64, messageIDs []int) DeleteMessagesConfig {
}
}

// NewVerifyUser verifies user on behalf of the organization
// which is represented by the bot
func NewVerifyUser(userID int64, customDescription string) VerifyUserConfig {
return VerifyUserConfig{
UserID: userID,
CustomDescription: customDescription,
}
}

// NewVerifyChat verifies chat on behalf of the organization
// which is represented by the bot
func NewVerifyChat(chat ChatConfig, customDescription string) VerifyChatConfig {
return VerifyChatConfig{
Chat: chat,
CustomDescription: customDescription,
}
}

// NewRemoveUserVerification removes verification from a user who is currently
// verified on behalf of the organization represented by the bot.
func NewRemoveUserVerification(userID int64) RemoveUserVerificationConfig {
return RemoveUserVerificationConfig{
UserID: userID,
}
}

// NewRemoveChatVerification removes verification from a chat that is currently
// verified on behalf of the organization represented by the bot.
func NewRemoveChatVerification(chat ChatConfig) RemoveChatVerificationConfig {
return RemoveChatVerificationConfig{
Chat: chat,
}
}

// NewMessageToChannel creates a new Message that is sent to a channel
// by username.
//
Expand Down
17 changes: 9 additions & 8 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4370,6 +4370,7 @@ type InlineQueryResultArticle struct {
// HideURL pass True, if you don't want the URL to be shown in the message.
//
// optional
// Deprecated in 8.2: Pass an empty string as url instead.
HideURL bool `json:"hide_url,omitempty"`
// Description short description of the result.
//
Expand Down Expand Up @@ -5319,26 +5320,26 @@ type RevenueWithdrawalState struct {
// AffiliateInfo contains information about the affiliate that
// received a commission via this transaction.
type AffiliateInfo struct {
// AffiliateUser is the bot or the user that received an
// AffiliateUser is the bot or the user that received an
// affiliate commission if it was received by a bot or a user
//
// optional
AffiliateUser *User `json:"affiliate_user,omitempty"`
// AffiliateChat is the chat that received an affiliate commission
// AffiliateChat is the chat that received an affiliate commission
// if it was received by a chat
//
// optional
AffiliateChat *Chat `json:"affiliate_chat,omitempty"`
// CommissionPerMile is the number of Telegram Stars received by
// the affiliate for each 1000 Telegram Stars received by
// CommissionPerMile is the number of Telegram Stars received by
// the affiliate for each 1000 Telegram Stars received by
// the bot from referred users
CommissionPerMile int `json:"commission_per_mille"`
// Amount is the integer amount of Telegram Stars received by
// the affiliate from the transaction, rounded to 0;
// Amount is the integer amount of Telegram Stars received by
// the affiliate from the transaction, rounded to 0;
// can be negative for refunds
Amount int64 `json:"amount"`
// NanostarAmount is the number of 1/1000000000 shares of Telegram Stars
// received by the affiliate; from -999999999 to 999999999;
// NanostarAmount is the number of 1/1000000000 shares of Telegram Stars
// received by the affiliate; from -999999999 to 999999999;
// can be negative for refunds
//
// optional
Expand Down
67 changes: 36 additions & 31 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ func TestFileLink(t *testing.T) {

// Ensure all configs are sendable
var (
_ Chattable = AddStickerConfig{}
_ Chattable = AnimationConfig{}
_ Chattable = AnswerWebAppQueryConfig{}
_ Chattable = AudioConfig{}
Expand All @@ -290,19 +291,25 @@ var (
_ Chattable = ChatInfoConfig{}
_ Chattable = ChatInviteLinkConfig{}
_ Chattable = CloseConfig{}
_ Chattable = CloseForumTopicConfig{}
_ Chattable = CloseGeneralForumTopicConfig{}
_ Chattable = ContactConfig{}
_ Chattable = CopyMessageConfig{}
_ Chattable = CreateChatInviteLinkConfig{}
_ Chattable = CreateChatSubscriptionLinkConfig{}
_ Chattable = CreateForumTopicConfig{}
_ Chattable = DeleteChatPhotoConfig{}
_ Chattable = DeleteChatStickerSetConfig{}
_ Chattable = DeleteForumTopicConfig{}
_ Chattable = DeleteMessageConfig{}
_ Chattable = GetAvailableGiftsConfig{}
_ Chattable = DeleteMyCommandsConfig{}
_ Chattable = DeleteStickerSetConfig{}
_ Chattable = DeleteWebhookConfig{}
_ Chattable = DocumentConfig{}
_ Chattable = EditChatInviteLinkConfig{}
_ Chattable = EditChatSubscriptionLinkConfig{}
_ Chattable = EditForumTopicConfig{}
_ Chattable = EditGeneralForumTopicConfig{}
_ Chattable = EditMessageCaptionConfig{}
_ Chattable = EditMessageLiveLocationConfig{}
_ Chattable = EditMessageMediaConfig{}
Expand All @@ -311,11 +318,18 @@ var (
_ Chattable = FileConfig{}
_ Chattable = ForwardConfig{}
_ Chattable = GameConfig{}
_ Chattable = GetAvailableGiftsConfig{}
_ Chattable = GetBusinessConnectionConfig{}
_ Chattable = GetChatMemberConfig{}
_ Chattable = GetChatMenuButtonConfig{}
_ Chattable = GetForumTopicIconStickersConfig{}
_ Chattable = GetGameHighScoresConfig{}
_ Chattable = GetMyDefaultAdministratorRightsConfig{}
_ Chattable = GetMyDescriptionConfig{}
_ Chattable = GetMyNameConfig{}
_ Chattable = GetMyShortDescriptionConfig{}
_ Chattable = GetStarTransactionsConfig{}
_ Chattable = HideGeneralForumTopicConfig{}
_ Chattable = InlineConfig{}
_ Chattable = InvoiceConfig{}
_ Chattable = KickChatMemberConfig{}
Expand All @@ -324,10 +338,16 @@ var (
_ Chattable = LogOutConfig{}
_ Chattable = MediaGroupConfig{}
_ Chattable = MessageConfig{}
_ Chattable = PaidMediaConfig{}
_ Chattable = PhotoConfig{}
_ Chattable = PinChatMessageConfig{}
_ Chattable = PreCheckoutConfig{}
_ Chattable = PromoteChatMemberConfig{}
_ Chattable = RefundStarPaymentConfig{}
_ Chattable = RemoveChatVerificationConfig{}
_ Chattable = RemoveUserVerificationConfig{}
_ Chattable = ReopenForumTopicConfig{}
_ Chattable = ReopenGeneralForumTopicConfig{}
_ Chattable = ReplaceStickerInSetConfig{}
_ Chattable = RestrictChatMemberConfig{}
_ Chattable = RevokeChatInviteLinkConfig{}
Expand All @@ -336,52 +356,37 @@ var (
_ Chattable = SetChatMenuButtonConfig{}
_ Chattable = SetChatPhotoConfig{}
_ Chattable = SetChatTitleConfig{}
_ Chattable = SetCustomEmojiStickerSetThumbnailConfig{}
_ Chattable = SetGameScoreConfig{}
_ Chattable = SetMessageReactionConfig{}
_ Chattable = SetMyDefaultAdministratorRightsConfig{}
_ Chattable = SetMyDescriptionConfig{}
_ Chattable = SetMyNameConfig{}
_ Chattable = SetMyShortDescriptionConfig{}
_ Chattable = SetStickerEmojiListConfig{}
_ Chattable = SetStickerKeywordsConfig{}
_ Chattable = SetStickerMaskPositionConfig{}
_ Chattable = SetStickerSetTitleConfig{}
_ Chattable = SetUserEmojiStatusConfig{}
_ Chattable = ShippingConfig{}
_ Chattable = StickerConfig{}
_ Chattable = StopMessageLiveLocationConfig{}
_ Chattable = StopPollConfig{}
_ Chattable = UnbanChatMemberConfig{}
_ Chattable = UnbanChatSenderChatConfig{}
_ Chattable = UnhideGeneralForumTopicConfig{}
_ Chattable = UnpinAllForumTopicMessagesConfig{}
_ Chattable = UnpinAllGeneralForumTopicMessagesConfig{}
_ Chattable = UnpinChatMessageConfig{}
_ Chattable = UpdateConfig{}
_ Chattable = SetMessageReactionConfig{}
_ Chattable = UserProfilePhotosConfig{}
_ Chattable = SetUserEmojiStatusConfig{}
_ Chattable = VenueConfig{}
_ Chattable = VerifyChatConfig{}
_ Chattable = VerifyUserConfig{}
_ Chattable = VideoConfig{}
_ Chattable = VideoNoteConfig{}
_ Chattable = VoiceConfig{}
_ Chattable = WebhookConfig{}
_ Chattable = CreateForumTopicConfig{}
_ Chattable = EditForumTopicConfig{}
_ Chattable = CloseForumTopicConfig{}
_ Chattable = ReopenForumTopicConfig{}
_ Chattable = DeleteForumTopicConfig{}
_ Chattable = UnpinAllForumTopicMessagesConfig{}
_ Chattable = GetForumTopicIconStickersConfig{}
_ Chattable = EditGeneralForumTopicConfig{}
_ Chattable = CloseGeneralForumTopicConfig{}
_ Chattable = ReopenGeneralForumTopicConfig{}
_ Chattable = HideGeneralForumTopicConfig{}
_ Chattable = UnhideGeneralForumTopicConfig{}
_ Chattable = UnpinAllGeneralForumTopicMessagesConfig{}
_ Chattable = SetCustomEmojiStickerSetThumbnailConfig{}
_ Chattable = SetStickerSetTitleConfig{}
_ Chattable = DeleteStickerSetConfig{}
_ Chattable = SetStickerEmojiListConfig{}
_ Chattable = SetStickerKeywordsConfig{}
_ Chattable = SetStickerMaskPositionConfig{}
_ Chattable = GetMyDescriptionConfig{}
_ Chattable = SetMyDescriptionConfig{}
_ Chattable = GetMyShortDescriptionConfig{}
_ Chattable = SetMyShortDescriptionConfig{}
_ Chattable = GetMyNameConfig{}
_ Chattable = SetMyNameConfig{}
_ Chattable = RefundStarPaymentConfig{}
_ Chattable = GetStarTransactionsConfig{}
_ Chattable = PaidMediaConfig{}
)

// Ensure all Fileable types are correct.
Expand Down