(draft): telegram markdown v2 string builder
Golang lint / lint (push) Successful in 4m51s

This commit is contained in:
2026-04-30 13:56:36 +03:00
parent 269ccec007
commit 071fc2375e
34 changed files with 1227 additions and 385 deletions
+2 -2
View File
@@ -83,10 +83,10 @@ func (opts *APIOpts) SetLimiter(limiter *utils.RateLimiter) *APIOpts {
return opts
}
// SetLimiterDrop enables "drop mode" for rate limiting.
// SetDropRateLimitOverflow enables "drop mode" for rate limiting.
// If true, requests exceeding limits return ErrDropOverflow immediately.
// If false, requests block until capacity is available.
func (opts *APIOpts) SetLimiterDrop(b bool) *APIOpts {
func (opts *APIOpts) SetDropRateLimitOverflow(b bool) *APIOpts {
opts.dropOverflowLimit = b
return opts
}
+4 -4
View File
@@ -652,15 +652,15 @@ func (api *API) GetChatAdministratorsWithContext(ctx context.Context, params Get
return req.DoWithContext(ctx, api)
}
// GetChatMembersCount holds parameters for the getChatMemberCount method.
// GetChatMemberCount holds parameters for the getChatMemberCount method.
// See https://core.telegram.org/bots/api#getchatmembercount
type GetChatMembersCount struct {
type GetChatMemberCount struct {
ChatID int64 `json:"chat_id"`
}
// GetChatMemberCount returns the number of members in a chat.
// See https://core.telegram.org/bots/api#getchatmembercount
func (api *API) GetChatMemberCount(params GetChatMembersCount) (int, error) {
func (api *API) GetChatMemberCount(params GetChatMemberCount) (int, error) {
req := NewRequestWithChatID[int]("getChatMemberCount", params, params.ChatID)
return req.Do(api)
}
@@ -668,7 +668,7 @@ func (api *API) GetChatMemberCount(params GetChatMembersCount) (int, error) {
// GetChatMemberCountWithContext is the context-aware variant of GetChatMemberCount.
// It executes the same request but uses ctx for cancellation and deadlines.
// See https://core.telegram.org/bots/api#getchatmembercount
func (api *API) GetChatMemberCountWithContext(ctx context.Context, params GetChatMembersCount) (int, error) {
func (api *API) GetChatMemberCountWithContext(ctx context.Context, params GetChatMemberCount) (int, error) {
req := NewRequestWithChatID[int]("getChatMemberCount", params, params.ChatID)
return req.DoWithContext(ctx, api)
}
+1 -1
View File
@@ -362,7 +362,7 @@ type MessageEntity struct {
Language string `json:"language,omitempty"`
CustomEmojiID string `json:"custom_emoji_id,omitempty"`
UnixTime int `json:"unix_time,omitempty"`
UnixTime int64 `json:"unix_time,omitempty"`
DateTimeFormat string `json:"date_time_format,omitempty"`
}
+4 -4
View File
@@ -4,12 +4,12 @@ package tgapi
type ParseMode string
const (
// ParseMDV2 enables MarkdownV2 style parsing.
ParseMDV2 ParseMode = "MarkdownV2"
// ParseMarkdownV2 enables MarkdownV2 style parsing.
ParseMarkdownV2 ParseMode = "MarkdownV2"
// ParseHTML enables HTML style parsing.
ParseHTML ParseMode = "HTML"
// ParseMD enables legacy Markdown style parsing.
ParseMD ParseMode = "Markdown"
// ParseMarkdown enables legacy Markdown style parsing.
ParseMarkdown ParseMode = "Markdown"
// ParseNone disables parse_mode and leaves plain-text requests unannotated.
ParseNone ParseMode = ""
)
+1 -1
View File
@@ -25,7 +25,7 @@ func TestParseModeStillSerializesExplicitModes(t *testing.T) {
data, err := json.Marshal(SendMessage{
ChatID: 42,
Text: "hello",
ParseMode: ParseMDV2,
ParseMode: ParseMarkdownV2,
})
if err != nil {
t.Fatalf("Marshal returned error: %v", err)