mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-02 05:24:51 +00:00
Add ainput function
This commit is contained in:
parent
3711437dbd
commit
26bb97af46
1 changed files with 10 additions and 0 deletions
|
|
@ -16,9 +16,12 @@
|
|||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
from base64 import b64decode, b64encode
|
||||
from concurrent.futures.thread import ThreadPoolExecutor
|
||||
from struct import pack
|
||||
from weakref import proxy
|
||||
|
||||
|
|
@ -57,6 +60,13 @@ class Str(str):
|
|||
return self._client.html.unparse(self, self._entities)
|
||||
|
||||
|
||||
async def ainput(prompt: str = ""):
|
||||
with ThreadPoolExecutor(1, "AsyncInput", lambda x: print(x, end="", flush=True), (prompt,)) as executor:
|
||||
return (await asyncio.get_event_loop().run_in_executor(
|
||||
executor, sys.stdin.readline
|
||||
)).rstrip()
|
||||
|
||||
|
||||
ENTITIES = {
|
||||
types.MessageEntityMention.ID: "mention",
|
||||
types.MessageEntityHashtag.ID: "hashtag",
|
||||
|
|
|
|||
Loading…
Reference in a new issue