Problem
Bot.ID() parses the numeric bot id from the token prefix (<id>:<secret>). On any parse error it returns 0 with no way for callers to distinguish:
- invalid / placeholder token,
- corrupted token string,
- API misuse,
from a legitimate bot id that might theoretically collide with 0 (or simply: callers assume 0 means “error” but this is undocumented).
Current implementation:
func (b *Bot) ID() int64 {
id, err := strconv.ParseInt(strings.Split(b.token, ":")[0], 10, 64)
if err != nil {
return 0
}
return id
}
Problem
Bot.ID()parses the numeric bot id from the token prefix (<id>:<secret>). On any parse error it returns0with no way for callers to distinguish:from a legitimate bot id that might theoretically collide with
0(or simply: callers assume0means “error” but this is undocumented).Current implementation: