• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bots-go-framework / bots-fw / 16304292245

15 Jul 2025 09:03PM UTC coverage: 3.205% (-0.01%) from 3.219%
16304292245

push

github

trakhimenok
feat: added botmsg.AnswerCallbackQuery

0 of 25 new or added lines in 2 files covered. (0.0%)

124 of 3869 relevant lines covered (3.2%)

0.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/botmsg/message_answer_callback.go
1
package botmsg
2

3
import (
4
        "errors"
5
        "fmt"
6
        "net/url"
7
        "strings"
8
)
9

10
var _ BotMessage = AnswerCallbackQuery{}
11
var _ BotMessage = (*AnswerCallbackQuery)(nil)
12

13
// AnswerCallbackQuery is modeled after https://core.telegram.org/bots/api#answercallbackquery
14
type AnswerCallbackQuery struct {
15
        CallbackQueryID string `json:"callback_query_id"` // Unique identifier for the query to be answered
16

17
        // Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
18
        Text string `json:"text,omitempty"`
19

20
        // If True, an alert will be shown by the client instead of a notification at the top of the chat screen
21
        ShowAlert bool `json:"show_alert,omitempty"`
22

23
        // URL that will be opened by the user's client.
24
        // If you have created a Game and accepted the conditions via @BotFather,
25
        // specify the URL that opens your game - note that this will only work
26
        // if the query comes from a callback_game button.
27
        //
28
        // Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
29
        URL string `json:"url,omitempty"`
30

31
        // The maximum amount of time in seconds that the result of the callback query may be cached client-side.
32
        // Telegram apps will support caching starting in version 3.14. Defaults to 0.
33
        CacheTime int `json:"cache_time,omitempty"`
34
}
35

NEW
36
func (AnswerCallbackQuery) BotMessageType() Type {
×
NEW
37
        return TypeCallbackAnswer
×
NEW
38
}
×
39

NEW
40
func (v AnswerCallbackQuery) Validate() error {
×
NEW
41
        if strings.TrimSpace(v.CallbackQueryID) == "" {
×
NEW
42
                return errors.New("missing required parameter CallbackQueryID")
×
NEW
43
        }
×
NEW
44
        if len(v.Text) > 200 {
×
NEW
45
                return fmt.Errorf("callback text cannot be longer than 200 characters, got %d", len(v.Text))
×
NEW
46
        }
×
NEW
47
        if v.CacheTime < 0 {
×
NEW
48
                return fmt.Errorf("callback cache time must be 0 or positive, got %d", v.CacheTime)
×
NEW
49
        }
×
NEW
50
        if _, err := url.Parse(v.URL); err != nil {
×
NEW
51
                return fmt.Errorf("URL is invalid: %w", err)
×
NEW
52
        }
×
NEW
53
        return nil
×
54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc