Skip to content

Commit

Permalink
Revert "Revert "Merge branch 'dev'""
Browse files Browse the repository at this point in the history
This reverts commit 4e00473.
  • Loading branch information
WaffleLapkin committed Nov 28, 2022
1 parent ff1bf70 commit 8ad3bf5
Show file tree
Hide file tree
Showing 351 changed files with 38,979 additions and 425 deletions.
20 changes: 11 additions & 9 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[alias]
# We pass "--cfg docsrs" when building docs to turn on nightly-only rustdoc features like
# `This is supported on feature="..." only.`
# Using `--features=full --features=nightly` instead of `--all-features` because of
# https://github.com/rust-lang/cargo/issues/10333
#
# "--cfg dep_docsrs" is used for the same reason, but for `teloxide-core`.
docs = """
doc
--all-features
--config build.rustflags=["--cfg=dep_docsrs"]
--config build.rustdocflags=["--cfg=docsrs","-Znormalize-docs"]
-Zrustdoc-scrape-examples=examples
# "tokio/macros" and "tokio/rt-multi-thread" are required for examples
docs = """doc
-Zrustdoc-scrape-examples=examples
--features=full --features=nightly
--features=tokio/macros --features=tokio/rt-multi-thread
"""

[build]
# We pass "--cfg docsrs" when building docs to add `This is supported on feature="..." only.`
rustdocflags = ["--cfg", "docsrs", "-Znormalize-docs"]
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ env:
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10

rust_nightly: nightly-2022-09-01
# When updating this, also update:
# - README.md
# - src/lib.rs
# - crates/teloxide-core/src/codegen.rs
# - rust-toolchain.toml
rust_nightly: nightly-2022-09-23
# When updating this, also update:
# - **/README.md
# - **/src/lib.rs
# - down below in a matrix
rust_msrv: 1.64.0

CI: 1

jobs:
# Depends on all action that are required for a "successful" CI run.
ci-pass:
Expand Down Expand Up @@ -82,7 +87,7 @@ jobs:
toolchain: beta
features: "--features full"
- rust: nightly
toolchain: nightly-2022-09-01
toolchain: nightly-2022-09-23
features: "--all-features"
- rust: msrv
toolchain: 1.64.0
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/target
**/*.rs.bk
Cargo.lock
.idea/
.vscode/
examples/*/target
*.sqlite
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## unreleased

## Removed

- `rocksdb-storage` feature and associated items (See [PR #761](https://github.com/teloxide/teloxide/pull/761) for reasoning) [**BC**]

## 0.11.3 - 2022-11-28

### Fixed
Expand Down Expand Up @@ -319,14 +323,14 @@ This release was yanked because it accidentally [breaks backwards compatibility]
- Export `teloxide_macros::teloxide` in `prelude`.
- `dispatching::dialogue::serializer::{JSON -> Json, CBOR -> Cbor}`
- Allow `bot_name` be `N`, where `N: Into<String> + ...` in `commands_repl` & `commands_repl_with_listener`.
- 'Edit methods' (namely `edit_message_live_location`, `stop_message_live_location`, `edit_message_text`,
`edit_message_caption`, `edit_message_media` and `edit_message_reply_markup`) are split into common and inline
- 'Edit methods' (namely `edit_message_live_location`, `stop_message_live_location`, `edit_message_text`,
`edit_message_caption`, `edit_message_media` and `edit_message_reply_markup`) are split into common and inline
versions (e.g.: `edit_message_text` and `edit_inline_message_text`). Instead of `ChatOrInlineMessage` common versions
accept `chat_id: impl Into<ChatId>` and `message_id: i32` whereas inline versions accept
accept `chat_id: impl Into<ChatId>` and `message_id: i32` whereas inline versions accept
`inline_message_id: impl Into<String>`. Also note that return type of inline versions is `True` ([issue 253], [pr 257])
- `ChatOrInlineMessage` is renamed to `TargetMessage`, it's `::Chat` variant is renamed to `::Common`,
`#[non_exhaustive]` annotation is removed from the enum, type of `TargetMessage::Inline::inline_message_id` changed
`i32` => `String`. `TargetMessage` now implements `From<String>`, `get_game_high_scores` and `set_game_score` use
- `ChatOrInlineMessage` is renamed to `TargetMessage`, it's `::Chat` variant is renamed to `::Common`,
`#[non_exhaustive]` annotation is removed from the enum, type of `TargetMessage::Inline::inline_message_id` changed
`i32` => `String`. `TargetMessage` now implements `From<String>`, `get_game_high_scores` and `set_game_score` use
`Into<TargetMessage>` to accept `String`s. ([issue 253], [pr 257])
- Remove `ResponseResult` from `prelude`.

Expand Down
174 changes: 2 additions & 172 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,172 +1,2 @@
[package]
name = "teloxide"
version = "0.11.3"
edition = "2021"
description = "An elegant Telegram bots framework for Rust"
repository = "https://github.com/teloxide/teloxide"
documentation = "https://docs.rs/teloxide/"
readme = "README.md"
keywords = ["teloxide", "telegram", "telegram-bot", "telegram-bot-api"]
categories = ["web-programming", "api-bindings", "asynchronous"]
license = "MIT"
exclude = ["media"]

[features]
default = ["native-tls", "ctrlc_handler", "teloxide-core/default", "auto-send"]

webhooks = ["rand"]
webhooks-axum = ["webhooks", "axum", "tower", "tower-http"]

sqlite-storage = ["sqlx"]
redis-storage = ["redis"]
rocksdb-storage = ["rocksdb"]
cbor-serializer = ["serde_cbor"]
bincode-serializer = ["bincode"]

macros = ["teloxide-macros"]

ctrlc_handler = ["tokio/signal"]

native-tls = ["teloxide-core/native-tls"]
rustls = ["teloxide-core/rustls"]
auto-send = ["teloxide-core/auto_send"]
throttle = ["teloxide-core/throttle"]
cache-me = ["teloxide-core/cache_me"]
trace-adaptor = ["teloxide-core/trace_adaptor"]
erased = ["teloxide-core/erased"]

# currently used for `README.md` tests, building docs for `docsrs` to add `This is supported on feature="..." only.`,
# and for teloxide-core.
nightly = ["teloxide-core/nightly"]

full = [
"webhooks-axum",
"sqlite-storage",
"redis-storage",
"rocksdb-storage",
"cbor-serializer",
"bincode-serializer",
"macros",
"ctrlc_handler",
"teloxide-core/full",
"native-tls",
"rustls",
"auto-send",
"throttle",
"cache-me",
"trace-adaptor",
"erased",
]

[dependencies]
teloxide-core = { version = "0.8.0", default-features = false }
teloxide-macros = { version = "0.7.0", optional = true }

serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

dptree = "0.3.0"

# These lines are used only for development.
# teloxide-core = { git = "https://github.com/teloxide/teloxide-core", rev = "00165e6", default-features = false }
# teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros", rev = "e715105", optional = true }
# dptree = { git = "https://github.com/teloxide/dptree", rev = "df578e4" }

tokio = { version = "1.8", features = ["fs"] }
tokio-util = "0.7"
tokio-stream = "0.1.8"

url = "2.2.2"
log = "0.4"
bytes = "1.0"
mime = "0.3"

derive_more = "0.99"
thiserror = "1.0"
futures = "0.3.15"
pin-project = "1.0"
serde_with_macros = "1.4"
aquamarine = "0.1.11"

sqlx = { version = "0.6", optional = true, default-features = false, features = [
"runtime-tokio-native-tls",
"macros",
"sqlite",
] }
redis = { version = "0.21", features = ["tokio-comp"], optional = true }
rocksdb = { version = "0.19", optional = true, default-features = false, features = [
"lz4",
] }
serde_cbor = { version = "0.11", optional = true }
bincode = { version = "1.3", optional = true }
axum = { version = "0.5.13", optional = true }
tower = { version = "0.4.12", optional = true }
tower-http = { version = "0.3.4", features = ["trace"], optional = true }
rand = { version = "0.8.5", optional = true }

[dev-dependencies]
rand = "0.8.3"
pretty_env_logger = "0.4.0"
serde = "1"
serde_json = "1"
tokio = { version = "1.8", features = ["fs", "rt-multi-thread", "macros"] }
reqwest = "0.11.11"
chrono = "0.4"
tokio-stream = "0.1"

[package.metadata.docs.rs]
all-features = true
# FIXME: Add back "-Znormalize-docs" when https://github.com/rust-lang/rust/issues/93703 is fixed
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "dep_docsrs"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples=examples"]

[[test]]
name = "redis"
path = "tests/redis.rs"
required-features = ["redis-storage", "cbor-serializer", "bincode-serializer"]

[[test]]
name = "sqlite"
path = "tests/sqlite.rs"
required-features = ["sqlite-storage", "cbor-serializer", "bincode-serializer"]

[[example]]
name = "dialogue"
required-features = ["macros"]

[[example]]
name = "command"
required-features = ["macros"]

[[example]]
name = "db_remember"
required-features = ["sqlite-storage", "redis-storage", "bincode-serializer", "macros"]

[[example]]
name = "inline"
required-features = ["macros"]

[[example]]
name = "buttons"
required-features = ["macros"]

[[example]]
name = "admin"
required-features = ["macros"]

[[example]]
name = "dispatching_features"
required-features = ["macros"]

[[example]]
name = "ngrok_ping_pong"
required-features = ["webhooks-axum"]

[[example]]
name = "heroku_ping_pong"
required-features = ["webhooks-axum"]

[[example]]
name = "purchase"
required-features = ["macros"]
[workspace]
members = ["crates/*"]
8 changes: 8 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
This document describes breaking changes of `teloxide` crate, as well as the ways to update code.
Note that the list of required changes is not fully exhaustive and it may lack something in rare cases.

## 0.11 -> 0.??

### teloxide

`rocksdb-storage` feature and associated items were removed.
If you are using rocksdb storage, you'll need to either write `Storage` impl yourself, or use a third party crate.
<!-- FIXME: add a link once there *is* a third party crate -->

## 0.11 -> 0.11.3

### teloxide
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
> [v0.11 -> v0.11.3 migration guide >>](MIGRATION_GUIDE.md#011---0113)
<div align="center">
<img src="./ICON.png" width="250"/>
<img src="./media/teloxide-logo.png" width="250"/>
<h1><code>teloxide</code></h1>
<a href="https://docs.rs/teloxide/">
<img src="https://docs.rs/teloxide/badge.svg">
Expand Down Expand Up @@ -31,11 +31,10 @@

- **Feature-rich.** You can use both long polling and webhooks, configure an underlying HTTPS client, set a custom URL of a Telegram API server, do graceful shutdown, and much more.

- **Simple dialogues.** Our dialogues subsystem is simple and easy-to-use, and, furthermore, is agnostic of how/where dialogues are stored. For example, you can just replace a one line to achieve [persistence]. Out-of-the-box storages include [Redis], [RocksDB] and [Sqlite].
- **Simple dialogues.** Our dialogues subsystem is simple and easy-to-use, and, furthermore, is agnostic of how/where dialogues are stored. For example, you can just replace a one line to achieve [persistence]. Out-of-the-box storages include [Redis] and [Sqlite].

[persistence]: https://en.wikipedia.org/wiki/Persistence_(computer_science)
[Redis]: https://redis.io/
[RocksDB]: https://rocksdb.org/
[Sqlite]: https://www.sqlite.org

- **Strongly typed commands.** Define bot commands as an `enum` and teloxide will parse them automatically — just like JSON structures in [`serde-json`] and command-line arguments in [`structopt`].
Expand Down Expand Up @@ -85,7 +84,7 @@ tokio = { version = "1.8", features = ["rt-multi-thread", "macros"] }

This bot replies with a die throw to each received message:

[[`examples/throw_dice.rs`](examples/throw_dice.rs)]
[[`examples/throw_dice.rs`](crates/teloxide/examples/throw_dice.rs)]

```rust,no_run
use teloxide::prelude::*;
Expand Down Expand Up @@ -120,7 +119,7 @@ Commands are strongly typed and defined declaratively, similar to how we define
[structopt]: https://docs.rs/structopt/0.3.9/structopt/
[serde-json]: https://github.com/serde-rs/json

[[`examples/command.rs`](examples/command.rs)]
[[`examples/command.rs`](crates/teloxide/examples/command.rs)]

```rust,no_run
use teloxide::{prelude::*, utils::command::BotCommands};
Expand Down Expand Up @@ -174,7 +173,7 @@ A dialogue is typically described by an enumeration where each variant is one po

Below is a bot that asks you three questions and then sends the answers back to you:

[[`examples/dialogue.rs`](examples/dialogue.rs)]
[[`examples/dialogue.rs`](crates/teloxide/examples/dialogue.rs)]

```rust,ignore
use teloxide::{dispatching::dialogue::InMemStorage, prelude::*};
Expand Down Expand Up @@ -285,7 +284,7 @@ async fn receive_location(
<img src="./media/dialogue.gif" width="420" />
</div>

[More examples >>](examples/)
[More examples >>](crates/teloxide/examples/)

## FAQ

Expand All @@ -307,11 +306,11 @@ A: No, only the bots API.

**Q: Can I use webhooks?**

A: You can! `teloxide` has a built-in support for webhooks in `dispatching::update_listeners::webhooks` module. See how it's used in [`examples/ngrok_ping_pong_bot`](examples/ngrok_ping_pong.rs) and [`examples/heroku_ping_pong_bot`](examples/heroku_ping_pong.rs).
A: You can! `teloxide` has a built-in support for webhooks in `dispatching::update_listeners::webhooks` module. See how it's used in [`examples/ngrok_ping_pong_bot`](crates/teloxide/examples/ngrok_ping_pong.rs) and [`examples/heroku_ping_pong_bot`](crates/teloxide/examples/heroku_ping_pong.rs).

**Q: Can I handle both callback queries and messages within a single dialogue?**

A: Yes, see [`examples/purchase.rs`](examples/purchase.rs).
A: Yes, see [`examples/purchase.rs`](crates/teloxide/examples/purchase.rs).

## Community bots

Expand Down

0 comments on commit 8ad3bf5

Please sign in to comment.