Skip to content
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

BotAPI7.2 #706

Merged
merged 7 commits into from
Aug 8, 2024
Merged

BotAPI7.2 #706

merged 7 commits into from
Aug 8, 2024

Conversation

Apolisk
Copy link
Contributor

@Apolisk Apolisk commented Jun 27, 2024

No description provided.

@Apolisk Apolisk changed the title Integration with Business Accounts BotAPI7.2 Jun 27, 2024
bot.go Outdated
@@ -1271,6 +1271,27 @@ func (b *Bot) botInfo(language, key string) (*BotInfo, error) {
return resp.Result, nil
}

// GetBusinessConnection use this method to get information about the connection of the bot with a business account.
// Returns a BusinessConnection object on success.
func (b *Bot) GetBusinessConnection(businessConnectionID string) (*BusinessConnection, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (b *Bot) BusinessConnection(connectionID string) (*BusinessConnection, error) {
	params := map[string]string{
		"business_connection_id": connectionID,
	}

	data, err := b.Raw("getBusinessConnection", params)
	if err != nil {
		return nil, err
	}

	var resp struct {
		Result *BusinessConnection
	}

	if err := json.Unmarshal(data, &resp); err != nil {
		return nil, wrapError(err)
	}
	return resp.Result, nil
}

message.go Outdated

// (Optional) The bot that actually sent the message on behalf of the business account.
// Available only for outgoing messages sent on behalf of the connected business account.
SenderBusinessBot *User `json:"sender_business_bot"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BusinessBot *User `json:"sender_business_bot"`

sticker.go Outdated
@@ -304,3 +303,24 @@ func (b *Bot) SetCustomEmojiStickerSetThumb(name, id string) error {
_, err := b.Raw("setCustomEmojiStickerSetThumbnail", params)
return err
}

// ReplaceStickerInSet returns True on success, if existing sticker was replaced with a new one
func (b *Bot) ReplaceStickerInSet(of Recipient, name, old_sticker string, sticker InputSticker) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (b *Bot) ReplaceStickerInSet(of Recipient, name, oldSticker string, sticker InputSticker) (bool, error) {
	files := make(map[string]File)
	
        repr := sticker.File.process("0", files)
	if repr == "" {
		return false, errors.New("telebot: sticker does not exist")
	}
	sticker.Sticker = repr

	data, err := json.Marshal(sticker)
        if err != nil {
             ...
        }

	params := map[string]string{
		"user_id":     of.Recipient(),
		"name":        name,
		"old_stikcer": oldSticker,
		"sticker":     string(data),
	}

	_, err := b.sendFiles("replaceStickerInSet", files, params)
	return true, err
}

sticker.go Outdated
params := map[string]string{
"user_id": of.Recipient(),
"name": name,
"old_stikcer": oldSticker,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"old_sticker": oldSticker,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, already fixed.

@demget demget changed the base branch from v3 to v3.4 July 11, 2024 13:16
@demget demget merged commit 8d98398 into tucnak:v3.4 Aug 8, 2024
1 check passed
demget pushed a commit that referenced this pull request Aug 9, 2024
* Integration with Business Accounts

* Working on Behalf of Business Accounts

* Information about Business Accounts

* Mixed-Format Sticker Packs

* Request Chat Improvements

* Other Changes

* business: satisfy change request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants