Commit graph

1536 commits

Author SHA1 Message Date
Hirrolot
ec9f701cf7 Revert ".chat_id() => .chat_id"
This reverts commit 26a28b1918.
2022-02-04 19:44:04 +06:00
Hirrolot
26a28b1918 .chat_id() => .chat_id 2022-02-04 19:38:06 +06:00
Hirrolot
879560f34a Fix the fixes 2022-02-04 19:09:32 +06:00
Hirrolot
9306f6d484
Update src/dispatching2/dispatcher.rs
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2022-02-04 16:43:52 +06:00
Hirrolot
242bfef885 Fix merge conflicts 2022-02-03 20:39:32 +06:00
Hirrolot
dedb1c85e1 Add high-level documentation 2022-02-03 20:27:45 +06:00
Hirrolot
d4fbaa74c4 Some tiny documentation tweaks 2022-02-03 16:38:54 +06:00
Hirrolot
d89eeb5847 Make setup_ctrlc_handler return &mut Self 2022-02-03 12:48:02 +06:00
Hirrolot
45293e3168 Fix dialogue examples 2022-02-03 02:36:36 +06:00
Hirrolot
60df0a5cf8 Refactor Dialogue
Remove useless stuff, some cleanup, u know.
2022-02-02 15:25:23 +06:00
Hirrolot
d25efa9e14 Document UpdateHandler, DefaultHandler 2022-02-02 05:00:45 +06:00
Hirrolot
5101786d0b requester => bot 2022-02-02 04:55:12 +06:00
Hirrolot
21eb048ca2 Decouple Dispatcher from DispatcherBuilder 2022-02-02 04:51:36 +06:00
Hirrolot
e92eef4a7c Document some stuff 2022-01-31 19:23:47 +06:00
Hirrolot
2058395d54 Add Me into the dependencies 2022-01-28 20:52:01 +06:00
Hirrolot
58311ef608 Add Update & UpdateFilterExt to prelude2 2022-01-26 15:51:43 +06:00
Hirrolot
b1fac57c94
Merge pull request #500 from teloxide/fix_stop_token_sendness
Fix `polling`'s `StopToken` not being `Send`
2022-01-26 12:34:32 +06:00
Maybe Waffle
e83688d4d3 Add toolchain file and fix formatting 2022-01-25 21:07:30 +03:00
Maybe Waffle
ea5eb16276 Clarify StatefulListener docs a little 2022-01-25 20:38:59 +03:00
Maybe Waffle
755ec44aea Cleanup update_listeners docs 2022-01-25 20:25:19 +03:00
Hirrolot
cd51bba180 Refactor Dispatcher 2022-01-24 13:20:13 +06:00
Hirrolot
7d6c374828 Accept the handler as a parameter in Dispatcher::new 2022-01-23 20:58:55 +06:00
Hirrolot
ad88db96b6 Add UpdateFilterExt 2022-01-23 20:38:12 +06:00
Hirrolot
01c43dd360 Refactor MessageFilterExt 2022-01-23 20:15:27 +06:00
Maybe Waffle
a7182962f7 Fix polling's StopToken not being Send 2022-01-18 21:01:47 +03:00
Maybe Waffle
993e6e53aa Do not retry get_updates infinitely while stopping polling listener 2022-01-17 14:42:49 +03:00
Hirrolot
cc0e21c9f8 Remove Dispatcher::without_error_handler 2022-01-16 19:51:36 +06:00
Hirrolot
bacea51adc Expose DefaultHandler, UpdateHandler out of dispatcher.rs 2022-01-16 19:50:39 +06:00
Hirrolot
2ad4e9a9f7 Define Dispatcher handlers via a macro 2022-01-16 18:26:37 +06:00
p0lunin
1be9dd9a48 import MessageFilterExt in the prelude2.rs 2022-01-12 15:44:31 +02:00
p0lunin
3042dcada5 add Dispatcher::error_handler 2022-01-12 14:07:30 +02:00
p0lunin
bbd8f4d5ec add MessageFilterExt 2022-01-12 14:07:18 +02:00
p0lunin
5fb673a87f fix bug with callback_queries_handler 2022-01-12 12:36:42 +02:00
Maybe Waffle
d5392fddab Update teloxide-core yet again 2022-01-12 12:50:35 +03:00
p0lunin
7615fc1392 fix clippy errors 2022-01-06 15:12:57 +02:00
p0lunin
d7386a7dc1 remove old_dispatching feature, add prelude2 and repls2 modules 2022-01-06 14:50:59 +02:00
p0lunin
a8098350fc Merge branch 'dev' into dispatching2
# Conflicts:
#	Cargo.toml
#	examples/dialogue_bot/Cargo.toml
#	examples/inline_bot/src/main.rs
#	src/dispatching/mod.rs
#	src/lib.rs
2022-01-06 14:25:01 +02:00
p0lunin
dac969250d update rest of handlers in the Dispatcher 2022-01-05 20:33:48 +02:00
p0lunin
e2891d6d00 remove #[out()] attribute 2021-12-29 14:21:37 +02:00
p0lunin
72dfef4963 added DialogueState macro 2021-12-29 13:33:51 +02:00
p0lunin
6c0f1b9fc4 Added handler_factory.rs 2021-12-28 18:24:56 +02:00
Maybe Waffle
edecf5975f Update teloxide-core to the latest git version 2021-12-28 17:31:33 +03:00
Hirrolot
b253b7eec2 Don't define async fn run()
rustc now emits enough good compiler error messages for procedural macros such as `#[tokio::main]`.
2021-12-27 21:13:46 +06:00
p0lunin
b10288f751 remove unused imports 2021-12-26 20:06:21 +02:00
p0lunin
4452631fcc fix repls 2021-12-26 19:59:13 +02:00
p0lunin
a644d0b6d2 added handler_ext.rs, updated dptree version 2021-12-26 16:55:24 +02:00
p0lunin
6959d1c928 added dialogues + updated sqlite_remember_bot example. 2021-12-15 13:46:32 +02:00
p0lunin
3f1d1360c6 fmt 2021-12-11 13:11:44 +02:00
p0lunin
635c18142a 1. Bump futures to 0.3.15 version (Abortable::is_aborted()).
2. Fix simple_commands_bot example.
2021-12-11 13:11:25 +02:00
p0lunin
4752b22c43 1. Change feature dispatching2 -> old_dispatching.
2. Added command repls.
3. Added function BotCommand::ty() due to new restrictions in the command repls.
2021-12-11 12:46:44 +02:00
p0lunin
93ed028e44 added dispatching2 feature, implemented standard repls 2021-11-25 13:44:55 +02:00
p0lunin
14083c8300 Many improvements of Dispatcher, also made many dispatcher::* methods and types pub(crate) for using in dispatching2 module 2021-11-25 12:59:54 +02:00
p0lunin
887b24d27f Initial commit.
1. Added `dptree` dependency.
2. Added `dispatching2` module.
2. Added `Dispatcher` and `Handlers` types, which is similar to `dispatching::Dispatcher` type.
2021-11-13 12:35:56 +02:00
Waffle Maybe
fb238ff656
Merge branch 'dev' into master-to-dev-1 2021-10-25 17:17:42 +03:00
Maybe Waffle
f6c4701932 fix clippy 2021-10-25 15:50:04 +03:00
­
964323fca4
Fix compilation without ctrlc_handler feature
The feature gate is moved to the `dispatching` mod level.
Public exports are also covered by this flag now.
2021-10-25 02:12:11 +03:00
­
a7049c9e7d
Docs: Add missing features description 2021-10-23 01:56:17 +03:00
Maybe Waffle
fc4bb6be14 fix clippy 2021-10-10 15:15:16 +03:00
Waffle
a97050de24 Require that AsUpdateStream::Stream is Send 2021-09-04 14:05:18 +03:00
Waffle
18cfb675bf Fix doc(cfg) annotation 2021-09-04 14:00:43 +03:00
Waffle
a2bfdf850a Suppress clippy false positive 2021-08-19 12:03:35 +03:00
Waffle
b984464a79 Improve log messages when ^C is received with ^C handler setted up
Now they tell the user to not repeatedly press `^C` since only the first
signal actually does anything, all subsequesnt ones are ignored.
2021-07-21 15:53:52 +03:00
Waffle
81775a7217 Show "This is supported on feature="..." only." in socs of reexported teloxide-core items 2021-07-07 20:27:38 +03:00
dracarys18
4c480a1714 Merge github.com:teloxide/teloxide into dev 2021-07-04 09:17:41 +05:30
Waffle
39e0ee094a Ignore buggy nonstandard_macro_braces clippy lint 2021-07-04 00:22:11 +03:00
dracarys18
1f1a3abd6b utils: Change the user_id type to i64
user_id is of type i64 in User struct (bd104a0a08/src/types/user.rs (L10))

