ferogram 0.4.0__tar.gz → 0.4.1__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.
Files changed (99) hide show
  1. ferogram-0.4.1/.readthedocs.yaml +35 -0
  2. {ferogram-0.4.0 → ferogram-0.4.1}/Cargo.lock +23 -12
  3. {ferogram-0.4.0 → ferogram-0.4.1}/Cargo.toml +2 -2
  4. {ferogram-0.4.0 → ferogram-0.4.1}/PKG-INFO +1 -1
  5. {ferogram-0.4.0 → ferogram-0.4.1}/pyproject.toml +1 -1
  6. {ferogram-0.4.0 → ferogram-0.4.1}/src/client.rs +27 -15
  7. {ferogram-0.4.0 → ferogram-0.4.1}/.github/workflows/compile-check.yml +0 -0
  8. {ferogram-0.4.0 → ferogram-0.4.1}/.github/workflows/publish.yml +0 -0
  9. {ferogram-0.4.0 → ferogram-0.4.1}/.gitignore +0 -0
  10. {ferogram-0.4.0 → ferogram-0.4.1}/CHANGELOG.md +0 -0
  11. {ferogram-0.4.0 → ferogram-0.4.1}/FEATURES.md +0 -0
  12. {ferogram-0.4.0 → ferogram-0.4.1}/LICENSE-APACHE +0 -0
  13. {ferogram-0.4.0 → ferogram-0.4.1}/LICENSE-MIT +0 -0
  14. {ferogram-0.4.0 → ferogram-0.4.1}/README.md +0 -0
  15. {ferogram-0.4.0 → ferogram-0.4.1}/examples/admin_tools.py +0 -0
  16. {ferogram-0.4.0 → ferogram-0.4.1}/examples/command_bot.py +0 -0
  17. {ferogram-0.4.0 → ferogram-0.4.1}/examples/echo_bot.py +0 -0
  18. {ferogram-0.4.0 → ferogram-0.4.1}/examples/group_management.py +0 -0
  19. {ferogram-0.4.0 → ferogram-0.4.1}/examples/media_bot.py +0 -0
  20. {ferogram-0.4.0 → ferogram-0.4.1}/examples/raw_invoke.py +0 -0
  21. {ferogram-0.4.0 → ferogram-0.4.1}/examples/search_bot.py +0 -0
  22. {ferogram-0.4.0 → ferogram-0.4.1}/examples/send_hi.py +0 -0
  23. {ferogram-0.4.0 → ferogram-0.4.1}/examples/send_media.py +0 -0
  24. {ferogram-0.4.0 → ferogram-0.4.1}/examples/send_message.py +0 -0
  25. {ferogram-0.4.0 → ferogram-0.4.1}/examples/update_handlers.py +0 -0
  26. {ferogram-0.4.0 → ferogram-0.4.1}/examples/user_management.py +0 -0
  27. {ferogram-0.4.0 → ferogram-0.4.1}/examples/userbot.py +0 -0
  28. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/__init__.py +0 -0
  29. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/client.py +0 -0
  30. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/filters.py +0 -0
  31. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/logging.py +0 -0
  32. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/py.typed +0 -0
  33. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/__init__.py +0 -0
  34. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/api/__init__.py +0 -0
  35. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/api/functions.py +0 -0
  36. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/api/types.py +0 -0
  37. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/codegen.py +0 -0
  38. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/__init__.py +0 -0
  39. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/_tl_schema.py +0 -0
  40. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/__init__.py +0 -0
  41. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/account.py +0 -0
  42. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/aicompose.py +0 -0
  43. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/auth.py +0 -0
  44. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/bots.py +0 -0
  45. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/channels.py +0 -0
  46. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/chatlists.py +0 -0
  47. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/contacts.py +0 -0
  48. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/folders.py +0 -0
  49. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/fragment.py +0 -0
  50. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/help.py +0 -0
  51. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/langpack.py +0 -0
  52. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/messages.py +0 -0
  53. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/payments.py +0 -0
  54. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/phone.py +0 -0
  55. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/photos.py +0 -0
  56. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/premium.py +0 -0
  57. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/smsjobs.py +0 -0
  58. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/stats.py +0 -0
  59. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/stickers.py +0 -0
  60. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/stories.py +0 -0
  61. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/updates.py +0 -0
  62. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/upload.py +0 -0
  63. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/functions/users.py +0 -0
  64. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/__init__.py +0 -0
  65. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/_base.py +0 -0
  66. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/account.py +0 -0
  67. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/aicompose.py +0 -0
  68. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/auth.py +0 -0
  69. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/bots.py +0 -0
  70. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/channels.py +0 -0
  71. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/chatlists.py +0 -0
  72. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/contacts.py +0 -0
  73. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/fragment.py +0 -0
  74. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/help.py +0 -0
  75. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/messages.py +0 -0
  76. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/payments.py +0 -0
  77. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/phone.py +0 -0
  78. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/photos.py +0 -0
  79. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/premium.py +0 -0
  80. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/smsjobs.py +0 -0
  81. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/stats.py +0 -0
  82. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/stickers.py +0 -0
  83. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/storage.py +0 -0
  84. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/stories.py +0 -0
  85. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/updates.py +0 -0
  86. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/upload.py +0 -0
  87. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/generated/types/users.py +0 -0
  88. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/proxy.py +0 -0
  89. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw/tl.py +0 -0
  90. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/raw_api.tl +0 -0
  91. {ferogram-0.4.0 → ferogram-0.4.1}/ferogram/types.py +0 -0
  92. {ferogram-0.4.0 → ferogram-0.4.1}/src/auth.rs +0 -0
  93. {ferogram-0.4.0 → ferogram-0.4.1}/src/keyboards.rs +0 -0
  94. {ferogram-0.4.0 → ferogram-0.4.1}/src/lib.rs +0 -0
  95. {ferogram-0.4.0 → ferogram-0.4.1}/src/message.rs +0 -0
  96. {ferogram-0.4.0 → ferogram-0.4.1}/src/raw.rs +0 -0
  97. {ferogram-0.4.0 → ferogram-0.4.1}/src/session.rs +0 -0
  98. {ferogram-0.4.0 → ferogram-0.4.1}/src/types.rs +0 -0
  99. {ferogram-0.4.0 → ferogram-0.4.1}/src/updates.rs +0 -0
