mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-12-06 07:44:04 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cec37b7b95 | ||
|
|
2fa1494d57 | ||
|
|
b9ee0ead7c | ||
|
|
62c34d40a8 | ||
|
|
5f40e766d1 |
@@ -41,6 +41,14 @@ const (
|
|||||||
BotSubscriptionUpdatedStateFailed BotSubscriptionUpdatedState = "failed"
|
BotSubscriptionUpdatedStateFailed BotSubscriptionUpdatedState = "failed"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CallbackQueryMode string
|
||||||
|
|
||||||
|
const (
|
||||||
|
CallbackQueryModeDefault CallbackQueryMode = "default"
|
||||||
|
CallbackQueryModeAuto CallbackQueryMode = "auto"
|
||||||
|
CallbackQueryModeInline CallbackQueryMode = "inline"
|
||||||
|
)
|
||||||
|
|
||||||
type ChatBoostSourceKind string
|
type ChatBoostSourceKind string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -60,6 +68,13 @@ const (
|
|||||||
ChatMemberStatusKicked ChatMemberStatus = "kicked"
|
ChatMemberStatusKicked ChatMemberStatus = "kicked"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ChatShareThemeType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ChatShareThemeTypeEmoji ChatShareThemeType = "emoji"
|
||||||
|
ChatShareThemeTypeUniqueGift ChatShareThemeType = "unique_gift"
|
||||||
|
)
|
||||||
|
|
||||||
type ChatType string
|
type ChatType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -69,6 +84,13 @@ const (
|
|||||||
ChatTypeChannel ChatType = "channel"
|
ChatTypeChannel ChatType = "channel"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type EmojiTypeKind string
|
||||||
|
|
||||||
|
const (
|
||||||
|
EmojiTypeKindEmoji EmojiTypeKind = "emoji"
|
||||||
|
EmojiTypeKindCustomEmoji EmojiTypeKind = "custom_emoji"
|
||||||
|
)
|
||||||
|
|
||||||
type EncryptedPassportElementType string
|
type EncryptedPassportElementType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -267,6 +289,8 @@ const (
|
|||||||
MessageEntityTypeURL MessageEntityType = "url"
|
MessageEntityTypeURL MessageEntityType = "url"
|
||||||
MessageEntityTypeEmail MessageEntityType = "email"
|
MessageEntityTypeEmail MessageEntityType = "email"
|
||||||
MessageEntityTypePhoneNumber MessageEntityType = "phone_number"
|
MessageEntityTypePhoneNumber MessageEntityType = "phone_number"
|
||||||
|
MessageEntityTypeBankCardNumber MessageEntityType = "bank_card_number"
|
||||||
|
MessageEntityTypeTonAddress MessageEntityType = "ton_address"
|
||||||
MessageEntityTypeBold MessageEntityType = "bold"
|
MessageEntityTypeBold MessageEntityType = "bold"
|
||||||
MessageEntityTypeItalic MessageEntityType = "italic"
|
MessageEntityTypeItalic MessageEntityType = "italic"
|
||||||
MessageEntityTypeUnderline MessageEntityType = "underline"
|
MessageEntityTypeUnderline MessageEntityType = "underline"
|
||||||
@@ -501,6 +525,7 @@ const (
|
|||||||
RichTextTypeEmailAddress RichTextType = "email_address"
|
RichTextTypeEmailAddress RichTextType = "email_address"
|
||||||
RichTextTypePhoneNumber RichTextType = "phone_number"
|
RichTextTypePhoneNumber RichTextType = "phone_number"
|
||||||
RichTextTypeBankCardNumber RichTextType = "bank_card_number"
|
RichTextTypeBankCardNumber RichTextType = "bank_card_number"
|
||||||
|
RichTextTypeTonAddress RichTextType = "ton_address"
|
||||||
RichTextTypeMention RichTextType = "mention"
|
RichTextTypeMention RichTextType = "mention"
|
||||||
RichTextTypeHashtag RichTextType = "hashtag"
|
RichTextTypeHashtag RichTextType = "hashtag"
|
||||||
RichTextTypeCashtag RichTextType = "cashtag"
|
RichTextTypeCashtag RichTextType = "cashtag"
|
||||||
@@ -592,3 +617,11 @@ const (
|
|||||||
UniqueGiftModelRarityEpic UniqueGiftModelRarity = "epic"
|
UniqueGiftModelRarityEpic UniqueGiftModelRarity = "epic"
|
||||||
UniqueGiftModelRarityLegendary UniqueGiftModelRarity = "legendary"
|
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
|
// 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
|
// var meCache api.MeCache
|
||||||
// me, err := meCache.Get(ctx, bot)
|
// me, err := meCache.Get(ctx, bot)
|
||||||
@@ -16,12 +16,12 @@ import (
|
|||||||
// MeCache is safe for concurrent use.
|
// MeCache is safe for concurrent use.
|
||||||
type MeCache struct {
|
type MeCache struct {
|
||||||
mu sync.Mutex
|
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.
|
// 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()
|
c.mu.Lock()
|
||||||
if c.cached != nil {
|
if c.cached != nil {
|
||||||
u := c.cached
|
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
+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 {
|
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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.",
|
Text: "You are authorized.",
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
@@ -114,7 +114,7 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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),
|
Text: "Your user ID is: " + strconv.FormatInt(from.ID, 10),
|
||||||
})
|
})
|
||||||
return err
|
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 {
|
func sendMenu(ctx context.Context, bot *client.Bot, chatID int64, value int) error {
|
||||||
_, err := api.SendMessage(ctx, bot, &api.SendMessageParams{
|
_, err := api.SendMessage(ctx, bot, &api.SendMessageParams{
|
||||||
ChatID: api.ChatIDFromInt(chatID),
|
ChatID: api.Ptr(api.ChatIDFromInt(chatID)),
|
||||||
Text: fmt.Sprintf("Counter: %d", value),
|
Text: fmt.Sprintf("Counter: %d", value),
|
||||||
ReplyMarkup: counterKeyboard(value),
|
ReplyMarkup: counterKeyboard(value),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ func TestHandleCallback_Increments(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
_, _ = buf.ReadFrom(r.Body)
|
_, _ = buf.ReadFrom(r.Body)
|
||||||
return strings.Contains(buf.String(), `"Counter: 6"`)
|
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))
|
bot := client.New("test:token", client.WithHTTPClient(m))
|
||||||
q := callbackQuery("count:5:inc", 10, 42)
|
q := callbackQuery("count:5:inc", 10, 42)
|
||||||
@@ -137,7 +137,7 @@ func TestHandleCallback_Decrements(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
_, _ = buf.ReadFrom(r.Body)
|
_, _ = buf.ReadFrom(r.Body)
|
||||||
return strings.Contains(buf.String(), `"Counter: 4"`)
|
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))
|
bot := client.New("test:token", client.WithHTTPClient(m))
|
||||||
q := callbackQuery("count:5:dec", 10, 42)
|
q := callbackQuery("count:5:dec", 10, 42)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
|||||||
Filter: onMsg(msgfilter.Command("/newbot")),
|
Filter: onMsg(msgfilter.Command("/newbot")),
|
||||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = 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?",
|
Text: "What should the bot's name be?",
|
||||||
})
|
})
|
||||||
return conversation.Next("await_name")
|
return conversation.Next("await_name")
|
||||||
@@ -36,7 +36,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
|||||||
Filter: notCmd,
|
Filter: notCmd,
|
||||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = 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?",
|
Text: "Got it! What's the description?",
|
||||||
})
|
})
|
||||||
return conversation.Next("await_desc")
|
return conversation.Next("await_desc")
|
||||||
@@ -46,7 +46,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
|||||||
Filter: notCmd,
|
Filter: notCmd,
|
||||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = 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.",
|
Text: "Done! Your bot has been configured.",
|
||||||
})
|
})
|
||||||
return conversation.End()
|
return conversation.End()
|
||||||
@@ -57,7 +57,7 @@ func buildConv(storage conversation.Storage) *conversation.Conversation {
|
|||||||
Filter: onMsg(msgfilter.Command("/cancel")),
|
Filter: onMsg(msgfilter.Command("/cancel")),
|
||||||
Handler: func(c *dispatch.Context, u *api.Update) error {
|
Handler: func(c *dispatch.Context, u *api.Update) error {
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = 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.",
|
Text: "Cancelled.",
|
||||||
})
|
})
|
||||||
return conversation.End()
|
return conversation.End()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func register(r *dispatch.Router) {
|
|||||||
|
|
||||||
func handleStart(c *dispatch.Context, m *api.Message) error {
|
func handleStart(c *dispatch.Context, m *api.Message) error {
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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),
|
Text: fmt.Sprintf("hello %s, send me anything to echo", m.From.FirstName),
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
@@ -24,7 +24,7 @@ func handleStart(c *dispatch.Context, m *api.Message) error {
|
|||||||
|
|
||||||
func handleEcho(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{
|
_, 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,
|
Text: m.Text,
|
||||||
ReplyParameters: &api.ReplyParameters{MessageID: &m.MessageID},
|
ReplyParameters: &api.ReplyParameters{MessageID: &m.MessageID},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func main() {
|
|||||||
|
|
||||||
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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.",
|
Text: "Send me a document and I'll download then re-upload it.",
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
@@ -88,7 +88,7 @@ func handleDocument(c *dispatch.Context, m *api.Message) error {
|
|||||||
name = "file"
|
name = "file"
|
||||||
}
|
}
|
||||||
_, err = api.SendDocument(c.Ctx, c.Bot, &api.SendDocumentParams{
|
_, 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{
|
Document: &api.InputFile{
|
||||||
Reader: bytes.NewReader(body),
|
Reader: bytes.NewReader(body),
|
||||||
Filename: name,
|
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 {
|
func reply(c *dispatch.Context, chatID int64, text string) error {
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||||
ChatID: api.ChatIDFromInt(chatID),
|
ChatID: api.Ptr(api.ChatIDFromInt(chatID)),
|
||||||
Text: text,
|
Text: text,
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func main() {
|
|||||||
|
|
||||||
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
router.OnCommand("/start", func(c *dispatch.Context, m *api.Message) error {
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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",
|
Text: "middleware demo: this update was timed and (optionally) auth-checked",
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func resolveTarget(m *api.Message) int64 {
|
|||||||
|
|
||||||
func reply(c *dispatch.Context, chatID int64, text string) {
|
func reply(c *dispatch.Context, chatID int64, text string) {
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
||||||
ChatID: api.ChatIDFromInt(chatID),
|
ChatID: api.Ptr(api.ChatIDFromInt(chatID)),
|
||||||
Text: text,
|
Text: text,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ func main() {
|
|||||||
router.OnCommand("/list", func(c *dispatch.Context, m *api.Message) error {
|
router.OnCommand("/list", func(c *dispatch.Context, m *api.Message) error {
|
||||||
text, markup := renderPage(sampleItems, 0)
|
text, markup := renderPage(sampleItems, 0)
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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,
|
Text: text,
|
||||||
ReplyMarkup: markup,
|
ReplyMarkup: markup,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func main() {
|
|||||||
log.Printf("payment success: charge_id=%s payload=%q amount=%d %s",
|
log.Printf("payment success: charge_id=%s payload=%q amount=%d %s",
|
||||||
sp.TelegramPaymentChargeID, sp.InvoicePayload, sp.TotalAmount, sp.Currency)
|
sp.TelegramPaymentChargeID, sp.InvoicePayload, sp.TotalAmount, sp.Currency)
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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.",
|
Text: "Payment received! Your widget is on its way.",
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
if question == "" {
|
if question == "" {
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = 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>",
|
Text: "Usage: /poll <question>",
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
@@ -116,13 +116,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
if pollID == "" {
|
if pollID == "" {
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = 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>",
|
Text: "Usage: /tally <poll_id>",
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
_, _ = api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, _ = 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),
|
Text: tally.summary(pollID),
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
n := store.inc(m.From.ID)
|
n := store.inc(m.From.ID)
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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),
|
Text: fmt.Sprintf("Your count: %d", n),
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func register(r *dispatch.Router) {
|
|||||||
|
|
||||||
func handlePing(c *dispatch.Context, m *api.Message) error {
|
func handlePing(c *dispatch.Context, m *api.Message) error {
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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",
|
Text: "pong",
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func main() {
|
|||||||
name += " " + u.LastName
|
name += " " + u.LastName
|
||||||
}
|
}
|
||||||
_, err := api.SendMessage(c.Ctx, c.Bot, &api.SendMessageParams{
|
_, 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),
|
Text: fmt.Sprintf("Welcome, %s! Please read the pinned rules before posting.", name),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ require (
|
|||||||
github.com/goccy/go-json v0.12.0
|
github.com/goccy/go-json v0.12.0
|
||||||
github.com/lukaszraczylo/oss-telemetry v0.2.5
|
github.com/lukaszraczylo/oss-telemetry v0.2.5
|
||||||
github.com/stretchr/testify v1.12.1
|
github.com/stretchr/testify v1.12.1
|
||||||
github.com/valyala/fasthttp v1.79.0
|
github.com/valyala/fasthttp v1.80.0
|
||||||
golang.org/x/net v0.63.0
|
golang.org/x/net v0.63.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWD
|
|||||||
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasthttp v1.79.0 h1:32ur91W4kWG+1s6x3oDlP8/KNmjlZZlUzSSC4p9LSWE=
|
github.com/valyala/fasthttp v1.80.0 h1:10pVr/QLFGbSX8ikDS0i+wOi2AGY2Sy0TACVpoiG+7U=
|
||||||
github.com/valyala/fasthttp v1.79.0/go.mod h1:NQN+PlgP93+JRPnCiApN5XwnI24oMQf8kuzrxtsTy9A=
|
github.com/valyala/fasthttp v1.80.0/go.mod h1:oulvtxx5dQeORu6sKWaJItcnWXRqiGmrTFQ4gmZjLFM=
|
||||||
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
|
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
|
||||||
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
||||||
|
|||||||
+2350
-383
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,9 @@ replace github.com/lukaszraczylo/go-telegram => ../../
|
|||||||
require (
|
require (
|
||||||
github.com/NicoNex/echotron/v3 v3.47.0
|
github.com/NicoNex/echotron/v3 v3.47.0
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
|
||||||
github.com/go-telegram/bot v1.30.0
|
github.com/go-telegram/bot v1.31.0
|
||||||
github.com/lukaszraczylo/go-telegram v0.0.0-00010101000000-000000000000
|
github.com/lukaszraczylo/go-telegram v0.0.0-00010101000000-000000000000
|
||||||
github.com/mymmrac/telego v1.13.0
|
github.com/mymmrac/telego v1.14.0
|
||||||
gopkg.in/telebot.v4 v4.0.0
|
gopkg.in/telebot.v4 v4.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ require (
|
|||||||
github.com/molecule-man/go-brrr v1.3.1 // indirect
|
github.com/molecule-man/go-brrr v1.3.1 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasthttp v1.79.0 // indirect
|
github.com/valyala/fasthttp v1.80.0 // indirect
|
||||||
github.com/valyala/fastjson v1.6.10 // indirect
|
github.com/valyala/fastjson v1.6.10 // indirect
|
||||||
golang.org/x/arch v0.33.0 // indirect
|
golang.org/x/arch v0.33.0 // indirect
|
||||||
golang.org/x/sys v0.50.0 // indirect
|
golang.org/x/sys v0.50.0 // indirect
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn
|
|||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
||||||
github.com/go-telegram/bot v1.30.0 h1:jqx9fw3QFfgZhR5e7Tp8dlFqoASHmmFy6OrLwbk13uA=
|
github.com/go-telegram/bot v1.31.0 h1:F7WgyBPKup/9SfsM/ybfX/PMdaz/Tkcmu9sdK3+rqV8=
|
||||||
github.com/go-telegram/bot v1.30.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
|
github.com/go-telegram/bot v1.31.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
|
||||||
github.com/goccy/go-json v0.12.0 h1:pD+oWouAiz4yruwXIt/iT+lOMeyhr1aTtxzaMP/RgVI=
|
github.com/goccy/go-json v0.12.0 h1:pD+oWouAiz4yruwXIt/iT+lOMeyhr1aTtxzaMP/RgVI=
|
||||||
github.com/goccy/go-json v0.12.0/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY=
|
github.com/goccy/go-json v0.12.0/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY=
|
||||||
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
|
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
|
||||||
@@ -320,8 +320,8 @@ github.com/molecule-man/go-brrr v1.3.1 h1:EwaJUzRIlp/dFmIpzq4J17CA5Zi5OHo2vOGmu0
|
|||||||
github.com/molecule-man/go-brrr v1.3.1/go.mod h1:7ybW6/7gA3oKY45jOfVNjSJDtrr6ea4tzbsTkjmQDC4=
|
github.com/molecule-man/go-brrr v1.3.1/go.mod h1:7ybW6/7gA3oKY45jOfVNjSJDtrr6ea4tzbsTkjmQDC4=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/mymmrac/telego v1.13.0 h1:1sz4F5bstBJYjZNPPJykYBT0HHIIKvPLvARZt45swM0=
|
github.com/mymmrac/telego v1.14.0 h1:6wI282H2dXYTgJjESckU29vVDZhpC/kfxuCaeyG9vF8=
|
||||||
github.com/mymmrac/telego v1.13.0/go.mod h1:gsRatcXPP0UBU9gWbKzp21yQWoPHte86AUKrVcikuaw=
|
github.com/mymmrac/telego v1.14.0/go.mod h1:H2FYDs8ahk5zxt+QlPpPZF55k+J/qKfGxgdWIvWv5UQ=
|
||||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||||
@@ -392,8 +392,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
|
|||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasthttp v1.79.0 h1:32ur91W4kWG+1s6x3oDlP8/KNmjlZZlUzSSC4p9LSWE=
|
github.com/valyala/fasthttp v1.80.0 h1:10pVr/QLFGbSX8ikDS0i+wOi2AGY2Sy0TACVpoiG+7U=
|
||||||
github.com/valyala/fasthttp v1.79.0/go.mod h1:NQN+PlgP93+JRPnCiApN5XwnI24oMQf8kuzrxtsTy9A=
|
github.com/valyala/fasthttp v1.80.0/go.mod h1:oulvtxx5dQeORu6sKWaJItcnWXRqiGmrTFQ4gmZjLFM=
|
||||||
github.com/valyala/fastjson v1.6.10 h1:/yjJg8jaVQdYR3arGxPE2X5z89xrlhS0eGXdv+ADTh4=
|
github.com/valyala/fastjson v1.6.10 h1:/yjJg8jaVQdYR3arGxPE2X5z89xrlhS0eGXdv+ADTh4=
|
||||||
github.com/valyala/fastjson v1.6.10/go.mod h1:e6FubmQouUNP73jtMLmcbxS6ydWIpOfhz34TSfO3JaE=
|
github.com/valyala/fastjson v1.6.10/go.mod h1:e6FubmQouUNP73jtMLmcbxS6ydWIpOfhz34TSfO3JaE=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
@@ -639,8 +639,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func TestGetMe(t *testing.T) {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
u, err := api.GetMe(ctx, b)
|
u, err := api.GetMe(ctx, b, &api.GetMeParams{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, u.IsBot)
|
require.True(t, u.IsBot)
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ func TestSendMessage(t *testing.T) {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
msg, err := api.SendMessage(ctx, b, &api.SendMessageParams{
|
msg, err := api.SendMessage(ctx, b, &api.SendMessageParams{
|
||||||
ChatID: chatID,
|
ChatID: api.ChatIDFromInt(chatID),
|
||||||
Text: "integration test " + time.Now().UTC().Format(time.RFC3339),
|
Text: "integration test " + time.Now().UTC().Format(time.RFC3339),
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
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