Signed-off-by: dracarys18 <karthihegde010@gmail.com>
2021-07-03 17:31:57 +05:30
dracarys18
6bb18ea40b Add reply shortcuts for every kind of message
Signed-off-by: dracarys18 <karthihegde010@gmail.com>
2021-06-30 17:59:07 +05:30
Hirrolot
01d1c8c95b
Merge pull request #403 from teloxide/hint_allowed_updates
Implement automatic update filtering
2021-06-27 18:56:48 +06:00
Waffle
7859294ff6 Apply suggestion from the review 2021-06-27 15:52:23 +03:00
Waffle
faef0c6ffb Implement automatic update filtering
Add `UpdateListener::hint_allowed_updates` and `StatefulListener::hint_allowed_updates`.

Make `Dispatcher` call `UpdateListener::hint_allowed_updates` when starting dispatching.
2021-06-27 15:07:21 +03:00
Hirrolot
c5ac8b5f9c Emit graceful shutdown info in all cases 2021-06-27 16:36:36 +06:00
Hirrolot
a6c480930a Print info about graceful shutdown to users 2021-06-27 15:44:46 +06:00
Hirrolot
afe5a9716b Enhance the docs 2021-06-27 14:57:02 +06:00
Waffle
558e7d5a72 Add IdleShutdownError 2021-06-27 10:50:47 +03:00
Waffle
0347f9e627 Replace ShutdownError with () 2021-06-26 23:21:44 +03:00
Waffle
483e544223 Apply suggestions from the review: rename AtomicShutdownState => DispatcherState, IsntRunning => Idle 2021-06-26 23:04:36 +03:00
Waffle
1795cb22c2 setup ^C handler in repls 2021-06-26 17:19:56 +03:00
Waffle
49848abd61 Doc fixes 2021-06-26 15:33:33 +03:00
Waffle
8e3ef4ab67 Minor Dispatcher cleanup 2021-06-26 15:08:32 +03:00
Waffle
7cfb207b44 Wait for handlers to finish before shutting down dispatcher
This commit makes `Dispatcher::dispatch_with_listener` (and all it's derivatives
like `Dispatcher::dispatch`, `teloxide::repl`) to wait for handlers to finish
berfore shutting down.