@@ -0,0 +1,35 @@
1
+ # Read the Docs configuration file for Sphinx projects
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version and other tools you might need
8
+ build:
9
+ os: ubuntu-24.04
10
+ tools:
11
+ python: "3.12"
12
+ # You can also specify other tool versions:
13
+ # nodejs: "20"
14
+ # rust: "1.70"
15
+ # golang: "1.20"
16
+
17
+ # Build documentation in the "docs/" directory with Sphinx
18
+ sphinx:
19
+ configuration: docs/conf.py
20
+ # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
21
+ # builder: "dirhtml"
22
+ # Fail on all warnings to avoid broken references
23
+ # fail_on_warning: true
24
+
25
+ # Optionally build your docs in additional formats such as PDF and ePub
26
+ # formats:
27
+ # - pdf
28
+ # - epub
29
+
30
+ # Optional but recommended, declare the Python requirements required
31
+ # to build your documentation
32
+ # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
33
+ # python:
34
+ # install:
35
+ # - requirements: docs/requirements.txt
@@ -458,7 +458,8 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
458
458
  [[package]]
459
459
  name = "ferogram"
460
460
  version = "0.6.0"
461
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
461
+ source = "registry+https://github.com/rust-lang/crates.io-index"
462
+ checksum = "35327fc700fc4884b847888970e571eadf9a788d759b005569517b0f3824dd96"
462
463
  dependencies = [
463
464
  "base64 0.22.1",
464
465
  "chrono",
@@ -493,7 +494,8 @@ dependencies = [
493
494
  [[package]]
494
495
  name = "ferogram-connect"
495
496
  version = "0.6.0"
496
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
497
+ source = "registry+https://github.com/rust-lang/crates.io-index"
498
+ checksum = "97fed37f5b36213d4e87a8a8ae9b277cf3e45022a701e428a771a5b25f73339c"
497
499
  dependencies = [
498
500
  "ferogram-crypto",
499
501
  "ferogram-mtproto",
@@ -512,7 +514,8 @@ dependencies = [
512
514
  [[package]]
513
515
  name = "ferogram-crypto"
514
516
  version = "0.6.0"
515
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
517
+ source = "registry+https://github.com/rust-lang/crates.io-index"
518
+ checksum = "0f78840bea359e02551316d3726f0735bec4528d18f7926cfbbd86f99a12980d"
516
519
  dependencies = [
517
520
  "aes",
518
521
  "ctr",
@@ -526,7 +529,8 @@ dependencies = [
526
529
  [[package]]
527
530
  name = "ferogram-fsm"
528
531
  version = "0.6.0"
529
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
532
+ source = "registry+https://github.com/rust-lang/crates.io-index"
533
+ checksum = "c220365f36c0b1cfa935cb104f7d853cb009ff693f82851472b3bbd1cbf5e6ce"
530
534
  dependencies = [
531
535
  "async-trait",
532
536
  "dashmap",
@@ -538,7 +542,8 @@ dependencies = [
538
542
  [[package]]
539
543
  name = "ferogram-mtproto"
540
544
  version = "0.6.0"
541
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
545
+ source = "registry+https://github.com/rust-lang/crates.io-index"
546
+ checksum = "3b1205fe74d0ca3123cc5bd6a75a67d9b440af631fa86ee0ff064491b4464a22"
542
547
  dependencies = [
543
548
  "ferogram-crypto",
544
549
  "ferogram-tl-types",
@@ -552,7 +557,8 @@ dependencies = [
552
557
  [[package]]
553
558
  name = "ferogram-mtsender"
554
559
  version = "0.6.0"
555
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
560
+ source = "registry+https://github.com/rust-lang/crates.io-index"
561
+ checksum = "ca3ca4efefba40e9fcf1dd984fb4396080ecafce8b600d25c309aea5c0e7e44f"
556
562
  dependencies = [
557
563
  "ferogram-connect",
558
564
  "ferogram-crypto",
@@ -571,7 +577,8 @@ dependencies = [
571
577
  [[package]]
572
578
  name = "ferogram-parsers"
573
579
  version = "0.6.0"
574
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
580
+ source = "registry+https://github.com/rust-lang/crates.io-index"
581
+ checksum = "4b83447f6024ffb119e2649c2cc1765f5783ae83e8834128f7c130ed1d0dbf3b"
575
582
  dependencies = [
576
583
  "ferogram-tl-types",
577
584
  "pulldown-cmark",
@@ -579,7 +586,7 @@ dependencies = [
579
586
 
580
587
  [[package]]
581
588
  name = "ferogram-py"
582
- version = "0.4.0"
589
+ version = "0.4.1"
583
590
  dependencies = [
584
591
  "ferogram",
585
592
  "hex",
@@ -591,7 +598,8 @@ dependencies = [
591
598
  [[package]]
592
599
  name = "ferogram-session"
593
600
  version = "0.6.0"
594
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
601
+ source = "registry+https://github.com/rust-lang/crates.io-index"
602
+ checksum = "e5ff2ce020b6907bfbb9ec7b438d8a9beb64e5aada12f557d4aa806db7612247"
595
603
  dependencies = [
596
604
  "base64 0.22.1",
597
605
  "libsql",
@@ -604,7 +612,8 @@ dependencies = [
604
612
  [[package]]
605
613
  name = "ferogram-tl-gen"
606
614
  version = "0.6.0"
607
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
615
+ source = "registry+https://github.com/rust-lang/crates.io-index"
616
+ checksum = "6f7bf83f361b3172b975729520730b7527649eaa4d459ccd80a1e164c26a32cd"
608
617
  dependencies = [
609
618
  "ferogram-tl-parser",
610
619
  ]
@@ -612,12 +621,14 @@ dependencies = [
612
621
  [[package]]
613
622
  name = "ferogram-tl-parser"
614
623
  version = "0.6.0"
615
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
624
+ source = "registry+https://github.com/rust-lang/crates.io-index"
625
+ checksum = "b856a12cceee44dd1182e364f470aae4988398a1bedcac2edc6b7e2228e25fe1"
616
626
 
617
627
  [[package]]
618
628
  name = "ferogram-tl-types"
619
629
  version = "0.6.0"
620
- source = "git+https://github.com/ankit-chaubey/ferogram?rev=8fcff584faf88e76fc501b057ca92c793f42883d#8fcff584faf88e76fc501b057ca92c793f42883d"
630
+ source = "registry+https://github.com/rust-lang/crates.io-index"
631
+ checksum = "0b4ed5f274f97fe97c62ffd3d3fdb5d5a9dfd30b0ab401dcb1fa07b530c60257"
621
632
  dependencies = [
622
633
  "ferogram-tl-gen",
623
634
  "ferogram-tl-parser",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "ferogram-py"
3
- version = "0.4.0"
3
+ version = "0.4.1"
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 = { git = "https://github.com/ankit-chaubey/ferogram", rev = "8fcff584faf88e76fc501b057ca92c793f42883d", features = ["sqlite-session", "libsql-session"] }
15
+ ferogram = { version = "0.6.0", features = ["sqlite-session", "libsql-session"] }
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"] }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ferogram
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "ferogram"
7
- version = "0.4.0"
7
+ version = "0.4.1"
8
8
  description = "Python wrapper for ferogram, blazing-fast Rust MTProto library for Telegram."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT OR Apache-2.0" }
@@ -375,7 +375,7 @@ impl Client {
375
375
  ) -> PyResult<Bound<'py, PyAny>> {
376
376
  let c = Arc::clone(&self.inner);
377
377
  future_into_py(py, async move {
378
- c.pin_message(peer, message_id, false)
378
+ c.pin_message(peer, message_id, true)
379
379
  .await
380
380
  .map_err(py_err)?;
381
381
  Ok(())
@@ -2435,12 +2435,22 @@ impl Client {
2435
2435
  ) -> PyResult<Bound<'py, PyAny>> {
2436
2436
  let c = Arc::clone(&self.inner);
2437
2437
  future_into_py(py, async move {
2438
- // In v0.5.0, get_poll_results was removed. Use get_poll_votes to
2439
- // fetch votes instead. The poll_hash parameter is no longer used.
2440
- c.get_poll_votes(peer, msg_id, None, 100, None)
2438
+ let result = c
2439
+ .get_poll_votes(peer, msg_id, None, 100, None)
2441
2440
  .await
2442
2441
  .map_err(py_err)?;
2443
- Ok(())
2442
+ let pairs: Vec<(i64, Vec<u8>)> = result
2443
+ .votes
2444
+ .into_iter()
2445
+ .map(|v| match v {
2446
+ tl::enums::MessagePeerVote::MessagePeerVote(x) => (x.peer.bare_id(), x.option),
2447
+ tl::enums::MessagePeerVote::InputOption(x) => (x.peer.bare_id(), vec![]),
2448
+ tl::enums::MessagePeerVote::Multiple(x) => {
2449
+ (x.peer.bare_id(), x.options.into_iter().flatten().collect())
2450
+ }
2451
+ })
2452
+ .collect();
2453
+ Ok(pairs)
2444
2454
  })
2445
2455
  }
2446
2456
 
@@ -2918,7 +2928,7 @@ impl Client {
2918
2928
  fn get_all_drafts<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
2919
2929
  let c = Arc::clone(&self.inner);
2920
2930
  future_into_py(py, async move {
2921
- c.clear_all_drafts().await.map_err(py_err)?;
2931
+ c.sync_drafts().await.map_err(py_err)?;
2922
2932
  Ok(())
2923
2933
  })
2924
2934
  }
@@ -3174,11 +3184,6 @@ impl Client {
3174
3184
  fn get_input_peer<'py>(&self, py: Python<'py>, peer_id: i64) -> PyResult<Bound<'py, PyAny>> {
3175
3185
  let c = Arc::clone(&self.inner);
3176
3186
  future_into_py(py, async move {
3177
- Python::with_gil(|py| {
3178
- let cache = pyo3::PyErr::take(py); // just to get py handle
3179
- drop(cache);
3180
- Ok::<_, pyo3::PyErr>(())
3181
- })?;
3182
3187
  // Build a Peer enum from the raw id using the same sign convention
3183
3188
  // as Telegram: positive = user, -100xxxx = channel, small neg = chat
3184
3189
  let peer = if peer_id > 0 {
@@ -3362,20 +3367,27 @@ impl Client {
3362
3367
  on_progress: Option<Bound<'py, pyo3::types::PyAny>>,
3363
3368
  ) -> PyResult<Bound<'py, PyAny>> {
3364
3369
  let c = Arc::clone(&self.inner);
3365
- // Capture the Python callable as a PyObject so it can cross the await boundary.
3366
- let _cb: Option<pyo3::PyObject> = on_progress.map(|f| f.into());
3370
+ let cb: Option<pyo3::PyObject> = on_progress.map(|f| f.into());
3367
3371
  future_into_py(py, async move {
3368
3372
  let msgs = c.get_messages(peer, &[msg_id]).await.map_err(py_err)?;
3369
3373
  let msg = msgs
3370
3374
  .into_iter()
3371
3375
  .next()
3372
3376
  .ok_or_else(|| py_err("message not found"))?;
3373
- // download_media_with_handle is not on IncomingMessage; use download_media.
3374
- // on_progress is accepted for API compatibility but not called per-chunk here.
3375
3377
  let found = msg.download_media(&path).await.map_err(py_err)?;
3376
3378
  if !found {
3377
3379
  return Err(py_err("no downloadable media in message"));
3378
3380
  }
3381
+ if let Some(ref f) = cb {
3382
+ let size = tokio::fs::metadata(&path)
3383
+ .await
3384
+ .map(|m| m.len())
3385
+ .unwrap_or(0);
3386
+ let _ = Python::with_gil(|py| -> PyResult<()> {
3387
+ f.call1(py, (size, size))?;
3388
+ Ok(())
3389
+ });
3390
+ }
3379
3391
  Ok(path)
3380
3392
  })
3381
3393
  }
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