Commit graph

159 commits

Author SHA1 Message Date
Waffle Maybe
95f519073b
Merge pull request #208 from SpriteOvO/user-mention-shortcut
Add method `MessageEntity::user_mention`
2022-04-24 20:51:49 +04:00
Sprite
f5f1fa974f Update changelog 2022-04-24 08:20:26 +08:00
Hirrolot
1a12dd2388
Merge branch 'master' into tune-markups 2022-04-24 01:10:08 +06:00
Hirrolot
daa43e4dbf Revert "Fix indentation in CHANGELOG.md"
This reverts commit 1229d783e3.
2022-04-24 00:45:57 +06:00
Hirrolot
1229d783e3
Fix indentation in CHANGELOG.md 2022-04-24 00:44:21 +06:00
Hirrolot
9440609a3c Accept Into<String> in InlineKeyboardButton's methods 2022-04-24 00:02:28 +06:00
Hirrolot
012fb94044 Accept IntoIterator in KeyboardMarkup::append_row 2022-04-23 23:57:42 +06:00
Maybe Waffle
852feaeda4 Update changelog and stuff 2022-04-21 20:15:31 +04:00
Maybe Waffle
f98472d798 Release v0.5.1 2022-04-18 14:03:50 +04:00
Hirrolot
9ee3b90988 Update the changelog 2022-04-18 15:52:22 +06:00
Maybe Waffle
22c6330ba8 Prepare 0.5.0 release 2022-04-13 14:58:38 +04:00
Waffle Maybe
b294631121
Merge pull request #198 from teloxide/bare_id
Expose bare chat id
2022-04-13 14:00:57 +04:00
Waffle Maybe
4e35f6de31
Merge pull request #130 from teloxide/chrottle_retries_and_freeze
`Throttle` retries and freeze
2022-04-13 13:58:59 +04:00
Maybe Waffle
6318a7e730 Apply changes from the review
Make `BareChatId` internal.
2022-04-13 13:57:26 +04:00
Maybe Waffle
57a3731e6b Fix Message::url 2022-04-13 13:56:48 +04:00
Maybe Waffle
6ebdeb7f01 Expose bare chat id 2022-04-13 13:56:46 +04:00
Maybe Waffle
edb84691a2 Fix changelog formatting 2022-04-10 19:28:15 +04:00
Maybe Waffle
2477a0f945 Fix infinite loop in read_from_rx 2022-04-10 19:04:30 +04:00
Maybe Waffle
af0dd99ef4 Use Duration instead of u32 as the RetryAfter field 2022-04-10 18:48:00 +04:00
Maybe Waffle
43802a5c41 Improve Throttling adoptor
- Freeze when getting `RetryAfter(_)` error
- Retry requests that previously returned `RetryAfter(_)` error
2022-04-10 17:24:57 +04:00
Maybe Waffle
6a91c44836 make errors module pub and add errors::AsResponseParameters trait 2022-04-10 17:23:33 +04:00
Maybe Waffle
51d6800a32 Make RequestError::RetryAfter::0 u32, instead of i32
(you can't really wait a negative amount of time, can you?)
2022-04-10 17:22:20 +04:00
Maybe Waffle
213db7b64c Add AllowedUpdate::ChatJoinRequest 2022-04-08 15:57:16 +04:00
Waffle Maybe
ac08117216
Merge pull request #197 from teloxide/convenience_user_and_me_methods
Add some convenience methods to `User` and `Me`
2022-04-04 03:35:07 +04:00
Waffle Maybe
d1cf0e4f52
Merge branch 'master' into hide_token_in_errors 2022-04-03 16:14:34 +04:00
Maybe Waffle
daec5ee13e Hide bot token in errors
This fixes a potential[^1] security vulnerability -- if bot shows errors
from teloxide to the user & for some reason network error happened[^2]
the url of the request would be included in the error. Since TBA
includes bot token in the error this may lead to token leakage.

This commit fixes that issue by removing the token from the urls of
`reqwest::Error`, we try to only replace the token, but if we fail we
remove the whole url.

This can be tested by using a very low timeout value for the http
reqwest client:
```rust
let client = reqwest::Client::builder()
    .timeout(std::time::Duration::from_millis(1))
    .build()
    .unwrap();

let bot = Bot::from_env_with_client(client).auto_send();

// see if the token is redacted when network error (timeout) happens
// while sending common requests
let _ = dbg!(bot.get_me().await);

// see if the token is redacted when network error (timeout) happens
// while downloading files ("path" is unimportant as the timeout is so
// low the request probably won't even be sent)
let _ = dbg!(bot.download_file_stream("path").next().await);
```

For me this gives the following result:
```text
[t.rs:26] bot.get_me().await = Err(
    Network(
        reqwest::Error {
            kind: Request,
            url: Url {
                scheme: "https",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: Some(
                    Domain(
                        "api.telegram.org",
                    ),
                ),
                port: None,
                path: "/token:redacted/GetMe",
                query: None,
                fragment: None,
            },
            source: TimedOut,
        },
    ),
)
[t.rs:31] bot.download_file_stream("path").next().await = Some(
    Err(
        reqwest::Error {
            kind: Request,
            url: Url {
                scheme: "https",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: Some(
                    Domain(
                        "api.telegram.org",
                    ),
                ),
                port: None,
                path: "/file/token:redacted/path",
                query: None,
                fragment: None,
            },
            source: TimedOut,
        },
    ),
)
```

Note that this commits parent is `d0be260` and not the current master
the master branch currently contains breaking changes (we'll need to
make a release from this brach directly).

[^1]: Note that there are recorded cases where the token got exposed.
[^2]: Note that this can be theoretically be controlled by the user when
      sending/downloading bigger files.
2022-04-03 13:34:17 +04:00
Maybe Waffle
b3c0d00b7d "override" mention and tme_url on Me
That's not **really** an override, but by adding an inherent methods
we "hide" methods from `Deref<Target = User>`, that allows us to return
non-option types from `me.mention()` and `me.tme_url()` -- bots must
always have usernames.
2022-04-02 22:56:32 +04:00
Maybe Waffle
df9ffe8918 Add Me::username and Deref<Target = User> impl for Me 2022-04-02 22:43:55 +04:00
Maybe Waffle
55f753a201 Add User::{tme_url, preferably_tme_url} functions 2022-04-02 21:09:34 +04:00
Maybe Waffle
705083c2d9 Add UserId::{url, is_anonymous, is_channel, is_telegram} functions 2022-04-02 20:59:41 +04:00
Maybe Waffle
380ebde98b Update changelog 2022-04-02 18:26:18 +04:00
Maybe Waffle
1a61d02858 Release 0.4.4 2022-03-21 19:22:22 +04:00
Maybe Waffle
923be2221d Add NotFound error 2022-03-21 19:10:12 +04:00
Hirrolot
2c0748f3ae
Merge branch 'master' into with_payload 2022-03-20 08:08:52 -07:00
Maybe Waffle
d8e3c6ce42 Add WrongFileIdOrUrl and FailedToGetUrlContent errors 2022-03-18 14:21:55 +04:00
Maybe Waffle
c7e32fa247 Add HasPayload::with_payload_mut function
`HasPayload::with_payload_mut` allows to easily apply multiple changes
to the payload without calling `payload_mut()` multiple times and
creating temporary variable for the request. e.g.:
```rust
// without `with_payload_mut`
{
    let mut req = bot.set_webhook(url.clone());

    req.payload_mut().certificate = certificate.take();
    req.payload_mut().drop_pending_updates = drop_pending_updates;

    req.send().await?;
}

// with `with_payload_mut`
bot
    .set_webhook(url.clone())
    .with_payload_mut(|payload| {
        payload.certificate = certificate.take();
        payload.drop_pending_updates = drop_pending_updates;
    })
    .send()
    .await?
```
2022-03-18 14:13:38 +04:00
Maybe Waffle
11c79499e3 Release 0.4.3 2022-03-07 22:43:24 +04:00
Waffle Maybe
0c5f9678d8
Merge pull request #185 from teloxide/revert_better_timeouts
Revert "better timeouts"
2022-03-07 20:16:53 +04:00
Maybe Waffle
b0607f604a update changelog 2022-03-03 02:23:46 +03:00
Maybe Waffle
cfb48a6fa4 Update changelog 2022-03-03 01:48:09 +03:00
mikhailantoshkin
3c09f32723
Update changelog 2022-02-20 23:17:15 +05:00
Maybe Waffle
1d7825c97a Prepare 0.4.2 release 2022-02-17 15:03:41 +03:00
Maybe Waffle
6bf204221f Deprecate Message::chat_id 2022-02-17 14:51:00 +03:00
Maybe Waffle
3477f7eded Fix sending quiz polls 2022-02-17 14:10:39 +03:00
Maybe Waffle
2dc4a915ba Add a way for long-running requests to increase network timeout 2022-02-14 19:52:43 +03:00
Maybe Waffle
bfb64665a6 Release 0.4.1 2022-02-13 21:08:40 +03:00
Maybe Waffle
fb523f153e Fix deserialization of UntilDate 2022-02-13 20:53:41 +03:00
Maybe Waffle
4f85b8dc03 Dump version (-> 0.4.0) 2022-02-03 17:48:36 +03:00
Maybe Waffle
1ae7544578 Update changelog 2022-02-01 20:22:20 +03:00
Maybe Waffle
a36794c5d3 Make WebhookInfo::allowed_updates typed 2022-02-01 18:30:40 +03:00