This commit also changes self-type for `Dispatcher::dispatch_with_listener` and
`Dispatcher::dispatch` from `&Self` to `&mut Self` (this is required to wait
for handlers to finish).

Since unique reference is now required for listening,`Dispatcher::shutdown`
function is removed.
2021-06-26 14:33:10 +03:00
Waffle
569ef222fc Add dispatcher shutdown token
This commit adds `ShutdownToken` which can be obrained throught
`Dispatcher::shutdown_token` and then later be used to shutdown dispatching.
2021-06-25 17:41:02 +03:00
Waffle
c378d6ef4e Make StatefulListener::new a little more convinient
Remove `timeout_hint` from the `StatefulListener::new` function. This parameter
is confusing and is likely to be set to `None` in most cases.

Add a `StatefulListener::new_with_timeout_hint` parameter which is the same as
the old `StatefulListener::new`.
2021-06-25 17:24:31 +03:00
Waffle
76dee997e0 Fix webhook examples (support graceful shutdown) 2021-06-25 16:57:24 +03:00
Waffle
8785b8263c Fix overflow in dispatch_with_listener 2021-06-25 16:57:24 +03:00
Waffle
f58ae9b9ca Make StatefulListener pub 2021-06-25 16:57:24 +03:00
Waffle
881aa3d6b6 Split update_listeners into multiple modules 2021-06-25 16:57:24 +03:00
Waffle
a162478346 Switch graceful shutdown to cancelation token-like system 2021-06-25 16:57:24 +03:00
Waffle Lapkin
a8306ec3ff Apply suggestions from code review
Co-authored-by: Hirrolot <hirrolot@gmail.com>
2021-06-25 16:57:24 +03:00
Waffle
00093664c7 Remove use of unstable feature (duration_zero)
The feature has been stabilized in 1.53.
2021-06-25 16:57:24 +03:00
Waffle
a5192a9ecb Clippy 2021-06-25 16:57:24 +03:00
Waffle
d745f9bdb1 Remove send! macro 2021-06-25 16:57:24 +03:00
Waffle
f0de55ad55 Add Dispatcher::setup_ctrlc_handler function.
This function sets up `^C` handler which shuts down dispatching.
2021-06-25 16:57:24 +03:00
Waffle
41a95079b2 Add Dispatcher::shutdown function
This function allows to gracefuly shutdown dispatching.
2021-06-25 16:57:24 +03:00
Waffle
eae2bced6d Simplify polling a little bit 2021-06-25 16:57:24 +03:00
Waffle
9f5a222ed7 Add UpdateListener::timeout_hint 2021-06-25 16:57:24 +03:00
Waffle
c288a540b9 Store fetched updates in polling::State
This way updates aren't lost when the stream is dropped.
2021-06-25 16:57:24 +03:00
Waffle
aeca45a579 Refactor UpdateListner trait
Instead of `Stream` super trait we now require `for<'a> AsUpdateStream<'a, E'>`
as a super trait. `AsUpdateStream` in turn provides `as_stream` function which
takes `&mut self` and returns `Self::Stream` (the trait is needed to workaround
lack of GAT).

