PaulSonOfLars / gotgbot

Autogenerated Go wrapper for the telegram API. Inspired by the python-telegram-bot library.
MIT License
511 stars 119 forks source link

API 7.5 support #167

Closed svscorp closed 4 months ago

svscorp commented 4 months ago

Hi Paul,

And thanks for your efforts maintaining the API. I saw there is a branch, but was curious, what are your plans on releasing the API 7.5 support?

PaulSonOfLars commented 4 months ago

Hi, thanks for the kind words :)

As you've mentioned, the branch is available; feel free to pin to that branch and help test it out. You can give quick feedback in the support group if you'd like, or just comment on the PR. Always wary of breakages from telegrams side, especially with some of the bigger changes from 7.5!

It should hopefully get released soon, along with some of the other improvements I've been making.

svscorp commented 4 months ago

Sure @PaulSonOfLars. Once I will get to "stars" implementation (that is new in v7.5) I'll let you know. Actually, I am rewriting my existing implementation from another package that was not maintained for a year or so to yours.

And one thing I'd like to ask is the following.

In my previous implementation I had a manual "webhook" handle function, and there before processing anything that goes in (whether it is message, callback, or something else), I implemented a rate limiter and tacking who is abusing the usage with custom implementation of muting (for certain amount of time) and banning, if it's occasional.

What would be the right way implementing it using your project and design?

Imagine I used both, internal app cache and a db (both for mutes and permanent bans), loading this data first when bot starts, and touching the db only if there are updates.

Would highly appreciate your advise :)

svscorp commented 4 months ago

I am thinking, should it be then only one handler for all incoming messages, like inlinequery.All, instead of writing individual handlers per message and query?

UPD: Looks like there is no way to forward all types of events to one handler. I can either capture all messages or all callback queries, etc... separately only.

Is my understanding correct?

svscorp commented 4 months ago

@PaulSonOfLars test reports, testing Sending Invoice for Stars (in 7.5)

payload := "buy_1"
title := "Sometitle"
description: "some description"
prices := []gotgbot.LabeledPrice{
        {Label: title, Amount: int64(amount)},
    }
_, err = p.BotAPI.SendInvoice(callbackQuery.Message.GetChat().Id, title, description, payload, "XTR", prices, &gotgbot.SendInvoiceOpts{})
if err != nil {
        logger.Errorf("Failed to send stars invoice: %v", err)
    } else {
        logger.Debugf("Stars invoice sent successfully: %s", payload)
    }

So it shows in log: Stars invoice sent successfully: buy_1

In Telegram, I see that chat window slightly moved up "like something should be shown", but nothing is displayed.

PaulSonOfLars commented 4 months ago

That sounds like it worked fine then - if theres no error on the bot API side, then theres not much else to handle. Worth checking which telegram clients you're using; are they latest official versions?

svscorp commented 4 months ago

Correct!