ferogram 0.1.9__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ferogram-0.1.9 → ferogram-0.2.0}/Cargo.lock +73 -17
- {ferogram-0.1.9 → ferogram-0.2.0}/Cargo.toml +2 -2
- {ferogram-0.1.9 → ferogram-0.2.0}/PKG-INFO +1 -1
- {ferogram-0.1.9 → ferogram-0.2.0}/pyproject.toml +1 -1
- {ferogram-0.1.9 → ferogram-0.2.0}/src/auth.rs +23 -7
- {ferogram-0.1.9 → ferogram-0.2.0}/src/client.rs +33 -32
- {ferogram-0.1.9 → ferogram-0.2.0}/src/lib.rs +1 -1
- {ferogram-0.1.9 → ferogram-0.2.0}/src/message.rs +1 -1
- {ferogram-0.1.9 → ferogram-0.2.0}/src/updates.rs +8 -15
- {ferogram-0.1.9 → ferogram-0.2.0}/.github/workflows/publish.yml +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/.gitignore +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/FEATURES.md +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/LICENSE-APACHE +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/LICENSE-MIT +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/README.md +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/admin_tools.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/command_bot.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/echo_bot.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/group_management.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/media_bot.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/raw_invoke.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/search_bot.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/send_hi.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/send_media.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/send_message.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/update_handlers.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/user_management.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/examples/userbot.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/__init__.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/client.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/filters.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/logging.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/py.typed +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/__init__.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/api/__init__.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/api/functions.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/api/types.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/codegen.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/__init__.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/_tl_schema.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/__init__.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/account.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/auth.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/bots.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/channels.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/chatlists.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/contacts.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/folders.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/fragment.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/help.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/langpack.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/messages.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/payments.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/phone.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/photos.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/premium.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/smsjobs.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/stats.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/stickers.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/stories.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/updates.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/upload.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/functions/users.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/__init__.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/_base.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/account.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/auth.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/bots.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/channels.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/chatlists.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/contacts.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/fragment.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/help.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/messages.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/payments.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/phone.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/photos.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/premium.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/smsjobs.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/stats.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/stickers.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/storage.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/stories.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/updates.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/upload.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/generated/types/users.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/proxy.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw/tl.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/raw_api.tl +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/ferogram/types.py +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/src/raw.rs +0 -0
- {ferogram-0.1.9 → ferogram-0.2.0}/src/types.rs +0 -0
|
@@ -274,16 +274,19 @@ dependencies = [
|
|
|
274
274
|
|
|
275
275
|
[[package]]
|
|
276
276
|
name = "ferogram"
|
|
277
|
-
version = "0.3.
|
|
277
|
+
version = "0.3.8"
|
|
278
278
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
279
|
-
checksum = "
|
|
279
|
+
checksum = "532d1f9f37f3579db6e95c22e40231eff18ba4f20820ae38b7a75a6459466922"
|
|
280
280
|
dependencies = [
|
|
281
281
|
"async-trait",
|
|
282
282
|
"base64",
|
|
283
283
|
"chrono",
|
|
284
284
|
"dashmap",
|
|
285
|
+
"ferogram-connect",
|
|
285
286
|
"ferogram-crypto",
|
|
287
|
+
"ferogram-fsm",
|
|
286
288
|
"ferogram-mtproto",
|
|
289
|
+
"ferogram-mtsender",
|
|
287
290
|
"ferogram-parsers",
|
|
288
291
|
"ferogram-session",
|
|
289
292
|
"ferogram-tl-types",
|
|
@@ -309,11 +312,31 @@ dependencies = [
|
|
|
309
312
|
"tracing",
|
|
310
313
|
]
|
|
311
314
|
|
|
315
|
+
[[package]]
|
|
316
|
+
name = "ferogram-connect"
|
|
317
|
+
version = "0.3.8"
|
|
318
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
319
|
+
checksum = "736861a82c40ba25195d1037463d54ec4e329f9b1e235e8bbe360678a861eaae"
|
|
320
|
+
dependencies = [
|
|
321
|
+
"ferogram-crypto",
|
|
322
|
+
"ferogram-mtproto",
|
|
323
|
+
"ferogram-tl-types",
|
|
324
|
+
"flate2",
|
|
325
|
+
"getrandom 0.2.17",
|
|
326
|
+
"hmac",
|
|
327
|
+
"metrics",
|
|
328
|
+
"sha2",
|
|
329
|
+
"socket2 0.5.10",
|
|
330
|
+
"tokio",
|
|
331
|
+
"tokio-socks",
|
|
332
|
+
"tracing",
|
|
333
|
+
]
|
|
334
|
+
|
|
312
335
|
[[package]]
|
|
313
336
|
name = "ferogram-crypto"
|
|
314
|
-
version = "0.3.
|
|
337
|
+
version = "0.3.8"
|
|
315
338
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
316
|
-
checksum = "
|
|
339
|
+
checksum = "db48b92a5c0ee7462a2a921a2c0bdd24fbc43a6e5ed96d79c19cc2534831f1e7"
|
|
317
340
|
dependencies = [
|
|
318
341
|
"aes",
|
|
319
342
|
"ctr",
|
|
@@ -324,11 +347,24 @@ dependencies = [
|
|
|
324
347
|
"sha2",
|
|
325
348
|
]
|
|
326
349
|
|
|
350
|
+
[[package]]
|
|
351
|
+
name = "ferogram-fsm"
|
|
352
|
+
version = "0.3.8"
|
|
353
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
354
|
+
checksum = "b5ab042df109225226c6d0e679de054bf68154bd1a851ec7f0cfc2ca3fb420fc"
|
|
355
|
+
dependencies = [
|
|
356
|
+
"async-trait",
|
|
357
|
+
"dashmap",
|
|
358
|
+
"serde",
|
|
359
|
+
"serde_json",
|
|
360
|
+
"tokio",
|
|
361
|
+
]
|
|
362
|
+
|
|
327
363
|
[[package]]
|
|
328
364
|
name = "ferogram-mtproto"
|
|
329
|
-
version = "0.3.
|
|
365
|
+
version = "0.3.8"
|
|
330
366
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
331
|
-
checksum = "
|
|
367
|
+
checksum = "ab166b411950c2493b8da16ac12512e9ae17aecb7efee3f53be12b4b0c558462"
|
|
332
368
|
dependencies = [
|
|
333
369
|
"ferogram-crypto",
|
|
334
370
|
"ferogram-tl-types",
|
|
@@ -339,11 +375,31 @@ dependencies = [
|
|
|
339
375
|
"sha1",
|
|
340
376
|
]
|
|
341
377
|
|
|
378
|
+
[[package]]
|
|
379
|
+
name = "ferogram-mtsender"
|
|
380
|
+
version = "0.3.8"
|
|
381
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
382
|
+
checksum = "57b0dc5058983f9662555436af85cf33f0a30aefdd1896a0f74379f4ce3725cc"
|
|
383
|
+
dependencies = [
|
|
384
|
+
"ferogram-connect",
|
|
385
|
+
"ferogram-crypto",
|
|
386
|
+
"ferogram-mtproto",
|
|
387
|
+
"ferogram-session",
|
|
388
|
+
"ferogram-tl-types",
|
|
389
|
+
"flate2",
|
|
390
|
+
"getrandom 0.2.17",
|
|
391
|
+
"metrics",
|
|
392
|
+
"sha2",
|
|
393
|
+
"socket2 0.5.10",
|
|
394
|
+
"tokio",
|
|
395
|
+
"tracing",
|
|
396
|
+
]
|
|
397
|
+
|
|
342
398
|
[[package]]
|
|
343
399
|
name = "ferogram-parsers"
|
|
344
|
-
version = "0.3.
|
|
400
|
+
version = "0.3.8"
|
|
345
401
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
346
|
-
checksum = "
|
|
402
|
+
checksum = "ae3bff00615fe04f7194b3392329877217183f45fe4eea88c4f13316d2238477"
|
|
347
403
|
dependencies = [
|
|
348
404
|
"ferogram-tl-types",
|
|
349
405
|
"pulldown-cmark",
|
|
@@ -351,7 +407,7 @@ dependencies = [
|
|
|
351
407
|
|
|
352
408
|
[[package]]
|
|
353
409
|
name = "ferogram-py"
|
|
354
|
-
version = "0.
|
|
410
|
+
version = "0.2.0"
|
|
355
411
|
dependencies = [
|
|
356
412
|
"ferogram",
|
|
357
413
|
"hex",
|
|
@@ -362,9 +418,9 @@ dependencies = [
|
|
|
362
418
|
|
|
363
419
|
[[package]]
|
|
364
420
|
name = "ferogram-session"
|
|
365
|
-
version = "0.3.
|
|
421
|
+
version = "0.3.8"
|
|
366
422
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
367
|
-
checksum = "
|
|
423
|
+
checksum = "a33e4d826504cc88a184045ee375daec7df0e8193cc5495633e1001f76ee7829"
|
|
368
424
|
dependencies = [
|
|
369
425
|
"base64",
|
|
370
426
|
"tracing",
|
|
@@ -372,24 +428,24 @@ dependencies = [
|
|
|
372
428
|
|
|
373
429
|
[[package]]
|
|
374
430
|
name = "ferogram-tl-gen"
|
|
375
|
-
version = "0.3.
|
|
431
|
+
version = "0.3.8"
|
|
376
432
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
377
|
-
checksum = "
|
|
433
|
+
checksum = "a3791ca624d86bdf1d2cfee99d4238cfd9fbc9559cef4e1a089b12a7648e9ce3"
|
|
378
434
|
dependencies = [
|
|
379
435
|
"ferogram-tl-parser",
|
|
380
436
|
]
|
|
381
437
|
|
|
382
438
|
[[package]]
|
|
383
439
|
name = "ferogram-tl-parser"
|
|
384
|
-
version = "0.3.
|
|
440
|
+
version = "0.3.8"
|
|
385
441
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
386
|
-
checksum = "
|
|
442
|
+
checksum = "97a4c074abe63bc6bef7fe46796e75e9b08126cbec9debe2082a8774b15204a2"
|
|
387
443
|
|
|
388
444
|
[[package]]
|
|
389
445
|
name = "ferogram-tl-types"
|
|
390
|
-
version = "0.3.
|
|
446
|
+
version = "0.3.8"
|
|
391
447
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
392
|
-
checksum = "
|
|
448
|
+
checksum = "68ef7eab10bb0f30e6ccb1cfc8d24bc67036a4cd7197b9abd0798a6b229e6fd2"
|
|
393
449
|
dependencies = [
|
|
394
450
|
"ferogram-tl-gen",
|
|
395
451
|
"ferogram-tl-parser",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "ferogram-py"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
description = "Python bindings for ferogram (Rust MTProto)"
|
|
6
6
|
license = "MIT OR Apache-2.0"
|
|
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
|
|
|
12
12
|
|
|
13
13
|
[dependencies]
|
|
14
14
|
hex = "0.4"
|
|
15
|
-
ferogram = "0.3.
|
|
15
|
+
ferogram = "0.3.8"
|
|
16
16
|
pyo3 = { version = "0.24", features = ["extension-module", "abi3-py313"] }
|
|
17
17
|
pyo3-async-runtimes = { version = "0.24", features = ["tokio-runtime"] }
|
|
18
18
|
tokio = { version = "1", features = ["full"] }
|
|
@@ -45,21 +45,37 @@ pub struct ClientBuilder {
|
|
|
45
45
|
pub api_id: i32,
|
|
46
46
|
pub api_hash: String,
|
|
47
47
|
pub session: String,
|
|
48
|
+
pub allow_zero_hash: bool,
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
#[pymethods]
|
|
51
52
|
impl ClientBuilder {
|
|
53
|
+
/// For bots only: skip needing a cached access hash.
|
|
54
|
+
/// Do NOT enable on user accounts.
|
|
55
|
+
fn experimental_allow_zero_hash(mut slf: PyRefMut<'_, Self>) -> PyRefMut<'_, Self> {
|
|
56
|
+
slf.allow_zero_hash = true;
|
|
57
|
+
slf
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
fn connect<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
|
|
53
|
-
let (api_id, api_hash, session) =
|
|
54
|
-
|
|
61
|
+
let (api_id, api_hash, session, allow_zero_hash) = (
|
|
62
|
+
self.api_id,
|
|
63
|
+
self.api_hash.clone(),
|
|
64
|
+
self.session.clone(),
|
|
65
|
+
self.allow_zero_hash,
|
|
66
|
+
);
|
|
55
67
|
future_into_py(py, async move {
|
|
56
|
-
let
|
|
68
|
+
let mut builder = ferogram::Client::builder()
|
|
57
69
|
.api_id(api_id)
|
|
58
70
|
.api_hash(api_hash)
|
|
59
|
-
.session(session)
|
|
60
|
-
|
|
61
|
-
.
|
|
62
|
-
|
|
71
|
+
.session(session);
|
|
72
|
+
if allow_zero_hash {
|
|
73
|
+
builder = builder.experimental_features(ferogram::ExperimentalFeatures {
|
|
74
|
+
allow_zero_hash: true,
|
|
75
|
+
..Default::default()
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
let (client, shutdown) = builder.connect().await.map_err(py_err)?;
|
|
63
79
|
Ok(crate::client::make_client(client, shutdown))
|
|
64
80
|
})
|
|
65
81
|
}
|
|
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
|
|
18
18
|
use tokio::sync::Mutex;
|
|
19
19
|
|
|
20
20
|
use crate::{auth::*, message::from_incoming, py_err, types::*};
|
|
21
|
+
use ferogram::PeerExt;
|
|
21
22
|
use ferogram::tl;
|
|
22
23
|
|
|
23
24
|
#[pyclass]
|
|
@@ -78,6 +79,7 @@ impl Client {
|
|
|
78
79
|
api_id,
|
|
79
80
|
api_hash,
|
|
80
81
|
session,
|
|
82
|
+
allow_zero_hash: false,
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
|
|
@@ -238,8 +240,8 @@ impl Client {
|
|
|
238
240
|
fn send_to_self<'py>(&self, py: Python<'py>, text: String) -> PyResult<Bound<'py, PyAny>> {
|
|
239
241
|
let c = Arc::clone(&self.inner);
|
|
240
242
|
future_into_py(py, async move {
|
|
241
|
-
c.send_to_self(text).await.map_err(py_err)?;
|
|
242
|
-
Ok(())
|
|
243
|
+
let m = c.send_to_self(text).await.map_err(py_err)?;
|
|
244
|
+
Ok(from_incoming(m, Some(c)))
|
|
243
245
|
})
|
|
244
246
|
}
|
|
245
247
|
|
|
@@ -283,9 +285,14 @@ impl Client {
|
|
|
283
285
|
) -> PyResult<Bound<'py, PyAny>> {
|
|
284
286
|
let c = Arc::clone(&self.inner);
|
|
285
287
|
future_into_py(py, async move {
|
|
286
|
-
c.forward_messages(
|
|
287
|
-
|
|
288
|
-
|
|
288
|
+
c.forward_messages(
|
|
289
|
+
destination,
|
|
290
|
+
&message_ids,
|
|
291
|
+
source,
|
|
292
|
+
ferogram::ForwardOptions::default(),
|
|
293
|
+
)
|
|
294
|
+
.await
|
|
295
|
+
.map_err(py_err)?;
|
|
289
296
|
Ok(())
|
|
290
297
|
})
|
|
291
298
|
}
|
|
@@ -1340,7 +1347,12 @@ impl Client {
|
|
|
1340
1347
|
let c = Arc::clone(&self.inner);
|
|
1341
1348
|
future_into_py(py, async move {
|
|
1342
1349
|
let msgs = c
|
|
1343
|
-
.forward_messages(
|
|
1350
|
+
.forward_messages(
|
|
1351
|
+
destination,
|
|
1352
|
+
&message_ids,
|
|
1353
|
+
source,
|
|
1354
|
+
ferogram::ForwardOptions::default(),
|
|
1355
|
+
)
|
|
1344
1356
|
.await
|
|
1345
1357
|
.map_err(py_err)?;
|
|
1346
1358
|
Ok(msgs
|
|
@@ -2464,22 +2476,11 @@ impl Client {
|
|
|
2464
2476
|
let pairs: Vec<(i64, Vec<u8>)> = result
|
|
2465
2477
|
.votes
|
|
2466
2478
|
.into_iter()
|
|
2467
|
-
.map(|v| {
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
tl::enums::Peer::Channel(ch) => ch.channel_id,
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
match v {
|
|
2476
|
-
tl::enums::MessagePeerVote::MessagePeerVote(x) => {
|
|
2477
|
-
(peer_id(&x.peer), x.option)
|
|
2478
|
-
}
|
|
2479
|
-
tl::enums::MessagePeerVote::InputOption(x) => (peer_id(&x.peer), vec![]),
|
|
2480
|
-
tl::enums::MessagePeerVote::Multiple(x) => {
|
|
2481
|
-
(peer_id(&x.peer), x.options.into_iter().flatten().collect())
|
|
2482
|
-
}
|
|
2479
|
+
.map(|v| match v {
|
|
2480
|
+
tl::enums::MessagePeerVote::MessagePeerVote(x) => (x.peer.bare_id(), x.option),
|
|
2481
|
+
tl::enums::MessagePeerVote::InputOption(x) => (x.peer.bare_id(), vec![]),
|
|
2482
|
+
tl::enums::MessagePeerVote::Multiple(x) => {
|
|
2483
|
+
(x.peer.bare_id(), x.options.into_iter().flatten().collect())
|
|
2483
2484
|
}
|
|
2484
2485
|
})
|
|
2485
2486
|
.collect();
|
|
@@ -2551,22 +2552,22 @@ impl Client {
|
|
|
2551
2552
|
) -> PyResult<Bound<'py, PyAny>> {
|
|
2552
2553
|
let c = Arc::clone(&self.inner);
|
|
2553
2554
|
future_into_py(py, async move {
|
|
2554
|
-
let price_refs: Vec<(&str, i64)> =
|
|
2555
|
-
prices.iter().map(|(l, a)| (l.as_str(), *a)).collect();
|
|
2556
2555
|
let msg = c
|
|
2557
2556
|
.send_invoice(
|
|
2558
2557
|
peer,
|
|
2559
2558
|
title,
|
|
2560
2559
|
description,
|
|
2561
2560
|
payload,
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2561
|
+
ferogram::InvoiceOptions {
|
|
2562
|
+
currency,
|
|
2563
|
+
prices,
|
|
2564
|
+
photo_url,
|
|
2565
|
+
need_name,
|
|
2566
|
+
need_phone,
|
|
2567
|
+
need_email,
|
|
2568
|
+
need_shipping_address,
|
|
2569
|
+
is_flexible,
|
|
2570
|
+
},
|
|
2570
2571
|
)
|
|
2571
2572
|
.await
|
|
2572
2573
|
.map_err(py_err)?;
|
|
@@ -60,7 +60,7 @@ fn _ferogram(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
60
60
|
m.add_class::<updates::PollVote>()?;
|
|
61
61
|
m.add_class::<updates::BotStopped>()?;
|
|
62
62
|
m.add_class::<updates::RawUpdate>()?;
|
|
63
|
-
// new in 0.3.6
|
|
63
|
+
// new in 0.3.6 / updated in 0.3.7 (binding v0.2.0)
|
|
64
64
|
m.add_class::<types::ShippingQuery>()?;
|
|
65
65
|
m.add_class::<types::PreCheckoutQuery>()?;
|
|
66
66
|
m.add_class::<types::ChatBoost>()?;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// If you use or modify this code, keep this notice at the top of the file
|
|
12
12
|
// and include the LICENSE-MIT or LICENSE-APACHE file from this repository.
|
|
13
13
|
|
|
14
|
+
use ferogram::PeerExt;
|
|
14
15
|
use ferogram::tl;
|
|
15
16
|
use pyo3::prelude::*;
|
|
16
17
|
use pyo3_async_runtimes::tokio::future_into_py;
|
|
@@ -21,14 +22,6 @@ use crate::{message::from_incoming, py_err};
|
|
|
21
22
|
|
|
22
23
|
// helpers
|
|
23
24
|
|
|
24
|
-
fn peer_to_id(p: &tl::enums::Peer) -> i64 {
|
|
25
|
-
match p {
|
|
26
|
-
tl::enums::Peer::User(u) => u.user_id,
|
|
27
|
-
tl::enums::Peer::Chat(c) => c.chat_id,
|
|
28
|
-
tl::enums::Peer::Channel(c) => c.channel_id,
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
25
|
fn reaction_str(r: &tl::enums::Reaction) -> String {
|
|
33
26
|
match r {
|
|
34
27
|
tl::enums::Reaction::Emoji(e) => e.emoticon.clone(),
|
|
@@ -378,7 +371,7 @@ pub fn update_to_py(
|
|
|
378
371
|
)
|
|
379
372
|
}
|
|
380
373
|
ferogram::update::Update::CallbackQuery(q) => {
|
|
381
|
-
let chat_id = q.chat_peer.as_ref().map(
|
|
374
|
+
let chat_id = q.chat_peer.as_ref().map(|p| p.bare_id());
|
|
382
375
|
ok!(
|
|
383
376
|
"callback_query",
|
|
384
377
|
CallbackQuery {
|
|
@@ -399,7 +392,7 @@ pub fn update_to_py(
|
|
|
399
392
|
user_id: q.user_id,
|
|
400
393
|
query: q.query,
|
|
401
394
|
offset: q.offset,
|
|
402
|
-
peer_id: q.peer.as_ref().map(
|
|
395
|
+
peer_id: q.peer.as_ref().map(|p| p.bare_id()),
|
|
403
396
|
}
|
|
404
397
|
)
|
|
405
398
|
}
|
|
@@ -437,7 +430,7 @@ pub fn update_to_py(
|
|
|
437
430
|
ok!(
|
|
438
431
|
"chat_action",
|
|
439
432
|
ChatAction {
|
|
440
|
-
peer_id:
|
|
433
|
+
peer_id: a.peer.bare_id(),
|
|
441
434
|
user_id: a.user_id,
|
|
442
435
|
action: action_str(&a.action).to_string(),
|
|
443
436
|
}
|
|
@@ -459,7 +452,7 @@ pub fn update_to_py(
|
|
|
459
452
|
ok!(
|
|
460
453
|
"join_request",
|
|
461
454
|
JoinRequest {
|
|
462
|
-
peer_id:
|
|
455
|
+
peer_id: r.peer.bare_id(),
|
|
463
456
|
user_id: r.user_id,
|
|
464
457
|
about: r.about,
|
|
465
458
|
date: r.date,
|
|
@@ -470,10 +463,10 @@ pub fn update_to_py(
|
|
|
470
463
|
ok!(
|
|
471
464
|
"message_reaction",
|
|
472
465
|
MessageReaction {
|
|
473
|
-
peer_id:
|
|
466
|
+
peer_id: r.peer.bare_id(),
|
|
474
467
|
msg_id: r.msg_id,
|
|
475
468
|
date: r.date,
|
|
476
|
-
actor_id:
|
|
469
|
+
actor_id: r.actor.bare_id(),
|
|
477
470
|
old_reactions: r.old_reactions.iter().map(reaction_str).collect(),
|
|
478
471
|
new_reactions: r.new_reactions.iter().map(reaction_str).collect(),
|
|
479
472
|
}
|
|
@@ -484,7 +477,7 @@ pub fn update_to_py(
|
|
|
484
477
|
"poll_vote",
|
|
485
478
|
PollVote {
|
|
486
479
|
poll_id: v.poll_id,
|
|
487
|
-
peer_id:
|
|
480
|
+
peer_id: v.peer.bare_id(),
|
|
488
481
|
positions: v.positions,
|
|
489
482
|
}
|
|
490
483
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|