{"action":"created","issue":{"url":"https://api.github.com/repos/LukasKalbertodt/telegram-bot/issues/16","labels_url":"https://api.github.com/repos/LukasKalbertodt/telegram-bot/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/LukasKalbertodt/telegram-bot/issues/16/comments","events_url":"https://api.github.com/repos/LukasKalbertodt/telegram-bot/issues/16/events","html_url":"https://github.com/LukasKalbertodt/telegram-bot/pull/16","id":101637535,"number":16,"title":"Added multipart support, send files methods and some updates and changes in the API, details in the description :)","user":{"login":"rockneurotiko","id":1377584,"avatar_url":"https://avatars.githubusercontent.com/u/1377584?v=3","gravatar_id":"","url":"https://api.github.com/users/rockneurotiko","html_url":"https://github.com/rockneurotiko","followers_url":"https://api.github.com/users/rockneurotiko/followers","following_url":"https://api.github.com/users/rockneurotiko/following{/other_user}","gists_url":"https://api.github.com/users/rockneurotiko/gists{/gist_id}","starred_url":"https://api.github.com/users/rockneurotiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rockneurotiko/subscriptions","organizations_url":"https://api.github.com/users/rockneurotiko/orgs","repos_url":"https://api.github.com/users/rockneurotiko/repos","events_url":"https://api.github.com/users/rockneurotiko/events{/privacy}","received_events_url":"https://api.github.com/users/rockneurotiko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-18T11:45:31Z","updated_at":"2015-08-25T13:45:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/LukasKalbertodt/telegram-bot/pulls/16","html_url":"https://github.com/LukasKalbertodt/telegram-bot/pull/16","diff_url":"https://github.com/LukasKalbertodt/telegram-bot/pull/16.diff","patch_url":"https://github.com/LukasKalbertodt/telegram-bot/pull/16.patch"},"body":"# Changes\r\n\r\nThis is a summary with all the changes (I think that I didn't missed any change :smile:  )\r\n\r\n## mod.rs\r\n\r\n- `try_field` macro: Instead of creating a closure and passing it to Decodable::decode, apply that function directly\r\n- `Response`: Added `error_code: Option<Integer>`, this is a parameter that you get if something went wrong\r\n- `Audio`: Added performer and title, both `Option<String>`, this was added the 15 August in the API\r\n- `Voice`: Added Voice type, this was added the 15 August in the API\r\n- `Message`: The 30 july they made some changes in the Api, this is one of them, adding an optional `caption` field to the Message structure. The 15 August they added the optional `voice` field.\r\n- `MessageType` enum: Changed `Photo(PhotoSize)` for `Photo(Vec<PhotoSize>)` because you receive a list of images, added `Voice(Voice)` because of the 15 August changes.\r\n- `maybe_field` macro: same as try\\_field macro\r\n- `impl Decodable for MessageType`: Added the `file` optional field missing and new `voice` optional field, and the same as try_field macro.\r\n- `Document` and `Sticker`: The 30 july they changed the thumb field to be optional\r\n- `Video`: The 30 july they changed the thumb field to be optional and removed the caption field (they moved it to Message)\r\n\r\nAnd the most important to me:\r\n- `Update` struct: Changed `message` field from `Optional<Message>` to just `Message`, because in the API the message is not optional, if you are receiving an Update, it will have a Message for sure, I don't know why you have it Optional :S\r\n\r\n## lib.rs\r\n\r\n- Initial documentation: Changed the example, because I removed the `Optional` from the message, so you don't have to check it with the `if let Some(m) = u.message {`, if you are there, you know that you have a message for sure.\r\n- `SendPath` enum that is used by the multipart to differentiate sending a local file or a file id, because it's sended differently.\r\n- `RequestType` enum that differentiate between a Post request or a Multipart request encapsulating a `SendPath`\r\n- Implemented `Clone` trait for `Api` struct, I don't know if you like it, but I'm building kind-of framework up to this library and I find it really useful to have the clone implemented ^^\r\n- `&mut self` for `&self`, I changed this because I don't really know why you need mutable reference in the methods, you are not mutating at all, and for what I readed it's better use a reference than a mutable reference, but maybe there are something that I'm missing, maybe you can explain me why you are using &mut self ^^\r\n- All the `send_request` now uses the RequestType\r\n- Implement `send_photo`, `send_audio`, `send_voice`, `send_document`, `send_sticker` and `send_video`, they all accept and String for path, and \"detect\" if it's a local file or an ID, with the `detect_file_or_id` function, I really love this, but maybe you prefer to accept directly what kind is or some other thing, this is what I do in my Go library, that's why I made it this way :smile:\r\n- `detect_file_or_id` \"detect\" if a given string is a path or an ID, first check if the string have a dot (the telegram API don't accept files without extension, I saw it testing the API some time ago, and the IDs don't have dots), if have it, see if it's really a file, if it is, return the SendPath::File, and if any of the checks fail, it will return a SendPath::Id. For example, if the path don't exist, but it's not a real file id, it will return a SendPath::Id, and the telegram server will return an error saying that the id is not valid\r\n- `request` dispatch depending of Post or Multipart.\r\n- `multipart_request` do a multipart-form request :smile:\r\n- `post_request` I changed the GET request for a POST request, the main reason is because if you use GET in sendMessage, there are size limit in the GET request and probably can't send a long message, so it's better use POST in sendMessage, and if you use POST in one, is better to use it in everyone.\r\n- Listener: sending the \"getUpdate\" request now is done using an auxiliar function.\r\n\r\n## error.rs\r\n\r\n- Added `InvalidPath(String)` error that is used in the `multipart_request` method when trying to access the path of a file and it's not valid.\r\n\r\n## examples/*.rs\r\n\r\n- I removed the Option in the field message in Update struct, so now there are not need to use `if let Some(m) = u.message {`\r\n- I changed the methods to take `&self` instead of `&mut self`, so now you don't need to declare the api as mutable (`let mut api` for `let api`)\r\n\r\n## Cargo.tml\r\n\r\n- Added multipart dependency\r\n\r\n## README.md\r\n\r\n- Checked the \"sending files\" TODO\r\n"},"comment":{"url":"https://api.github.com/repos/LukasKalbertodt/telegram-bot/issues/comments/134590813","html_url":"https://github.com/LukasKalbertodt/telegram-bot/pull/16#issuecomment-134590813","issue_url":"https://api.github.com/repos/LukasKalbertodt/telegram-bot/issues/16","id":134590813,"user":{"login":"rockneurotiko","id":1377584,"avatar_url":"https://avatars.githubusercontent.com/u/1377584?v=3","gravatar_id":"","url":"https://api.github.com/users/rockneurotiko","html_url":"https://github.com/rockneurotiko","followers_url":"https://api.github.com/users/rockneurotiko/followers","following_url":"https://api.github.com/users/rockneurotiko/following{/other_user}","gists_url":"https://api.github.com/users/rockneurotiko/gists{/gist_id}","starred_url":"https://api.github.com/users/rockneurotiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rockneurotiko/subscriptions","organizations_url":"https://api.github.com/users/rockneurotiko/orgs","repos_url":"https://api.github.com/users/rockneurotiko/repos","events_url":"https://api.github.com/users/rockneurotiko/events{/privacy}","received_events_url":"https://api.github.com/users/rockneurotiko/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T13:45:09Z","updated_at":"2015-08-25T13:45:09Z","body":"I've been talking with the Bot Support about the optional Message. They asked the developers and here are the answer:\r\n\r\n```\r\nJust got a reply: for the moment an update can only contain a message, but this will not necessarily be so in the future. We may add additional types and this will help backward compatibility.\r\n```"}}