mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-11-30 07:15:38 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
898c19609c | ||
|
|
cec37b7b95 |
@@ -2,7 +2,7 @@ name: regen
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 6 * * 1" # Monday 06:00 UTC
|
||||
- cron: "0 6 * * *" # Every day 06:00 UTC
|
||||
workflow_dispatch: {}
|
||||
|
||||
permissions:
|
||||
|
||||
@@ -347,7 +347,7 @@ make snapshot # grab the latest HTML from core.telegram.org
|
||||
make regen # scrape → audit → emit Go → run tests → regenerate docs
|
||||
```
|
||||
|
||||
The audit tool checks for `any`-typed escapes, surprise `bool` returns, and signature drift. CI runs it on every PR, and a weekly workflow opens an auto-PR with regenerated code so a new Bot API version never sits longer than a week.
|
||||
The audit tool checks for `any`-typed escapes, surprise `bool` returns, and signature drift. CI runs it on every PR, and a daily workflow opens an auto-PR with regenerated code so a new Bot API version never sits longer than a day.
|
||||
|
||||
If something in Telegram's docs trips up the scraper, add an override to `internal/spec/overrides.json`. The audit will tell you what to put there.
|
||||
|
||||
|
||||
@@ -41,6 +41,14 @@ const (
|
||||
BotSubscriptionUpdatedStateFailed BotSubscriptionUpdatedState = "failed"
|
||||
)
|
||||
|
||||
type CallbackQueryMode string
|
||||
|
||||
const (
|
||||
CallbackQueryModeDefault CallbackQueryMode = "default"
|
||||
CallbackQueryModeAuto CallbackQueryMode = "auto"
|
||||
CallbackQueryModeInline CallbackQueryMode = "inline"
|
||||
)
|
||||
|
||||
type ChatBoostSourceKind string
|
||||
|
||||
const (
|
||||
@@ -60,6 +68,13 @@ const (
|
||||
ChatMemberStatusKicked ChatMemberStatus = "kicked"
|
||||
)
|
||||
|
||||
type ChatShareThemeType string
|
||||
|
||||
const (
|
||||
ChatShareThemeTypeEmoji ChatShareThemeType = "emoji"
|
||||
ChatShareThemeTypeUniqueGift ChatShareThemeType = "unique_gift"
|
||||
)
|
||||
|
||||
type ChatType string
|
||||
|
||||
const (
|
||||
@@ -69,6 +84,13 @@ const (
|
||||
ChatTypeChannel ChatType = "channel"
|
||||
)
|
||||
|
||||
type EmojiTypeKind string
|
||||
|
||||
const (
|
||||
EmojiTypeKindEmoji EmojiTypeKind = "emoji"
|
||||
EmojiTypeKindCustomEmoji EmojiTypeKind = "custom_emoji"
|
||||
)
|
||||
|
||||
type EncryptedPassportElementType string
|
||||
|
||||
const (
|
||||
@@ -267,6 +289,8 @@ const (
|
||||
MessageEntityTypeURL MessageEntityType = "url"
|
||||
MessageEntityTypeEmail MessageEntityType = "email"
|
||||
MessageEntityTypePhoneNumber MessageEntityType = "phone_number"
|
||||
MessageEntityTypeBankCardNumber MessageEntityType = "bank_card_number"
|
||||
MessageEntityTypeTonAddress MessageEntityType = "ton_address"
|
||||
MessageEntityTypeBold MessageEntityType = "bold"
|
||||
MessageEntityTypeItalic MessageEntityType = "italic"
|
||||
MessageEntityTypeUnderline MessageEntityType = "underline"
|
||||
@@ -501,6 +525,7 @@ const (
|
||||
RichTextTypeEmailAddress RichTextType = "email_address"
|
||||
RichTextTypePhoneNumber RichTextType = "phone_number"
|
||||
RichTextTypeBankCardNumber RichTextType = "bank_card_number"
|
||||
RichTextTypeTonAddress RichTextType = "ton_address"
|
||||
RichTextTypeMention RichTextType = "mention"
|
||||
RichTextTypeHashtag RichTextType = "hashtag"
|
||||
RichTextTypeCashtag RichTextType = "cashtag"
|
||||
@@ -592,3 +617,11 @@ const (
|
||||
UniqueGiftModelRarityEpic UniqueGiftModelRarity = "epic"
|
||||
UniqueGiftModelRarityLegendary UniqueGiftModelRarity = "legendary"
|
||||
)
|
||||
|
||||
type WidgetQueryTypeKind string
|
||||
|
||||
const (
|
||||
WidgetQueryTypeKindData WidgetQueryTypeKind = "data"
|
||||
WidgetQueryTypeKindSignData WidgetQueryTypeKind = "sign_data"
|
||||
WidgetQueryTypeKindSentTransaction WidgetQueryTypeKind = "sent_transaction"
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// MeCache caches the result of GetMe across calls. Construct one per
|
||||
// Bot and call Get to retrieve the cached User on subsequent invocations.
|
||||
// Bot and call Get to retrieve the cached BotFullInfo on subsequent invocations.
|
||||
//
|
||||
// var meCache api.MeCache
|
||||
// me, err := meCache.Get(ctx, bot)
|
||||
@@ -16,12 +16,12 @@ import (
|
||||
// MeCache is safe for concurrent use.
|
||||
type MeCache struct {
|
||||
mu sync.Mutex
|
||||
cached *User
|
||||
cached *BotFullInfo
|
||||
}
|
||||
|
||||
// Get returns the User from a cached GetMe call. If the cache is empty,
|
||||
// Get returns the BotFullInfo from a cached GetMe call. If the cache is empty,
|
||||
// it calls GetMe and populates the cache on success.
|
||||
func (c *MeCache) Get(ctx context.Context, b *client.Bot) (*User, error) {
|
||||
func (c *MeCache) Get(ctx context.Context, b *client.Bot) (*BotFullInfo, error) {
|
||||
c.mu.Lock()
|
||||
if c.cached != nil {
|
||||
u := c.cached
|
||||
|
||||
+477
-212
File diff suppressed because it is too large
Load Diff
+1247
-133
File diff suppressed because it is too large
Load Diff
+921
-164
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -228,7 +228,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-gray-100 mb-1">Generated from the live docs</h3>
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">IR + emitter pipeline runs weekly; a PR opens automatically for any Telegram-side change.</p>
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">IR + emitter pipeline runs daily; a PR opens automatically for any Telegram-side change.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+2677
-1555
File diff suppressed because it is too large
Load Diff
@@ -102,7 +102,7 @@ func main() {
|
||||
|
||||
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "You are authorized.",
|
||||
})
|
||||
return err
|
||||
@@ -114,7 +114,7 @@ func main() {
|
||||
return nil
|
||||
}
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "Your user ID is: " + strconv.FormatInt(from.ID, 10),
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -56,7 +56,7 @@ func handleCallback(c *dispatch.Context, q *api.CallbackQuery) error {
|
||||
|
||||
func sendMenu(ctx context.Context, bot *client.Bot, chatID int64, value int) error {
|
||||
_, err := api.SendMessage(ctx, bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(chatID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(chatID)),
|
||||
Text: fmt.Sprintf("Counter: %d", value),
|
||||
ReplyMarkup: counterKeyboard(value),
|
||||
})
|
||||
|
||||
@@ -114,7 +114,7 @@ func TestHandleCallback_Increments(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
_, _ = buf.ReadFrom(r.Body)
|
||||
return strings.Contains(buf.String(), `"Counter: 6"`)
|
||||
})).Return(okResp(editMsgResult), nil)
|
||||
})).Return(okResp(`{"ok":true,"result":true}`), nil)
|
||||
|
||||
bot := client.New("test:token", client.WithHTTPClient(m))
|
||||
q := callbackQuery("count:5:inc", 10, 42)
|
||||
@@ -137,7 +137,7 @@ func TestHandleCallback_Decrements(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
_, _ = buf.ReadFrom(r.Body)
|
||||
return strings.Contains(buf.String(), `"Counter: 4"`)
|
||||
})).Return(okResp(editMsgResult), nil)
|
||||
})).Return(okResp(`{"ok":true,"result":true}`), nil)
|
||||
|
||||
bot := client.New("test:token", client.WithHTTPClient(m))
|
||||
q := callbackQuery("count:5:dec", 10, 42)
|
||||
|
||||
@@ -25,7 +25,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
||||
Filter: onMsg(msgfilter.Command("/newbot")),
|
||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(u.Message.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(u.Message.Chat.ID)),
|
||||
Text: "What should the bot's name be?",
|
||||
})
|
||||
return conversation.Next("await_name")
|
||||
@@ -36,7 +36,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
||||
Filter: notCmd,
|
||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(u.Message.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(u.Message.Chat.ID)),
|
||||
Text: "Got it! What's the description?",
|
||||
})
|
||||
return conversation.Next("await_desc")
|
||||
@@ -46,7 +46,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
||||
Filter: notCmd,
|
||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(u.Message.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(u.Message.Chat.ID)),
|
||||
Text: "Done! Your bot has been configured.",
|
||||
})
|
||||
return conversation.End()
|
||||
@@ -57,7 +57,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
||||
Filter: onMsg(msgfilter.Command("/cancel")),
|
||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(u.Message.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(u.Message.Chat.ID)),
|
||||
Text: "Cancelled.",
|
||||
})
|
||||
return conversation.End()
|
||||
|
||||
@@ -16,7 +16,7 @@ func register(r *dispatch.Router) {
|
||||
|
||||
func handleStart(c *dispatch.Context, m *api.Message) error {
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: fmt.Sprintf("hello %s, send me anything to echo", m.From.FirstName),
|
||||
})
|
||||
return err
|
||||
@@ -24,7 +24,7 @@ func handleStart(c *dispatch.Context, m *api.Message) error {
|
||||
|
||||
func handleEcho(c *dispatch.Context, m *api.Message) error {
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: m.Text,
|
||||
ReplyParameters: &api.ReplyParameters{MessageID: &m.MessageID},
|
||||
})
|
||||
|
||||
@@ -39,7 +39,7 @@ func main() {
|
||||
|
||||
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "Send me a document and I'll download then re-upload it.",
|
||||
})
|
||||
return err
|
||||
@@ -88,7 +88,7 @@ func handleDocument(c *dispatch.Context, m *api.Message) error {
|
||||
name = "file"
|
||||
}
|
||||
_, err = api.SendDocument(c.Ctx, c.Bot, &api.SendDocumentParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Document: &api.InputFile{
|
||||
Reader: bytes.NewReader(body),
|
||||
Filename: name,
|
||||
@@ -103,7 +103,7 @@ func handleDocument(c *dispatch.Context, m *api.Message) error {
|
||||
|
||||
func reply(c *dispatch.Context, chatID int64, text string) error {
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(chatID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(chatID)),
|
||||
Text: text,
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -74,7 +74,7 @@ func main() {
|
||||
|
||||
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "middleware demo: this update was timed and (optionally) auth-checked",
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -70,7 +70,7 @@ func resolveTarget(m *api.Message) int64 {
|
||||
|
||||
func reply(c *dispatch.Context, chatID int64, text string) {
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(chatID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(chatID)),
|
||||
Text: text,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func main() {
|
||||
router.OnCommand("/list", func(c *dispatch.Context, m *api.Message) error {
|
||||
text, markup := renderPage(sampleItems, 0)
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: text,
|
||||
ReplyMarkup: markup,
|
||||
})
|
||||
|
||||
@@ -87,7 +87,7 @@ func main() {
|
||||
log.Printf("payment success: charge_id=%s payload=%q amount=%d %s",
|
||||
sp.TelegramPaymentChargeID, sp.InvoicePayload, sp.TotalAmount, sp.Currency)
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "Payment received! Your widget is on its way.",
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -89,7 +89,7 @@ func main() {
|
||||
}
|
||||
if question == "" {
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "Usage: /poll <question>",
|
||||
})
|
||||
return nil
|
||||
@@ -116,13 +116,13 @@ func main() {
|
||||
}
|
||||
if pollID == "" {
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "Usage: /tally <poll_id>",
|
||||
})
|
||||
return nil
|
||||
}
|
||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: tally.summary(pollID),
|
||||
})
|
||||
return nil
|
||||
|
||||
@@ -52,7 +52,7 @@ func main() {
|
||||
}
|
||||
n := store.inc(m.From.ID)
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: fmt.Sprintf("Your count: %d", n),
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -12,7 +12,7 @@ func register(r *dispatch.Router) {
|
||||
|
||||
func handlePing(c *dispatch.Context, m *api.Message) error {
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: "pong",
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -45,7 +45,7 @@ func main() {
|
||||
name += " " + u.LastName
|
||||
}
|
||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||
ChatID: api.ChatIDFromInt(m.Chat.ID),
|
||||
ChatID: api.Ptr(api.ChatIDFromInt(m.Chat.ID)),
|
||||
Text: fmt.Sprintf("Welcome, %s! Please read the pinned rules before posting.", name),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
+2350
-383
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -1 +1 @@
|
||||
snapshot_2026-09-14.html
|
||||
snapshot_2026-11-29.html
|
||||
+24911
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user