This patch also adds a `stop` function that allows stopping the listener.

Since `UpdateListner` now isn't `Stream` and required methods, it's blanked
implementation for streams was removed.

`polling` and `polling_default` functions now also require `R: 'static`.
2021-06-25 16:57:24 +03:00
Hirrolot
0f857e944b feature = "nightly" => all(docsrs, feature = "nightly") 2021-06-18 22:17:08 +06:00
Hirrolot
6a7ad31fc9 Place the comment above feature(doc_cfg) 2021-06-18 22:07:37 +06:00
Hirrolot
74348b7236 Remove feature(external_doc) completely 2021-06-18 21:44:10 +06:00
Hirrolot
fb0b267b94 Fix the removed feature external_doc 2021-06-18 21:35:54 +06:00
Hirrolot
f4260ed078 Replace lockfree with flurry 2021-06-18 20:53:03 +06:00
Hirrolot
1d5859507a Remove feature(extended_key_value_attributes) 2021-05-20 21:54:41 +06:00
Waffle
9b34586a04 Normalize docs 2021-05-15 23:37:14 +03:00
Temirkhan Myrzamadi
c0e3064785 Fmt 2021-05-10 12:13:07 +06:00
Hirrolot
7f578a8918
Paraphrase src/utils/command.rs
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-05-09 23:06:35 -07:00
Temirkhan Myrzamadi
cf3639f68b Document the "off" value as a command description 2021-05-10 08:55:43 +06:00
Temirkhan Myrzamadi
3b7ca4dabd Merge 2021-05-08 19:02:35 +06:00
Temirkhan Myrzamadi
27eda5759c RowNotFound -> DialogueNotFound 2021-05-08 19:00:38 +06:00
Hirrolot
de52ea25f9
Update src/dispatching/dialogue/storage/mod.rs
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-05-08 05:43:34 -07:00
Hirrolot
80e1afaeed
Update src/dispatching/dialogue/storage/in_mem_storage.rs
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-05-08 05:43:27 -07:00
Temirkhan Myrzamadi
d14e0a49e9 Merge branch 'fix-remove-dialogue-sqlite' of https://github.com/teloxide/teloxide into fix-remove-dialogue-sqlite 2021-05-08 18:41:53 +06:00
Temirkhan Myrzamadi
cb02b83520 Apply review suggestions 2021-05-08 18:41:34 +06:00
Hirrolot
94e61d3403
Refactor src/dispatching/dialogue/storage/redis_storage.rs
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-05-08 05:39:18 -07:00
Temirkhan Myrzamadi
5585143ac2 Don't capitalise letters after dashes 2021-05-08 18:21:11 +06:00
Temirkhan Myrzamadi
721feb0082 Fix the tests 2021-05-08 17:38:03 +06:00
Temirkhan Myrzamadi
58c8015e78 Re-export InMemStorageError unconditionally 2021-05-08 17:25:53 +06:00
Temirkhan Myrzamadi
08bf40e555 Fail Storage::remove_dialogue if a dialogue doesn't exist 2021-05-08 17:21:24 +06:00
Temirkhan Myrzamadi
9e0de46918 Always remove a dialogue in SqliteStorage::remove_dialogue 2021-04-22 05:42:05 +06:00
Temirkhan Myrzamadi
17d14d2d53 Yet another dirty hack to please rustfmt 2021-04-05 21:19:29 +06:00
Temirkhan Myrzamadi
bc9972bdf2 Move the features section to lib.rs 2021-04-05 19:48:56 +06:00
Temirkhan Myrzamadi
bf8d2fa51b Paraphrase #[must_use] 2021-04-03 14:21:06 +06:00
Temirkhan Myrzamadi
44956a4f85 Add descriptions of #[must_use] in Storage 2021-04-03 13:28:26 +06:00
Temirkhan Myrzamadi
617c861d26 Mark all the functions of Storage as #[must_use] 2021-04-03 06:53:02 +06:00
Temirkhan Myrzamadi
fff0b670fb Fix RedisStorage::update_dialogue 2021-03-29 12:20:17 +06:00
Hirrolot
ca60e52f43
Update src/dispatching/dialogue/storage/redis_storage.rs
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-03-28 22:18:47 -07:00
Hirrolot
75a36feca5
Merge branch 'dev' into fix-storage-persistency 2021-03-28 03:36:03 -07:00
Temirkhan Myrzamadi
68135d004f ToOwned<Owned = D> -> D: Clone 2021-03-28 16:30:12 +06:00
Temirkhan Myrzamadi
b7e2f14307 Automatically delete a webhook if it was set up 2021-03-28 08:51:57 +06:00
Temirkhan Myrzamadi
9b75378572 Fix the tests and examples 2021-03-28 08:20:35 +06:00
Temirkhan Myrzamadi
01b7b91bda Document how Storage failures are handled in DialogueDispatcher 2021-03-28 06:30:35 +06:00
Temirkhan Myrzamadi
abbbc41892 Fix RedisStorage, SqliteStorage 2021-03-28 06:20:13 +06:00
Temirkhan Myrzamadi
bf1ed601ac Fix the storage persistency bug 2021-03-28 05:34:25 +06:00
Temirkhan Myrzamadi
580dfaeae6 Merge branch 'dev' into clarify-storage-purpose 2021-03-22 01:35:14 +06:00
Waffle Lapkin
101528e453
Resolve fixme (#350)
* Update redis

* Resolve fixme(waffle) related to building docs

* Fix broken links

* Reexport teloxide_core::prelude as `no_inline`
2021-03-22 00:43:19 +06:00
Hirrolot
8522759e68
Get ready for v0.4.0 (#347)
* Get ready for v0.4.0

* Export teloxide_macros as macros in lib.rs

* Use tokio v1.3 in README.md

* Return the feature 'macros' back

* Export teloxide_macros::teloxide in the prelude

* Document the 'macros' feature in README.md

* Update src/lib.rs

Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>

* Update src/prelude.rs

Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>

* Propagate features from teloxide-core

* teloxide-core = 0.2.1

* Fix CI

* Require teloxide-core/auto_send instead of teloxide/auto-send

* default-features = false (teloxide-core)

* Specify each teloxide-core feature separately

* Fix Cargo.toml

* JSON -> Json, CBOR -> Cbor

* Update Cargo.toml

Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>

Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-03-21 18:34:23 +06:00
Hirrolot
68e3c5e089
Update src/prelude.rs
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-03-20 22:57:32 +06:00
Temirkhan Myrzamadi
86253edc92 Use Box<dyn Error + Send + Sync> in the examples 2021-03-19 17:58:22 +06:00
Temirkhan Myrzamadi
be7bec6fa9 Support UpdateKind::{MyChatMember, ChatMember} 2021-03-17 23:36:51 +06:00
Hirrolot
31e6fba58c
Update src/lib.rs
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2021-03-15 20:26:50 +06:00
Temirkhan Myrzamadi
62b979369f Fix the doc tests 2021-03-15 20:21:50 +06:00
Temirkhan Myrzamadi
823f279a60 Fix the docs 2021-03-15 09:51:00 +06:00
Temirkhan Myrzamadi
34a2eee1fa Apply review suggestions 2021-03-15 09:22:32 +06:00
Temirkhan Myrzamadi
36b314cdfc Fix this fucking bullshit 2021-03-13 23:35:48 +06:00
Temirkhan Myrzamadi
b29ef34299 Fmt 2021-03-13 23:08:35 +06:00
Temirkhan Myrzamadi
5f96da0a5f Fix the tests 2021-03-13 23:05:50 +06:00
Temirkhan Myrzamadi
1af0bfdcbc Fix the examples 2021-03-13 22:13:24 +06:00
Temirkhan Myrzamadi
a6e0c48427 Fix the tests 2021-03-06 03:50:11 +06:00
Temirkhan Myrzamadi
6102a02ed4 Integrate teloxide-core 2021-03-06 03:18:03 +06:00
Temirkhan Myrzamadi
f33428be03 Update the dependencies 2021-02-22 08:14:33 +06:00