1
0

🐛 ✏️ Fixed typos

This commit is contained in:
Maxim Lebedev 2017-09-05 01:54:28 +05:00
parent eb5dc94ead
commit d99fa961cb
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
14 changed files with 57 additions and 32 deletions

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -10,18 +13,18 @@ import (
// Note: In regular groups (non-supergroups), this method will only work if the All Members Are Admins setting is off in the target group.
func (bot *Bot) DeleteChatPhoto(chat interface{}) (bool, error) {
var args http.Args
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return false, errors.New(errorInt64OrString)
}
resp, err := bot.post("deleteChatPhoto", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -1,6 +1,7 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
@ -18,18 +19,18 @@ func (bot *Bot) DeleteMessage(chat interface{}, message int) (bool, error) {
var args http.Args
args.Add("message_id", strconv.Itoa(message)) // Identifier of the message to delete
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return false, errors.New(errorInt64OrString)
}
resp, err := bot.post("deleteMessage", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -12,7 +12,7 @@ func (bot *Bot) DeleteStickerFromSet(sticker string) (bool, error) {
resp, err := bot.post("deleteStickerFromSet", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -8,18 +11,18 @@ import (
// ExportChatInviteLink export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success.
func (bot *Bot) ExportChatInviteLink(chat interface{}) (string, error) {
var args http.Args
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @username)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return "", errors.New(errorInt64OrString)
}
resp, err := bot.post("exportChatInviteLink", &args)
if err != nil {
return nil, err
return "", err
}
var data string

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -8,7 +11,7 @@ import (
// GetChat get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
func (bot *Bot) GetChat(chat interface{}) (*Chat, error) {
var args http.Args
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -8,7 +11,7 @@ import (
// GetChatAdministrators get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
func (bot *Bot) GetChatAdministrators(chat interface{}) (*[]ChatMember, error) {
var args http.Args
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)

View File

@ -13,7 +13,7 @@ func (bot *Bot) GetChatMember(chat interface{}, user int) (*ChatMember, error) {
var args http.Args
args.Add("user_id", strconv.Itoa(user)) // Unique identifier of the target user
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -8,18 +11,18 @@ import (
// GetChatMembersCount get the number of members in a chat. Returns Int on success.
func (bot *Bot) GetChatMembersCount(chat interface{}) (int, error) {
var args http.Args
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return 0, errors.New(errorInt64OrString)
}
resp, err := bot.get("getChatMembersCount", &args)
if err != nil {
return nil, err
return 0, err
}
var data int

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -8,18 +11,18 @@ import (
// LeaveChat leave a group, supergroup or channel. Returns True on success.
func (bot *Bot) LeaveChat(chat interface{}) (bool, error) {
var args http.Args
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return false, errors.New(errorInt64OrString)
}
resp, err := bot.post("leaveChat", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -28,18 +28,18 @@ func (bot *Bot) SendChatAction(chat interface{}, action string) (bool, error) {
var args http.Args
args.Add("action", action) // Type of action to broadcast
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return false, errors.New(errorInt64OrString)
}
resp, err := bot.post("sendChatAction", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -12,18 +15,18 @@ func (bot *Bot) SetChatTitle(chat interface{}, title string) (bool, error) {
var args http.Args
args.Add("title", title) // New chat title, 1-255 characters
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return false, errors.New(errorInt64OrString)
}
resp, err := bot.post("setChatTitle", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -15,7 +15,7 @@ func (bot *Bot) SetStickerPositionInSet(sticker string, position int) (bool, err
resp, err := bot.post("setStickerPositionInSet", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -13,18 +13,18 @@ func (bot *Bot) UnbanChatMember(chat interface{}, user int) (bool, error) {
var args http.Args
args.Add("user_id", strconv.Itoa(user)) // Unique identifier of the target user
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @username)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return false, errors.New(errorInt64OrString)
}
resp, err := bot.post("unbanChatMember", &args)
if err != nil {
return nil, err
return false, err
}
var data bool

View File

@ -1,6 +1,9 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
@ -8,18 +11,18 @@ import (
// UnpinChatMessage unpin a message in a supergroup chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
func (bot *Bot) UnpinChatMessage(chat interface{}) (bool, error) {
var args http.Args
switch id := chatID.(type) {
switch id := chat.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @supergroupusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
return false, errors.New(errorInt64OrString)
}
resp, err := bot.post("unpinChatMessage", &args)
if err != nil {
return nil, err
return false, err
}
var data bool