mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
Merge branch 'dev' of https://github.com/teloxide/teloxide into fix_parse_command
This commit is contained in:
commit
b5221d68a7
9 changed files with 76 additions and 15 deletions
|
@ -1,7 +1,7 @@
|
|||
# Contributing
|
||||
Before contributing, please read [our code style](https://github.com/teloxide/teloxide/blob/master/CODE_STYLE.md) and [the license](https://github.com/teloxide/teloxide/blob/master/LICENSE).
|
||||
|
||||
To change the source code, fork this repository and work inside your own branch. Then send us a PR and wait for the CI to check everything. However, you'd better check changes first locally:
|
||||
To change the source code, fork this repository and work inside your own branch. Then send us a PR into the [dev](https://github.com/teloxide/teloxide/tree/dev) branch and wait for the CI to check everything. However, you'd better check changes first locally:
|
||||
|
||||
```
|
||||
cargo clippy --all --all-features --all-targets
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 teloxide
|
||||
Copyright (c) 2019-2020 teloxide
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
$ export TELOXIDE_TOKEN=<Your token here>
|
||||
|
||||
# Windows
|
||||
$ set TELOXITE_TOKEN=<Your token here>
|
||||
$ set TELOXIDE_TOKEN=<Your token here>
|
||||
```
|
||||
3. Be sure that you are up to date:
|
||||
```bash
|
||||
|
@ -280,13 +280,13 @@ The second one produces very strange compiler messages because of the `#[tokio::
|
|||
|
||||
## FAQ
|
||||
### Where I can ask questions?
|
||||
[Issues](https://github.com/teloxide/teloxide/issues) is a good place for well-formed questions, for example, about the library design, enhancements, bug reports. But if you can't compile your bot due to compilation errors and need a quick help, feel free to ask in our official group: https://t.me/teloxide.
|
||||
[Issues](https://github.com/teloxide/teloxide/issues) is a good place for well-formed questions, for example, about the library design, enhancements, bug reports. But if you can't compile your bot due to compilation errors and need quick help, feel free to ask in our official group: https://t.me/teloxide.
|
||||
|
||||
### Why Rust?
|
||||
Most programming languages have their own implementations of Telegram bots frameworks, so why not Rust? We think Rust provides enough good ecosystem and the language itself to be suitable for writing bots.
|
||||
|
||||
## Community bots
|
||||
Feel free to push your own bot into our collection: https://github.com/teloxide/community-bots. Later you will be able to play with them right in our official chat: https://t.me/teloxide (coming soon...).
|
||||
Feel free to push your own bot into our collection: https://github.com/teloxide/community-bots. Later you will be able to play with them right in our official chat: https://t.me/teloxide.
|
||||
|
||||
## Contributing
|
||||
See [CONRIBUTING.md](https://github.com/teloxide/teloxide/blob/master/CONTRIBUTING.md).
|
||||
|
|
|
@ -14,9 +14,7 @@ use futures::StreamExt;
|
|||
use std::{fmt::Debug, sync::Arc};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
type Tx<Upd> = Option<Mutex<mpsc::UnboundedSender<DispatcherHandlerCx<Upd>>>>;
|
||||
type Tx<Upd> = Option<mpsc::UnboundedSender<DispatcherHandlerCx<Upd>>>;
|
||||
|
||||
#[macro_use]
|
||||
mod macros {
|
||||
|
@ -37,10 +35,8 @@ async fn send<'a, Upd>(
|
|||
Upd: Debug,
|
||||
{
|
||||
if let Some(tx) = tx {
|
||||
if let Err(error) = tx
|
||||
.lock()
|
||||
.await
|
||||
.send(DispatcherHandlerCx { bot: Arc::clone(&bot), update })
|
||||
if let Err(error) =
|
||||
tx.send(DispatcherHandlerCx { bot: Arc::clone(&bot), update })
|
||||
{
|
||||
log::error!(
|
||||
"The RX part of the {} channel is closed, but an update is \
|
||||
|
@ -103,7 +99,7 @@ impl Dispatcher {
|
|||
let fut = h.handle(rx);
|
||||
fut.await;
|
||||
});
|
||||
Some(Mutex::new(tx))
|
||||
Some(tx)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
//! $ export TELOXIDE_TOKEN=<Your token here>
|
||||
//!
|
||||
//! # Windows
|
||||
//! $ set TELOXITE_TOKEN=<Your token here>
|
||||
//! $ set TELOXIDE_TOKEN=<Your token here>
|
||||
//! ```
|
||||
//!
|
||||
//! 3. Be sure that you are up to date:
|
||||
|
|
|
@ -71,7 +71,7 @@ mod tests {
|
|||
assert_eq!(expected, kind);
|
||||
}
|
||||
else {
|
||||
panic!("Этой херни здесь не должно быть");
|
||||
panic!("Expected ApiErrorKind::TerminatedByOtherGetUpdates");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ pub enum MessageKind {
|
|||
/// Specified message was pinned. Note that the Message object in this
|
||||
/// field will not contain further `reply_to_message` fields even if it
|
||||
/// is itself a reply.
|
||||
#[serde(rename = "pinned_message")]
|
||||
pinned: Box<Message>,
|
||||
},
|
||||
Invoice {
|
||||
|
|
|
@ -205,4 +205,46 @@ mod test {
|
|||
|
||||
assert!(serde_json::from_str::<Update>(text).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pinned_message_works() {
|
||||
let json = r#"{
|
||||
"message": {
|
||||
"chat": {
|
||||
"id": -1001276785818,
|
||||
"title": "teloxide dev",
|
||||
"type": "supergroup",
|
||||
"username": "teloxide_dev"
|
||||
},
|
||||
"date": 1582134655,
|
||||
"from": {
|
||||
"first_name": "Hirrolot",
|
||||
"id": 408258968,
|
||||
"is_bot": false,
|
||||
"username": "hirrolot"
|
||||
},
|
||||
"message_id": 20225,
|
||||
"pinned_message": {
|
||||
"chat": {
|
||||
"id": -1001276785818,
|
||||
"title": "teloxide dev",
|
||||
"type": "supergroup",
|
||||
"username": "teloxide_dev"
|
||||
},
|
||||
"date": 1582134643,
|
||||
"from": {
|
||||
"first_name": "Hirrolot",
|
||||
"id": 408258968,
|
||||
"is_bot": false,
|
||||
"username": "hirrolot"
|
||||
},
|
||||
"message_id": 20224,
|
||||
"text": "Faster than a bullet"
|
||||
}
|
||||
},
|
||||
"update_id": 845402291
|
||||
}"#;
|
||||
|
||||
serde_json::from_str::<Update>(json).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
22
teloxide-macros/LICENSE
Normal file
22
teloxide-macros/LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2020 teloxide
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
Loading…
Add table
Reference in a new issue