telebot: fix linter inspection problems

pull/300/head
Demian 4 years ago
parent 7a1d59c7d9
commit f82c0ec609

@ -18,7 +18,6 @@ go get -u gopkg.in/tucnak/telebot.v2
- [Editable](#editable) - [Editable](#editable)
- [Keyboards](#keyboards) - [Keyboards](#keyboards)
- [Inline mode](#inline-mode) - [Inline mode](#inline-mode)
- [Poll](#poll)
* [Contributing](#contributing) * [Contributing](#contributing)
* [Donate](#donate) * [Donate](#donate)
* [License](#license) * [License](#license)
@ -45,10 +44,13 @@ Let's take a look at the minimal telebot setup:
package main package main
import ( import (
"time" "log"
"log" "time"
tb "gopkg.in/tucnak/telebot.v2"
tb "gopkg.in/tucnak/telebot.v2"
) )
func main() { func main() {
@ -105,7 +107,7 @@ b.Handle(tb.OnQuery, func (q *tb.Query) {
There's dozens of supported endpoints (see package consts). Let me know There's dozens of supported endpoints (see package consts). Let me know
if you'd like to see some endpoint or endpoint idea implemented. This system if you'd like to see some endpoint or endpoint idea implemented. This system
is completely extensible, so I can introduce them without breaking is completely extensible, so I can introduce them without breaking
backwards-compatibity. backwards-compatibility.
## Poller ## Poller
Telebot doesn't really care how you provide it with incoming updates, as long Telebot doesn't really care how you provide it with incoming updates, as long
@ -273,7 +275,7 @@ it made sense for *any* Go struct to be editable as a Telegram message, to imple
// for edit operations. // for edit operations.
// //
// Use case: DB model struct for messages to-be // Use case: DB model struct for messages to-be
// edited with, say two collums: msg_id,chat_id // edited with, say two columns: msg_id,chat_id
// could easily implement MessageSig() making // could easily implement MessageSig() making
// instances of stored messages editable. // instances of stored messages editable.
type Editable interface { type Editable interface {

@ -119,7 +119,7 @@ type Update struct {
// Command represents a bot command. // Command represents a bot command.
type Command struct { type Command struct {
// Text is a aext of the command, 1-32 characters. // Text is a text of the command, 1-32 characters.
// Can contain only lowercase English letters, digits and underscores. // Can contain only lowercase English letters, digits and underscores.
Text string `json:"command"` Text string `json:"command"`
@ -196,7 +196,7 @@ func (b *Bot) ProcessUpdate(upd Update) {
// Commands // Commands
if m.Text != "" { if m.Text != "" {
// Filtering malicious messsages // Filtering malicious messages
if m.Text[0] == '\a' { if m.Text[0] == '\a' {
return return
} }
@ -494,7 +494,7 @@ func (b *Bot) handleMedia(m *Message) bool {
// //
// - *SendOptions (the actual object accepted by Telegram API) // - *SendOptions (the actual object accepted by Telegram API)
// - *ReplyMarkup (a component of SendOptions) // - *ReplyMarkup (a component of SendOptions)
// - Option (a shorcut flag for popular options) // - Option (a shortcut flag for popular options)
// - ParseMode (HTML, Markdown, etc) // - ParseMode (HTML, Markdown, etc)
// //
func (b *Bot) Send(to Recipient, what interface{}, options ...interface{}) (*Message, error) { func (b *Bot) Send(to Recipient, what interface{}, options ...interface{}) (*Message, error) {
@ -945,9 +945,9 @@ func (b *Bot) Notify(to Recipient, action ChatAction) error {
// requesting an address and the parameter is_flexible was specified. // requesting an address and the parameter is_flexible was specified.
// //
// Usage: // Usage:
// b.Ship(query) // OK // b.Ship(query) // OK
// b.Ship(query, options...) // OK with options // b.Ship(query, opts...) // OK with options
// b.Ship(query, "Oops!") // Error message // b.Ship(query, "Oops!") // Error message
// //
func (b *Bot) Ship(query *ShippingQuery, what ...interface{}) error { func (b *Bot) Ship(query *ShippingQuery, what ...interface{}) error {
params := map[string]string{ params := map[string]string{

@ -95,7 +95,7 @@ func (t *InlineButton) With(data string) *InlineButton {
} }
} }
// CallbackUnique returns InlineButto.Unique. // CallbackUnique returns InlineButton.Unique.
func (t *InlineButton) CallbackUnique() string { func (t *InlineButton) CallbackUnique() string {
return "\f" + t.Unique return "\f" + t.Unique
} }
@ -119,15 +119,15 @@ type Login struct {
// It needed to avoid InlineQueryChat and Login fields conflict. // It needed to avoid InlineQueryChat and Login fields conflict.
// If you have Login field in your button, InlineQueryChat must be skipped. // If you have Login field in your button, InlineQueryChat must be skipped.
func (t *InlineButton) MarshalJSON() ([]byte, error) { func (t *InlineButton) MarshalJSON() ([]byte, error) {
type InineButtonJSON InlineButton type InlineButtonJSON InlineButton
if t.Login != nil { if t.Login != nil {
return json.Marshal(struct { return json.Marshal(struct {
InineButtonJSON InlineButtonJSON
InlineQueryChat string `json:"switch_inline_query_current_chat,omitempty"` InlineQueryChat string `json:"switch_inline_query_current_chat,omitempty"`
}{ }{
InineButtonJSON: InineButtonJSON(*t), InlineButtonJSON: InlineButtonJSON(*t),
}) })
} }
return json.Marshal(InineButtonJSON(*t)) return json.Marshal(InlineButtonJSON(*t))
} }

@ -6,7 +6,7 @@ package telebot
// for edit operations. // for edit operations.
// //
// Use case: DB model struct for messages to-be // Use case: DB model struct for messages to-be
// edited with, say two collums: msg_id,chat_id // edited with, say two columns: msg_id,chat_id
// could easily implement MessageSig() making // could easily implement MessageSig() making
// instances of stored messages editable. // instances of stored messages editable.
type Editable interface { type Editable interface {

@ -76,7 +76,7 @@ var (
ErrWrongFileIDCharacter = NewAPIError(400, "Bad Request: wrong remote file id specified: Wrong character in the string") ErrWrongFileIDCharacter = NewAPIError(400, "Bad Request: wrong remote file id specified: Wrong character in the string")
ErrWrongFileIDPadding = NewAPIError(400, "Bad Request: wrong remote file id specified: Wrong padding in the string") ErrWrongFileIDPadding = NewAPIError(400, "Bad Request: wrong remote file id specified: Wrong padding in the string")
ErrFailedImageProcess = NewAPIError(400, "Bad Request: IMAGE_PROCESS_FAILED", "Image process failed") ErrFailedImageProcess = NewAPIError(400, "Bad Request: IMAGE_PROCESS_FAILED", "Image process failed")
ErrInvaliadStickerset = NewAPIError(400, "Bad Request: STICKERSET_INVALID", "Stickerset is invalid") ErrInvalidStickerSet = NewAPIError(400, "Bad Request: STICKERSET_INVALID", "Stickerset is invalid")
ErrBadPollOptions = NewAPIError(400, "Bad Request: expected Array of String as options") ErrBadPollOptions = NewAPIError(400, "Bad Request: expected Array of String as options")
// No rights errors // No rights errors
@ -164,8 +164,8 @@ func ErrByDescription(s string) error {
return ErrWrongFileIDPadding return ErrWrongFileIDPadding
case ErrFailedImageProcess.ʔ(): case ErrFailedImageProcess.ʔ():
return ErrFailedImageProcess return ErrFailedImageProcess
case ErrInvaliadStickerset.ʔ(): case ErrInvalidStickerSet.ʔ():
return ErrInvaliadStickerset return ErrInvalidStickerSet
default: default:
return nil return nil
} }

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
) )
// Option is a shorcut flag type for certain message features // Option is a shortcut flag type for certain message features
// (so-called options). It means that instead of passing // (so-called options). It means that instead of passing
// fully-fledged SendOptions* to Send(), you can use these // fully-fledged SendOptions* to Send(), you can use these
// flags instead. // flags instead.
@ -93,7 +93,7 @@ type ReplyMarkup struct {
// Requests clients to remove the reply keyboard. // Requests clients to remove the reply keyboard.
// //
// Dafaults to false. // Defaults to false.
ReplyKeyboardRemove bool `json:"remove_keyboard,omitempty"` ReplyKeyboardRemove bool `json:"remove_keyboard,omitempty"`
// Use this param if you want to force reply from // Use this param if you want to force reply from
@ -106,17 +106,17 @@ type ReplyMarkup struct {
Selective bool `json:"selective,omitempty"` Selective bool `json:"selective,omitempty"`
} }
func (og *ReplyMarkup) copy() *ReplyMarkup { func (r *ReplyMarkup) copy() *ReplyMarkup {
cp := *og cp := *r
cp.ReplyKeyboard = make([][]ReplyButton, len(og.ReplyKeyboard)) cp.ReplyKeyboard = make([][]ReplyButton, len(r.ReplyKeyboard))
for i, row := range og.ReplyKeyboard { for i, row := range r.ReplyKeyboard {
cp.ReplyKeyboard[i] = make([]ReplyButton, len(row)) cp.ReplyKeyboard[i] = make([]ReplyButton, len(row))
copy(cp.ReplyKeyboard[i], row) copy(cp.ReplyKeyboard[i], row)
} }
cp.InlineKeyboard = make([][]InlineButton, len(og.InlineKeyboard)) cp.InlineKeyboard = make([][]InlineButton, len(r.InlineKeyboard))
for i, row := range og.InlineKeyboard { for i, row := range r.InlineKeyboard {
cp.InlineKeyboard[i] = make([]InlineButton, len(row)) cp.InlineKeyboard[i] = make([]InlineButton, len(row))
copy(cp.InlineKeyboard[i], row) copy(cp.InlineKeyboard[i], row)
} }

@ -44,7 +44,7 @@ func (p *Poll) IsRegular() bool {
return p.Type == PollRegular return p.Type == PollRegular
} }
// IsQuiz says wheter poll is a quiz. // IsQuiz says whether poll is a quiz.
func (p *Poll) IsQuiz() bool { func (p *Poll) IsQuiz() bool {
return p.Type == PollQuiz return p.Type == PollQuiz
} }

@ -37,7 +37,7 @@ type WebhookEndpoint struct {
// add the Webhook to a http-mux. // add the Webhook to a http-mux.
type Webhook struct { type Webhook struct {
Listen string `json:"url"` Listen string `json:"url"`
MaxConnections int `json:"max_conecctions"` MaxConnections int `json:"max_connections"`
AllowedUpdates []string `json:"allowed_updates"` AllowedUpdates []string `json:"allowed_updates"`
// (WebhookInfo) // (WebhookInfo)

Loading…
Cancel
Save