patchpyro 2.1.0__tar.gz → 2.1.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.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: patchpyro
3
+ Version: 2.1.1
4
+ Summary: A modified pyromod by a.devh.in
5
+ Home-page: https://github.com/adityaprasad502/patchpyro
6
+ Author: Cezar H. & adityaprasad502
7
+ Author-email: plutoniumx502@gmail.com
8
+ License: LGPLv3+
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: COPYING
15
+ License-File: COPYING.lesser
16
+ License-File: NOTICE
17
+ Requires-Dist: kurigram>=2.0.69
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # PatchPyro
31
+
32
+ A fork of pyromod (renamed as patchpyro) providing conversation patches for Pyrogram-based clients.
33
+
34
+ ## Requirements
35
+ ```text
36
+ kurigram>=2.0.69
37
+ python>=3.9
38
+ ```
39
+
40
+ ## Installation
41
+ ```bash
42
+ pip install patchpyro
43
+ ```
44
+
45
+ ## Usage
46
+ Import `patchpyro` at least once in your script so you can use the modified Pyrogram in all files of the same process.
47
+
48
+ ### Example
49
+ ```python
50
+ # config.py
51
+ from patchpyro import listen # or import patchpyro.listen
52
+ from pyrogram import Client
53
+
54
+ listen.thank() # use this if your linter/IDE flags patchpyro as an unused import.
55
+
56
+ mybot = Client("mysession")
57
+ ```
58
+
59
+ ```python
60
+ # any other .py
61
+ from config import mybot
62
+ # no need to import patchpyro again; Pyrogram is already monkeypatched globally (in the same process)
63
+ ```
64
+
65
+ ## Available Methods
66
+ Just importing `patchpyro.listen` will automatically do the monkeypatch and you'll get these new methods:
67
+
68
+ ### `Chat.listen`, `User.listen`
69
+ - `await mybot.listen(chat_id, filters=None, timeout=30)`
70
+ - Awaits a new message in the specified chat and returns it.
71
+ - Raises `asyncio.TimeoutError` if timeout (optional parameter) occurs.
72
+ - You can pass Update Filters to the filters parameter just like you do for the update handlers.
73
+ - E.g. `filters=filters.photo & filters.bot`
74
+
75
+ ### `Chat.ask`, `User.ask`
76
+ - `await mybot.ask(text, chat_id, filters=None, timeout=30)`
77
+ - Same as `.listen()` above, but sends a message before awaiting.
78
+ - You can pass custom parameters to its internal `send_message()` call. Check the example below.
79
+
80
+ ### `Chat.asker`, `User.asker`
81
+ - `await mybot.asker(chat_id, filters=None, timeout=36)`
82
+ - Same as `.listen()` but `.asker()` returns `None` instead of raising `asyncio.TimeoutError`.
83
+ - Useful for graceful timeout handling, `.asker()` has a default timeout of 2 minutes (adjustable via `timeout` argument).
84
+
85
+ ## Examples
86
+
87
+ ### `asker()`
88
+ ```python
89
+ # ...
90
+ sendx = await client.send_message(chat_id, "`Send me your name:`")
91
+ answer = await client.asker(chat_id, filters=None, timeout=60)
92
+ if not answer: # `None` if timeout reached with no reply.
93
+ return await sendx.reply_text("How long should I wait? Bye!")
94
+ await answer.reply_text(f"{answer.text}, That's a cool name!")
95
+ # ...
96
+ ```
97
+
98
+ ### `ask()`
99
+ ```python
100
+ # ...
101
+ answer = await client.ask(chat_id, '*Send me your name:*', parse_mode=enums.ParseMode.MARKDOWN)
102
+ await client.send_message(chat_id, f'Your name is: {answer.text}')
103
+ # ...
104
+ ```
105
+
106
+ ## Copyright & License
107
+ This project includes code from:
108
+ - **[kurimod](https://github.com/ohmyarthur/kurimod)**: Monkeypatcher logic and modern async compatibility fixes.
109
+ - **Pyrogram**: Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <<https://github.com/delivrance>>
110
+ - **pyromod**: Original conversation patch logic.
111
+
112
+ Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
@@ -0,0 +1,83 @@
1
+ # PatchPyro
2
+
3
+ A fork of pyromod (renamed as patchpyro) providing conversation patches for Pyrogram-based clients.
4
+
5
+ ## Requirements
6
+ ```text
7
+ kurigram>=2.0.69
8
+ python>=3.9
9
+ ```
10
+
11
+ ## Installation
12
+ ```bash
13
+ pip install patchpyro
14
+ ```
15
+
16
+ ## Usage
17
+ Import `patchpyro` at least once in your script so you can use the modified Pyrogram in all files of the same process.
18
+
19
+ ### Example
20
+ ```python
21
+ # config.py
22
+ from patchpyro import listen # or import patchpyro.listen
23
+ from pyrogram import Client
24
+
25
+ listen.thank() # use this if your linter/IDE flags patchpyro as an unused import.
26
+
27
+ mybot = Client("mysession")
28
+ ```
29
+
30
+ ```python
31
+ # any other .py
32
+ from config import mybot
33
+ # no need to import patchpyro again; Pyrogram is already monkeypatched globally (in the same process)
34
+ ```
35
+
36
+ ## Available Methods
37
+ Just importing `patchpyro.listen` will automatically do the monkeypatch and you'll get these new methods:
38
+
39
+ ### `Chat.listen`, `User.listen`
40
+ - `await mybot.listen(chat_id, filters=None, timeout=30)`
41
+ - Awaits a new message in the specified chat and returns it.
42
+ - Raises `asyncio.TimeoutError` if timeout (optional parameter) occurs.
43
+ - You can pass Update Filters to the filters parameter just like you do for the update handlers.
44
+ - E.g. `filters=filters.photo & filters.bot`
45
+
46
+ ### `Chat.ask`, `User.ask`
47
+ - `await mybot.ask(text, chat_id, filters=None, timeout=30)`
48
+ - Same as `.listen()` above, but sends a message before awaiting.
49
+ - You can pass custom parameters to its internal `send_message()` call. Check the example below.
50
+
51
+ ### `Chat.asker`, `User.asker`
52
+ - `await mybot.asker(chat_id, filters=None, timeout=36)`
53
+ - Same as `.listen()` but `.asker()` returns `None` instead of raising `asyncio.TimeoutError`.
54
+ - Useful for graceful timeout handling, `.asker()` has a default timeout of 2 minutes (adjustable via `timeout` argument).
55
+
56
+ ## Examples
57
+
58
+ ### `asker()`
59
+ ```python
60
+ # ...
61
+ sendx = await client.send_message(chat_id, "`Send me your name:`")
62
+ answer = await client.asker(chat_id, filters=None, timeout=60)
63
+ if not answer: # `None` if timeout reached with no reply.
64
+ return await sendx.reply_text("How long should I wait? Bye!")
65
+ await answer.reply_text(f"{answer.text}, That's a cool name!")
66
+ # ...
67
+ ```
68
+
69
+ ### `ask()`
70
+ ```python
71
+ # ...
72
+ answer = await client.ask(chat_id, '*Send me your name:*', parse_mode=enums.ParseMode.MARKDOWN)
73
+ await client.send_message(chat_id, f'Your name is: {answer.text}')
74
+ # ...
75
+ ```
76
+
77
+ ## Copyright & License
78
+ This project includes code from:
79
+ - **[kurimod](https://github.com/ohmyarthur/kurimod)**: Monkeypatcher logic and modern async compatibility fixes.
80
+ - **Pyrogram**: Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <<https://github.com/delivrance>>
81
+ - **pyromod**: Original conversation patch logic.
82
+
83
+ Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
@@ -18,7 +18,7 @@ along with patchpyro. If not, see <https://www.gnu.org/licenses/>.
18
18
  """
19
19
 
20
20
 
21
- __version__ = "2.1.0"
21
+ __version__ = "2.1.1"
22
22
  # change in setup.py aswell
23
23
 
24
24
  from . import listen
@@ -17,11 +17,12 @@ You should have received a copy of the GNU General Public License
17
17
  along with patchpyro. If not, see <https://www.gnu.org/licenses/>.
18
18
  """
19
19
 
20
- from .listen import Chat, Client, MessageHandler, User
21
-
22
20
 
21
+ from .listen import Chat, Client, MessageHandler, User
23
22
  def thank() -> None:
24
23
  """A dummy function to prevent patchpyro.listen from being removed by formatters and linters."""
25
24
  from patchpyro import __version__
25
+ import logging
26
+ logging.debug(f"Thank you for using patchpyro v{__version__}!")
26
27
 
27
28
  __all__ = ["Chat", "Client", "MessageHandler", "User", "thank"]
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: patchpyro
3
+ Version: 2.1.1
4
+ Summary: A modified pyromod by a.devh.in
5
+ Home-page: https://github.com/adityaprasad502/patchpyro
6
+ Author: Cezar H. & adityaprasad502
7
+ Author-email: plutoniumx502@gmail.com
8
+ License: LGPLv3+
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: COPYING
15
+ License-File: COPYING.lesser
16
+ License-File: NOTICE
17
+ Requires-Dist: kurigram>=2.0.69
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # PatchPyro
31
+
32
+ A fork of pyromod (renamed as patchpyro) providing conversation patches for Pyrogram-based clients.
33
+
34
+ ## Requirements
35
+ ```text
36
+ kurigram>=2.0.69
37
+ python>=3.9
38
+ ```
39
+
40
+ ## Installation
41
+ ```bash
42
+ pip install patchpyro
43
+ ```
44
+
45
+ ## Usage
46
+ Import `patchpyro` at least once in your script so you can use the modified Pyrogram in all files of the same process.
47
+
48
+ ### Example
49
+ ```python
50
+ # config.py
51
+ from patchpyro import listen # or import patchpyro.listen
52
+ from pyrogram import Client
53
+
54
+ listen.thank() # use this if your linter/IDE flags patchpyro as an unused import.
55
+
56
+ mybot = Client("mysession")
57
+ ```
58
+
59
+ ```python
60
+ # any other .py
61
+ from config import mybot
62
+ # no need to import patchpyro again; Pyrogram is already monkeypatched globally (in the same process)
63
+ ```
64
+
65
+ ## Available Methods
66
+ Just importing `patchpyro.listen` will automatically do the monkeypatch and you'll get these new methods:
67
+
68
+ ### `Chat.listen`, `User.listen`
69
+ - `await mybot.listen(chat_id, filters=None, timeout=30)`
70
+ - Awaits a new message in the specified chat and returns it.
71
+ - Raises `asyncio.TimeoutError` if timeout (optional parameter) occurs.
72
+ - You can pass Update Filters to the filters parameter just like you do for the update handlers.
73
+ - E.g. `filters=filters.photo & filters.bot`
74
+
75
+ ### `Chat.ask`, `User.ask`
76
+ - `await mybot.ask(text, chat_id, filters=None, timeout=30)`
77
+ - Same as `.listen()` above, but sends a message before awaiting.
78
+ - You can pass custom parameters to its internal `send_message()` call. Check the example below.
79
+
80
+ ### `Chat.asker`, `User.asker`
81
+ - `await mybot.asker(chat_id, filters=None, timeout=36)`
82
+ - Same as `.listen()` but `.asker()` returns `None` instead of raising `asyncio.TimeoutError`.
83
+ - Useful for graceful timeout handling, `.asker()` has a default timeout of 2 minutes (adjustable via `timeout` argument).
84
+
85
+ ## Examples
86
+
87
+ ### `asker()`
88
+ ```python
89
+ # ...
90
+ sendx = await client.send_message(chat_id, "`Send me your name:`")
91
+ answer = await client.asker(chat_id, filters=None, timeout=60)
92
+ if not answer: # `None` if timeout reached with no reply.
93
+ return await sendx.reply_text("How long should I wait? Bye!")
94
+ await answer.reply_text(f"{answer.text}, That's a cool name!")
95
+ # ...
96
+ ```
97
+
98
+ ### `ask()`
99
+ ```python
100
+ # ...
101
+ answer = await client.ask(chat_id, '*Send me your name:*', parse_mode=enums.ParseMode.MARKDOWN)
102
+ await client.send_message(chat_id, f'Your name is: {answer.text}')
103
+ # ...
104
+ ```
105
+
106
+ ## Copyright & License
107
+ This project includes code from:
108
+ - **[kurimod](https://github.com/ohmyarthur/kurimod)**: Monkeypatcher logic and modern async compatibility fixes.
109
+ - **Pyrogram**: Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <<https://github.com/delivrance>>
110
+ - **pyromod**: Original conversation patch logic.
111
+
112
+ Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
patchpyro-2.1.0/PKG-INFO DELETED
@@ -1,115 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: patchpyro
3
- Version: 2.1.0
4
- Summary: A modified pyromod by a.devh.in
5
- Home-page: https://github.com/adityaprasad502/patchpyro
6
- Author: Cezar H. & adityaprasad502
7
- Author-email: plutoniumx502@gmail.com
8
- License: LGPLv3+
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.9
13
- Description-Content-Type: text/markdown
14
- License-File: COPYING
15
- License-File: COPYING.lesser
16
- License-File: NOTICE
17
- Requires-Dist: kurigram>=2.0.69
18
- Dynamic: author
19
- Dynamic: author-email
20
- Dynamic: classifier
21
- Dynamic: description
22
- Dynamic: description-content-type
23
- Dynamic: home-page
24
- Dynamic: license
25
- Dynamic: license-file
26
- Dynamic: requires-dist
27
- Dynamic: requires-python
28
- Dynamic: summary
29
-
30
- # PatchPyro
31
- ### This is a fork of pyromod (renamed as patchpyro) for personal usecases.
32
-
33
- ### Remember that this fork contains only conversation patch.
34
-
35
- # Requirements:
36
- ~~~python
37
- kurigram>=2.0.69
38
- python>=3.9
39
- ~~~
40
-
41
- # Installation:
42
- ```
43
- python -m pip install patchpyro
44
- ```
45
-
46
- # Usage:
47
- Import `patchpyro` at least one time in your script, so you'll be able to use modified pyrogram in all files of the same proccess.
48
- Example:
49
-
50
- ```python
51
- # config.py
52
- from patchpyro import listen # or import patchpyro.listen
53
- from pyrogram import Client
54
-
55
- listen.thank() # use this if ur linters/ide is removing patchpyro as unused import.
56
-
57
- mybot = Client("mysession")
58
- ```
59
-
60
- ```python
61
- # any other .py
62
- from config import mybot
63
- # no need to import patchpyro again pyrogram is already monkeypatched globally (at the same proccess)
64
- ```
65
-
66
- ## `patchpyro.listen`
67
- Just import it, it will automatically do the monkeypatch and you'll get these new methods:
68
-
69
- - Available bound methods::
70
- - `Chat.listen, User.listen`
71
-
72
- - `await mybot.listen(chat_id, filters=None, timeout=30)`
73
- - raises `asyncio.TimeoutError` if timeout (optional parameter)
74
- - Awaits for a new message in the specified chat and returns it.
75
- - You can pass Update Filters to the filters parameter just like you do for the update handlers.
76
- - E.g. `filters=filters.photo & filters.bot`
77
- - `Chat.ask, User.ask`
78
-
79
- - `await mybot.ask(text, chat_id, filters=None, timeout=30)`
80
- - Same of `.listen()` above, but sends a message before awaiting.
81
- - You can pass custom parameters to its send_message() call. Check the example below.
82
-
83
- - `Chat.asker, User.asker`
84
- - `await mybot.asker(chat_id, filters=None, timeout=36)`
85
- - same as `.listen()` but `.asker()` returns `None` instead of raising `asyncio.TimeoutError`.
86
- - Found useful in some cases for me, `.asker()` has a default timeout of 2 minutes.
87
- - You can adjust it by passing as a argument. Refer the example code given below.
88
-
89
- # Examples:
90
- ### For .asker():
91
- ```python
92
- ...
93
- sendx = await client.send_message(chat_id, "`Send me your name:`")
94
- answer = await client.asker(chat_id, filters=None, timeout=60)
95
- if not answer: # `None` if timeout if no reply received.
96
- return await sendx.reply_text("How long should I wait?, Eh! Bye!")
97
- await answer.reply_text(f"{answer.text}, That's a cool name!")
98
- ...
99
- ```
100
- ### For .ask():
101
- ```python
102
- ...
103
- answer = await client.ask(chat_id, '*Send me your name:*', parse_mode=enums.ParseMode.MARKDOWN)
104
- await client.send_message(chat_id, f'Your name is: {answer.text}')
105
- ...
106
- ```
107
-
108
-
109
- ### Copyright & License
110
- This project includes code from:
111
- - **[kurimod](https://github.com/ohmyarthur/kurimod)**: Monkeypatcher logic and modern async compatibility fixes.
112
- - **Pyrogram**: Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <<https://github.com/delivrance>>
113
- - **pyromod**: Original conversation patch logic.
114
-
115
- Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
patchpyro-2.1.0/README.md DELETED
@@ -1,86 +0,0 @@
1
- # PatchPyro
2
- ### This is a fork of pyromod (renamed as patchpyro) for personal usecases.
3
-
4
- ### Remember that this fork contains only conversation patch.
5
-
6
- # Requirements:
7
- ~~~python
8
- kurigram>=2.0.69
9
- python>=3.9
10
- ~~~
11
-
12
- # Installation:
13
- ```
14
- python -m pip install patchpyro
15
- ```
16
-
17
- # Usage:
18
- Import `patchpyro` at least one time in your script, so you'll be able to use modified pyrogram in all files of the same proccess.
19
- Example:
20
-
21
- ```python
22
- # config.py
23
- from patchpyro import listen # or import patchpyro.listen
24
- from pyrogram import Client
25
-
26
- listen.thank() # use this if ur linters/ide is removing patchpyro as unused import.
27
-
28
- mybot = Client("mysession")
29
- ```
30
-
31
- ```python
32
- # any other .py
33
- from config import mybot
34
- # no need to import patchpyro again pyrogram is already monkeypatched globally (at the same proccess)
35
- ```
36
-
37
- ## `patchpyro.listen`
38
- Just import it, it will automatically do the monkeypatch and you'll get these new methods:
39
-
40
- - Available bound methods::
41
- - `Chat.listen, User.listen`
42
-
43
- - `await mybot.listen(chat_id, filters=None, timeout=30)`
44
- - raises `asyncio.TimeoutError` if timeout (optional parameter)
45
- - Awaits for a new message in the specified chat and returns it.
46
- - You can pass Update Filters to the filters parameter just like you do for the update handlers.
47
- - E.g. `filters=filters.photo & filters.bot`
48
- - `Chat.ask, User.ask`
49
-
50
- - `await mybot.ask(text, chat_id, filters=None, timeout=30)`
51
- - Same of `.listen()` above, but sends a message before awaiting.
52
- - You can pass custom parameters to its send_message() call. Check the example below.
53
-
54
- - `Chat.asker, User.asker`
55
- - `await mybot.asker(chat_id, filters=None, timeout=36)`
56
- - same as `.listen()` but `.asker()` returns `None` instead of raising `asyncio.TimeoutError`.
57
- - Found useful in some cases for me, `.asker()` has a default timeout of 2 minutes.
58
- - You can adjust it by passing as a argument. Refer the example code given below.
59
-
60
- # Examples:
61
- ### For .asker():
62
- ```python
63
- ...
64
- sendx = await client.send_message(chat_id, "`Send me your name:`")
65
- answer = await client.asker(chat_id, filters=None, timeout=60)
66
- if not answer: # `None` if timeout if no reply received.
67
- return await sendx.reply_text("How long should I wait?, Eh! Bye!")
68
- await answer.reply_text(f"{answer.text}, That's a cool name!")
69
- ...
70
- ```
71
- ### For .ask():
72
- ```python
73
- ...
74
- answer = await client.ask(chat_id, '*Send me your name:*', parse_mode=enums.ParseMode.MARKDOWN)
75
- await client.send_message(chat_id, f'Your name is: {answer.text}')
76
- ...
77
- ```
78
-
79
-
80
- ### Copyright & License
81
- This project includes code from:
82
- - **[kurimod](https://github.com/ohmyarthur/kurimod)**: Monkeypatcher logic and modern async compatibility fixes.
83
- - **Pyrogram**: Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <<https://github.com/delivrance>>
84
- - **pyromod**: Original conversation patch logic.
85
-
86
- Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
@@ -1,115 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: patchpyro
3
- Version: 2.1.0
4
- Summary: A modified pyromod by a.devh.in
5
- Home-page: https://github.com/adityaprasad502/patchpyro
6
- Author: Cezar H. & adityaprasad502
7
- Author-email: plutoniumx502@gmail.com
8
- License: LGPLv3+
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.9
13
- Description-Content-Type: text/markdown
14
- License-File: COPYING
15
- License-File: COPYING.lesser
16
- License-File: NOTICE
17
- Requires-Dist: kurigram>=2.0.69
18
- Dynamic: author
19
- Dynamic: author-email
20
- Dynamic: classifier
21
- Dynamic: description
22
- Dynamic: description-content-type
23
- Dynamic: home-page
24
- Dynamic: license
25
- Dynamic: license-file
26
- Dynamic: requires-dist
27
- Dynamic: requires-python
28
- Dynamic: summary
29
-
30
- # PatchPyro
31
- ### This is a fork of pyromod (renamed as patchpyro) for personal usecases.
32
-
33
- ### Remember that this fork contains only conversation patch.
34
-
35
- # Requirements:
36
- ~~~python
37
- kurigram>=2.0.69
38
- python>=3.9
39
- ~~~
40
-
41
- # Installation:
42
- ```
43
- python -m pip install patchpyro
44
- ```
45
-
46
- # Usage:
47
- Import `patchpyro` at least one time in your script, so you'll be able to use modified pyrogram in all files of the same proccess.
48
- Example:
49
-
50
- ```python
51
- # config.py
52
- from patchpyro import listen # or import patchpyro.listen
53
- from pyrogram import Client
54
-
55
- listen.thank() # use this if ur linters/ide is removing patchpyro as unused import.
56
-
57
- mybot = Client("mysession")
58
- ```
59
-
60
- ```python
61
- # any other .py
62
- from config import mybot
63
- # no need to import patchpyro again pyrogram is already monkeypatched globally (at the same proccess)
64
- ```
65
-
66
- ## `patchpyro.listen`
67
- Just import it, it will automatically do the monkeypatch and you'll get these new methods:
68
-
69
- - Available bound methods::
70
- - `Chat.listen, User.listen`
71
-
72
- - `await mybot.listen(chat_id, filters=None, timeout=30)`
73
- - raises `asyncio.TimeoutError` if timeout (optional parameter)
74
- - Awaits for a new message in the specified chat and returns it.
75
- - You can pass Update Filters to the filters parameter just like you do for the update handlers.
76
- - E.g. `filters=filters.photo & filters.bot`
77
- - `Chat.ask, User.ask`
78
-
79
- - `await mybot.ask(text, chat_id, filters=None, timeout=30)`
80
- - Same of `.listen()` above, but sends a message before awaiting.
81
- - You can pass custom parameters to its send_message() call. Check the example below.
82
-
83
- - `Chat.asker, User.asker`
84
- - `await mybot.asker(chat_id, filters=None, timeout=36)`
85
- - same as `.listen()` but `.asker()` returns `None` instead of raising `asyncio.TimeoutError`.
86
- - Found useful in some cases for me, `.asker()` has a default timeout of 2 minutes.
87
- - You can adjust it by passing as a argument. Refer the example code given below.
88
-
89
- # Examples:
90
- ### For .asker():
91
- ```python
92
- ...
93
- sendx = await client.send_message(chat_id, "`Send me your name:`")
94
- answer = await client.asker(chat_id, filters=None, timeout=60)
95
- if not answer: # `None` if timeout if no reply received.
96
- return await sendx.reply_text("How long should I wait?, Eh! Bye!")
97
- await answer.reply_text(f"{answer.text}, That's a cool name!")
98
- ...
99
- ```
100
- ### For .ask():
101
- ```python
102
- ...
103
- answer = await client.ask(chat_id, '*Send me your name:*', parse_mode=enums.ParseMode.MARKDOWN)
104
- await client.send_message(chat_id, f'Your name is: {answer.text}')
105
- ...
106
- ```
107
-
108
-
109
- ### Copyright & License
110
- This project includes code from:
111
- - **[kurimod](https://github.com/ohmyarthur/kurimod)**: Monkeypatcher logic and modern async compatibility fixes.
112
- - **Pyrogram**: Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <<https://github.com/delivrance>>
113
- - **pyromod**: Original conversation patch logic.
114
-
115
- Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
File without changes
File without changes
File without changes
File without changes
File without changes