From 2dcee09927a39b33b796034d31afd32f76e86c10 Mon Sep 17 00:00:00 2001 From: Shmulik <29735690+Shmulik-Kravitz@users.noreply.github.com> Date: Fri, 12 Jun 2020 14:18:27 +0300 Subject: [PATCH] Fix `chat_id` needs to accept type of int and string --- lib/src/telegram/telegram.dart | 98 +++++++++++++++++----------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/lib/src/telegram/telegram.dart b/lib/src/telegram/telegram.dart index 4babb51..1805c24 100644 --- a/lib/src/telegram/telegram.dart +++ b/lib/src/telegram/telegram.dart @@ -137,7 +137,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendmessage /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendMessage(int chat_id, String text, + Future sendMessage(dynamic chat_id, String text, {String parse_mode, bool disable_web_page_preview, bool disable_notification, @@ -161,7 +161,7 @@ class Telegram { /// https://core.telegram.org/bots/api#forwardmessage /// /// [Message]: https://core.telegram.org/bots/api#message - Future forwardMessage(int chat_id, int from_chat_id, int message_id, + Future forwardMessage(dynamic chat_id, int from_chat_id, int message_id, {bool disable_notification}) async { var requestUrl = '${_baseUrl}${_token}/forwardMessage'; var body = { @@ -178,7 +178,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendphoto /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendPhoto(int chat_id, dynamic photo, + Future sendPhoto(dynamic chat_id, dynamic photo, {String caption, String parse_mode, bool disable_notification, @@ -223,7 +223,7 @@ class Telegram { /// /// [Message]: https://core.telegram.org/bots/api#message /// [sendVoice]: https://core.telegram.org/bots/api#sendvoice - Future sendAudio(int chat_id, dynamic audio, + Future sendAudio(dynamic chat_id, dynamic audio, {String caption, String parse_mode, int duration, @@ -299,7 +299,7 @@ class Telegram { /// https://core.telegram.org/bots/api#senddocument /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendDocument(int chat_id, dynamic document, + Future sendDocument(dynamic chat_id, dynamic document, {dynamic thumb, String caption, String parse_mode, @@ -373,7 +373,7 @@ class Telegram { /// /// [Document]: https://core.telegram.org/bots/api#document /// [Message]: https://core.telegram.org/bots/api#message - Future sendVideo(int chat_id, dynamic video, + Future sendVideo(dynamic chat_id, dynamic video, {int duration, int width, int height, @@ -452,7 +452,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendanimation /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendAnimation(int chat_id, dynamic animation, + Future sendAnimation(dynamic chat_id, dynamic animation, {int duration, int width, int height, @@ -535,7 +535,7 @@ class Telegram { /// [Audio]: https://core.telegram.org/bots/api#audio /// [Document]: https://core.telegram.org/bots/api#document /// [Message]: https://core.telegram.org/bots/api#message - Future sendVoice(int chat_id, dynamic voice, + Future sendVoice(dynamic chat_id, dynamic voice, {String caption, String parse_mode, int duration, @@ -577,7 +577,7 @@ class Telegram { /// /// [v.4.0]: https://telegram.org/blog/video-messages-and-telescope /// [messages]: https://core.telegram.org/bots/api#message - Future sendVideoNote(int chat_id, dynamic video_note, + Future sendVideoNote(dynamic chat_id, dynamic video_note, {int duration, int length, dynamic thumb, @@ -651,7 +651,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendmediagroup /// /// [messages]: https://core.telegram.org/bots/api#message - Future> sendMediaGroup(int chat_id, List media, + Future> sendMediaGroup(dynamic chat_id, List media, {bool disable_notification, int reply_to_message_id}) async { var requestUrl = '${_baseUrl}${_token}/sendMediaGroup'; var body = { @@ -670,7 +670,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendlocation /// /// [messages]: https://core.telegram.org/bots/api#message - Future sendLocation(int chat_id, double latitude, double longitude, + Future sendLocation(dynamic chat_id, double latitude, double longitude, {int live_period, bool disable_notification, int reply_to_message_id, @@ -700,7 +700,7 @@ class Telegram { /// [stopMessageLiveLocation]: https://core.telegram.org/bots/api#stopmessagelivelocation /// [Message]: https://core.telegram.org/bots/api#message Future editMessageLiveLocation(double latitude, double longitude, - {int chat_id, + {dynamic chat_id, int message_id, String inline_message_id, ReplyMarkup reply_markup}) async { @@ -730,7 +730,7 @@ class Telegram { /// [inline bots]: https://core.telegram.org/bots/api#inline-mode /// [Message]: https://core.telegram.org/bots/api#message Future stopMessageLiveLocation( - {int chat_id, + {dynamic chat_id, int message_id, String inline_message_id, ReplyMarkup reply_markup}) async { @@ -753,7 +753,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendvenue /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendVenue(int chat_id, double latitude, double longitude, + Future sendVenue(dynamic chat_id, double latitude, double longitude, String title, String address, {String foursquare_id, String foursquare_type, @@ -782,7 +782,7 @@ class Telegram { /// /// [Message]: https://core.telegram.org/bots/api#message Future sendContact( - int chat_id, String phone_number, String first_name, + dynamic chat_id, String phone_number, String first_name, {String last_name, String vcard, bool disable_notification, @@ -808,7 +808,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendpoll /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendPoll(int chat_id, String question, List options, + Future sendPoll(dynamic chat_id, String question, List options, {bool is_anonymous, String type, bool allows_multiple_answers, @@ -845,7 +845,7 @@ class Telegram { /// Use this method to send a dice, which will have a random value from 1 to 6. On success, /// the sent Message is returned. (Yes, we're aware of the “proper” singular of die. /// But it's awkward, and we decided to help it change. One dice at a time!) - Future sendDice(int chat_id, + Future sendDice(dynamic chat_id, {String emoji, bool disable_notification, int reply_to_message_id, @@ -878,7 +878,7 @@ class Telegram { /// /// [ImageBot]: https://t.me/imagebot /// [sendChatAction]: https://core.telegram.org/bots/api#sendchataction - Future sendChatAction(int chat_id, String action) async { + Future sendChatAction(dynamic chat_id, String action) async { var requestUrl = '${_baseUrl}${_token}/sendChatAction'; var body = {'chat_id': chat_id, 'action': action}; return await _client.httpPost(requestUrl, body: body); @@ -936,7 +936,7 @@ class Telegram { /// https://core.telegram.org/bots/api#kickchatmember /// /// [unbanned]: https://core.telegram.org/bots/api#unbanchatmember - Future kickChatMember(int chat_id, int user_id, + Future kickChatMember(dynamic chat_id, int user_id, {int until_date}) async { var requestUrl = '${_baseUrl}${_token}/kickChatMember'; var body = { @@ -953,7 +953,7 @@ class Telegram { /// Returns *True* on success. /// /// https://core.telegram.org/bots/api#unbanchatmember - Future unbanChatMember(int chat_id, int user_id) async { + Future unbanChatMember(dynamic chat_id, int user_id) async { var requestUrl = '${_baseUrl}${_token}/unbanChatMember'; var body = { 'chat_id': chat_id, @@ -972,7 +972,7 @@ class Telegram { /// /// This method now takes the new user permissions in a single argument of the type *ChatPermissions*. /// The old way of passing parameters will keep working for a while for backward compatibility. - Future restrictChatMember(int chat_id, int user_id, + Future restrictChatMember(dynamic chat_id, int user_id, {ChatPermissions permissions, int until_date, bool can_send_messages, @@ -999,7 +999,7 @@ class Telegram { /// Pass *False* for all boolean parameters to demote a user. Returns *True* on success. /// /// https://core.telegram.org/bots/api#promotechatmember - Future promoteChatMember(int chat_id, int user_id, + Future promoteChatMember(dynamic chat_id, int user_id, {bool can_change_info, bool can_post_messages, bool can_edit_messages, @@ -1025,7 +1025,7 @@ class Telegram { } Future setChatAdministratorCustomTitle( - int chat_id, int user_id, String custom_title) { + dynamic chat_id, int user_id, String custom_title) { var requestUrl = '${_baseUrl}${_token}/setChatAdministratorCustomTitle'; var body = { 'chat_id': chat_id, @@ -1039,7 +1039,7 @@ class Telegram { /// The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. /// Returns *True* on success. Future setChatPermissions( - int chat_id, ChatPermissions permissions) async { + dynamic chat_id, ChatPermissions permissions) async { var requestUrl = '${_baseUrl}${_token}/setChatPermissions'; var body = { 'chat_id': chat_id, @@ -1054,7 +1054,7 @@ class Telegram { /// admin rights. Returns the invite link as *String* on success. /// /// https://core.telegram.org/bots/api#exportchatinvitelink - Future exportChatInviteLink(int chat_id) async { + Future exportChatInviteLink(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/exportChatInviteLink'; var body = {'chat_id': chat_id}; return await _client.httpPost(requestUrl, body: body); @@ -1069,7 +1069,7 @@ class Telegram { /// this method will only work if the ‘All Members Are Admins’ setting is off in the target group. /// /// https://core.telegram.org/bots/api#setchatphoto - Future setChatPhoto(int chat_id, io.File photo) async { + Future setChatPhoto(dynamic chat_id, io.File photo) async { var requestUrl = '${_baseUrl}${_token}/setChatPhoto'; var body = {'chat_id': chat_id}; // filename cannot be empty to post to Telegram server @@ -1089,7 +1089,7 @@ class Telegram { /// this method will only work if the ‘All Members Are Admins’ setting is off in the target group. /// /// https://core.telegram.org/bots/api#deletechatphoto - Future deleteChatPhoto(int chat_id) async { + Future deleteChatPhoto(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/deleteChatPhoto'; var body = {'chat_id': chat_id}; return await _client.httpPost(requestUrl, body: body); @@ -1104,7 +1104,7 @@ class Telegram { /// this method will only work if the ‘All Members Are Admins’ setting is off in the target group. /// /// https://core.telegram.org/bots/api#setchattitle - Future setChatTitle(int chat_id, String title) async { + Future setChatTitle(dynamic chat_id, String title) async { var requestUrl = '${_baseUrl}${_token}/setChatTitle'; var body = { 'chat_id': chat_id, @@ -1118,7 +1118,7 @@ class Telegram { /// admin rights. Returns *True* on success. /// /// https://core.telegram.org/bots/api#setchatdescription - Future setChatDescription(int chat_id, {String description}) async { + Future setChatDescription(dynamic chat_id, {String description}) async { var requestUrl = '${_baseUrl}${_token}/setChatDescription'; var body = { 'chat_id': chat_id, @@ -1133,7 +1133,7 @@ class Telegram { /// in the channel. Returns *True* on success. /// /// https://core.telegram.org/bots/api#pinchatmessage - Future pinChatMessage(int chat_id, int message_id, + Future pinChatMessage(dynamic chat_id, int message_id, {bool disable_notification}) async { var requestUrl = '${_baseUrl}${_token}/pinChatMessage'; var body = { @@ -1150,7 +1150,7 @@ class Telegram { /// in the channel. Returns *True* on success. /// /// https://core.telegram.org/bots/api#unpinchatmessage - Future unpinChatMessage(int chat_id) async { + Future unpinChatMessage(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/unpinChatMessage'; var body = {'chat_id': chat_id}; return await _client.httpPost(requestUrl, body: body); @@ -1159,7 +1159,7 @@ class Telegram { /// Use this method for your bot to leave a group, supergroup or channel. Returns *True* on success. /// /// https://core.telegram.org/bots/api#leavechat - Future leaveChat(int chat_id) async { + Future leaveChat(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/leaveChat'; var body = {'chat_id': chat_id}; return await _client.httpPost(requestUrl, body: body); @@ -1173,7 +1173,7 @@ class Telegram { /// https://core.telegram.org/bots/api#getchat /// /// [Chat]: https://core.telegram.org/bots/api#chat - Future getChat(int chat_id) async { + Future getChat(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/getChat'; var body = {'chat_id': chat_id}; return Chat.fromJson(await _client.httpPost(requestUrl, body: body)); @@ -1188,7 +1188,7 @@ class Telegram { /// https://core.telegram.org/bots/api#getchatadministrators /// /// [ChatMember]: https://core.telegram.org/bots/api#chatmember - Future> getChatAdministrators(int chat_id) async { + Future> getChatAdministrators(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/getChatAdministrators'; var body = {'chat_id': chat_id}; return (await _client.httpPost(requestUrl, body: body)) @@ -1199,7 +1199,7 @@ class Telegram { /// Use this method to get the number of members in a chat. Returns *Int* on success. /// /// https://core.telegram.org/bots/api#getchatmemberscount - Future getChatMembersCount(int chat_id) async { + Future getChatMembersCount(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/getChatMembersCount'; var body = {'chat_id': chat_id}; return await _client.httpPost(requestUrl, body: body); @@ -1211,7 +1211,7 @@ class Telegram { /// https://core.telegram.org/bots/api#getchatmember /// /// [ChatMember]: https://core.telegram.org/bots/api#chatmember - Future getChatMember(int chat_id, int user_id) async { + Future getChatMember(dynamic chat_id, int user_id) async { var requestUrl = '${_baseUrl}${_token}/getChatMember'; var body = { 'chat_id': chat_id, @@ -1230,7 +1230,7 @@ class Telegram { /// https://core.telegram.org/bots/api#setchatstickerset /// /// [getChat]: https://core.telegram.org/bots/api#getchat - Future setChatStickerSet(int chat_id, String sticker_set_name) async { + Future setChatStickerSet(dynamic chat_id, String sticker_set_name) async { var requestUrl = '${_baseUrl}${_token}/setChatStickerSet'; var body = { 'chat_id': chat_id, @@ -1249,7 +1249,7 @@ class Telegram { /// https://core.telegram.org/bots/api#deletechatstickerset /// /// [getChat]: https://core.telegram.org/bots/api#getchat - Future deleteChatStickerSet(int chat_id) async { + Future deleteChatStickerSet(dynamic chat_id) async { var requestUrl = '${_baseUrl}${_token}/deleteChatStickerSet'; var body = {'chat_id': chat_id}; return await _client.httpPost(requestUrl, body: body); @@ -1308,7 +1308,7 @@ class Telegram { /// [inline bots]: https://core.telegram.org/bots/api#inline-mode /// [Message]: https://core.telegram.org/bots/api#message Future editMessageText(String text, - {int chat_id, + {dynamic chat_id, int message_id, String inline_message_id, String parse_mode, @@ -1347,7 +1347,7 @@ class Telegram { /// [inline bots]: https://core.telegram.org/bots/api#inline-mode /// [Message]: https://core.telegram.org/bots/api#message Future editMessageCaption( - {int chat_id, + {dynamic chat_id, int message_id, String inline_message_id, String caption, @@ -1387,7 +1387,7 @@ class Telegram { /// /// [Message]: https://core.telegram.org/bots/api#message Future editMessageMedia( - {int chat_id, + {dynamic chat_id, int message_id, String inline_message_id, InputMedia media, @@ -1425,7 +1425,7 @@ class Telegram { /// [inline bots]: https://core.telegram.org/bots/api#inline-mode /// [Message]: https://core.telegram.org/bots/api#message Future editMessageReplyMarkup( - {int chat_id, + {dynamic chat_id, int message_id, String inline_message_id, InlineKeyboardMarkup reply_markup}) async { @@ -1456,7 +1456,7 @@ class Telegram { /// /// [Poll]: https://core.telegram.org/bots/api#poll Future stopPoll( - int chat_id, int message_id, InlineKeyboardMarkup reply_markup) async { + dynamic chat_id, int message_id, InlineKeyboardMarkup reply_markup) async { var requestUrl = '${_baseUrl}${_token}/stopPoll'; var body = { 'chat_id': chat_id, @@ -1476,7 +1476,7 @@ class Telegram { /// Returns *True* on success. /// /// https://core.telegram.org/bots/api#deletemessage - Future deleteMessage(int chat_id, int message_id) async { + Future deleteMessage(dynamic chat_id, int message_id) async { var requestUrl = '${_baseUrl}${_token}/deleteMessage'; var body = { 'chat_id': chat_id, @@ -1490,7 +1490,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendsticker /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendSticker(int chat_id, dynamic sticker, + Future sendSticker(dynamic chat_id, dynamic sticker, {bool disable_notification, int reply_to_message_id, ReplyMarkup reply_markup}) async { @@ -1732,7 +1732,7 @@ class Telegram { /// /// [Message]: https://core.telegram.org/bots/api#message Future sendInvoice( - int chat_id, + dynamic chat_id, String title, String description, String payload, @@ -1858,7 +1858,7 @@ class Telegram { /// https://core.telegram.org/bots/api#sendgame /// /// [Message]: https://core.telegram.org/bots/api#message - Future sendGame(int chat_id, String game_short_name, + Future sendGame(dynamic chat_id, String game_short_name, {bool disable_notification, int reply_to_message_id, InlineKeyboardMarkup reply_markup}) async { @@ -1884,7 +1884,7 @@ class Telegram { Future setGameScore(int user_id, int score, {bool force, bool disable_edit_message, - int chat_id, + dynamic chat_id, int message_id, String inline_message_id}) async { if (inline_message_id == null && (chat_id == null || message_id == null)) { @@ -1917,7 +1917,7 @@ class Telegram { /// /// [GameHighScore]: https://core.telegram.org/bots/api#gamehighscore Future> getGameHighScores(int user_id, - {int chat_id, int message_id, String inline_message_id}) async { + {dynamic chat_id, int message_id, String inline_message_id}) async { if (inline_message_id == null && (chat_id == null || message_id == null)) { return Future.error(TelegramException( 'Require either \'chat_id\' and \'message_id\', or \'inline_message_id\''));