tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

GetCallbackQueryAnswer could be fast? #2710

Closed FunkyYang closed 8 months ago

FunkyYang commented 10 months ago

some groups call GetCallbackQueryAnswer and response slowly.How can I use it asynchronous?

levlam commented 10 months ago

Primary TDLib interface is asynchronous and most methods can be called only asynchronously. What exactly do you mean?

FunkyYang commented 10 months ago

I need get reponse which come from bot.that is synchronous

levlam commented 10 months ago

It is not possible to receive the response synchronously.

FunkyYang commented 10 months ago

// Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires
func (client *Client) GetCallbackQueryAnswer(req *GetCallbackQueryAnswerRequest) (*CallbackQueryAnswer, error) {
    result, err := client.Send(Request{
        meta: meta{
            Type: "getCallbackQueryAnswer",
        },
        Data: map[string]interface{}{
            "chat_id":    req.ChatId,
            "message_id": req.MessageId,
            "payload":    req.Payload,
        },
    })
    if err != nil {
        return nil, err
    }

    if result.Type == "error" {
        return nil, buildResponseError(result.Data)
    }

    return UnmarshalCallbackQueryAnswer(result.Data)
}

this is a library which I use to connect telegram. and that indicate must receive response from server before 60s timeout.this is a synchronously?

levlam commented 10 months ago

The function client.Send is asynchronous under the hood: https://github.com/zelenin/go-tdlib/blob/eacb6ab405b78851f6fabe02d2d79be5f2de74ea/client/client.go#L116C2-L116C8.