diff --git a/delete_chat_photo.go b/delete_chat_photo.go index 77861ec..d5208e9 100644 --- a/delete_chat_photo.go +++ b/delete_chat_photo.go @@ -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 diff --git a/delete_message.go b/delete_message.go index bb7ee27..38b647a 100644 --- a/delete_message.go +++ b/delete_message.go @@ -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 diff --git a/delete_sticker_from_set.go b/delete_sticker_from_set.go index dabee98..44be654 100644 --- a/delete_sticker_from_set.go +++ b/delete_sticker_from_set.go @@ -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 diff --git a/export_chat_invite_link.go b/export_chat_invite_link.go index 6bb4d71..ef445b5 100644 --- a/export_chat_invite_link.go +++ b/export_chat_invite_link.go @@ -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 diff --git a/get_chat.go b/get_chat.go index 5fd55b5..31a1dc4 100644 --- a/get_chat.go +++ b/get_chat.go @@ -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) diff --git a/get_chat_administrators.go b/get_chat_administrators.go index ecf9b55..1c1cc7b 100644 --- a/get_chat_administrators.go +++ b/get_chat_administrators.go @@ -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) diff --git a/get_chat_member.go b/get_chat_member.go index 9e0fd46..1f40ac4 100644 --- a/get_chat_member.go +++ b/get_chat_member.go @@ -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) diff --git a/get_chat_members_count.go b/get_chat_members_count.go index 502b960..b4ef237 100644 --- a/get_chat_members_count.go +++ b/get_chat_members_count.go @@ -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 diff --git a/leave_chat.go b/leave_chat.go index 821d799..6d13def 100644 --- a/leave_chat.go +++ b/leave_chat.go @@ -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 diff --git a/send_chat_action.go b/send_chat_action.go index cd5fa35..89313c2 100644 --- a/send_chat_action.go +++ b/send_chat_action.go @@ -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 diff --git a/set_chat_title.go b/set_chat_title.go index 730e630..8a2cf60 100644 --- a/set_chat_title.go +++ b/set_chat_title.go @@ -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 diff --git a/set_sticker_position_in_set.go b/set_sticker_position_in_set.go index 5b41160..6020546 100644 --- a/set_sticker_position_in_set.go +++ b/set_sticker_position_in_set.go @@ -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 diff --git a/unban_chat_member.go b/unban_chat_member.go index 920140c..058359c 100644 --- a/unban_chat_member.go +++ b/unban_chat_member.go @@ -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 diff --git a/unpin_chat_message.go b/unpin_chat_message.go index b01e79e..2dcb37b 100644 --- a/unpin_chat_message.go +++ b/unpin_chat_message.go @@ -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