(new): support Bot API 10.3
Golang lint / lint (push) Failing after 1m37s

(fix): finalize v2 contracts
(tests): cover v2 migration
(doc): prepare release guidance
This commit is contained in:
2026-09-08 23:21:38 +03:00
parent 24040fe164
commit d78526242b
88 changed files with 2321 additions and 918 deletions
+6 -6
View File
@@ -9,7 +9,7 @@ import (
"net/http"
"time"
"git.scuroneko.dev/scuroneko/laniakea/utils"
"git.scuroneko.dev/scuroneko/laniakea/v2/utils"
"git.scuroneko.dev/scuroneko/sneklog/v2"
)
@@ -236,7 +236,7 @@ func NewRequestWithChatID[R, P any](method string, params P, chatID int64) Teleg
return TelegramRequest[R, P]{method, params, chatID}
}
func (r TelegramRequest[R, P]) doRequest(ctx context.Context, api *API) (R, error) {
func (api *API) doRequest[R, P any](ctx context.Context, r TelegramRequest[R, P]) (R, error) {
var zero R
reqData, err := json.Marshal(r.params)
if err != nil {
@@ -336,11 +336,11 @@ func (r TelegramRequest[R, P]) doRequest(ctx context.Context, api *API) (R, erro
// DoWithContext executes the request asynchronously via the worker pool.
// Returns result or error via channel. Respects context cancellation.
func (r TelegramRequest[R, P]) DoWithContext(ctx context.Context, api *API) (R, error) {
func (api *API) DoWithContext[R, P any](ctx context.Context, r TelegramRequest[R, P]) (R, error) {
var zero R
resultChan, err := api.pool.submit(ctx, func(ctx context.Context) (any, error) {
return r.doRequest(ctx, api)
return api.doRequest(ctx, r)
})
if err != nil {
return zero, err
@@ -362,8 +362,8 @@ func (r TelegramRequest[R, P]) DoWithContext(ctx context.Context, api *API) (R,
// Do executes the request synchronously with a background context.
// Use only for simple, non-critical calls.
func (r TelegramRequest[R, P]) Do(api *API) (R, error) {
return r.DoWithContext(context.Background(), api)
func (api *API) Do[R, P any](r TelegramRequest[R, P]) (R, error) {
return api.DoWithContext(context.Background(), r)
}
func readBody(body io.ReadCloser) ([]byte, error) {