-// botAPI calls the Telegram Bot API. The bot token is a part of each URL, so no
-// error of botAPI holds a URL, a net/http error, or the token. SendTimeout
-// limits each sendMessage, sendRichMessage, and sendChatAction call.
-type botAPI struct {
- base string
- token string
- http *http.Client
- sendTimeout time.Duration
-}
-
-// botError is an answer of the Bot API that tells of a failure. RetryAfter is
-// the wait that the Bot API asks for after HTTP 429. Refused tells that the
-// answer is a Bot API answer with ok false, not a page of a proxy or of a
-// server error.
-type botError struct {
- Method string
- Status int
- Description string
- RetryAfter time.Duration
- Refused bool
-}
-
-// botAnswer is the envelope of each answer of the Bot API.
-type botAnswer struct {
- OK bool `json:"ok"`
- Result json.RawMessage `json:"result"`
- ErrorCode int `json:"error_code"`
- Description string `json:"description"`
- Parameters struct {
- RetryAfter int `json:"retry_after"`
- } `json:"parameters"`
-}
-
-// botUpdate is one update of getUpdates. Message is nil for the kinds of
-// updates that are not a new message.
-type botUpdate struct {
- UpdateID int64 `json:"update_id"`
- Message *botMessage `json:"message"`
+// newTelegramAPI returns the client of the Bot API at base with token.
+func newTelegramAPI(base, token string) *TelegramAPI {
+ return &TelegramAPI{
+ base: base,
+ token: token,
+ http: &http.Client{},
+ sendTimeout: telegramSendTimeout,
+ }