mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Compare commits
4 Commits
8f41df0ee4
...
master
Author | SHA1 | Date | |
---|---|---|---|
e10517e088 | |||
1946393c36 | |||
0f52ca688f | |||
b18bcd494a |
@ -1,10 +1,11 @@
|
|||||||
from telebot.asyncio_storage.base_storage import StateStorageBase, StateContext
|
from telebot.asyncio_storage.base_storage import StateStorageBase, StateContext
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
redis_installed = True
|
redis_installed = True
|
||||||
|
is_actual_aioredis = False
|
||||||
try:
|
try:
|
||||||
import aioredis
|
import aioredis
|
||||||
|
is_actual_aioredis = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from redis import asyncio as aioredis
|
from redis import asyncio as aioredis
|
||||||
@ -23,10 +24,10 @@ class StateRedisStorage(StateStorageBase):
|
|||||||
if not redis_installed:
|
if not redis_installed:
|
||||||
raise ImportError('AioRedis is not installed. Install it via "pip install aioredis"')
|
raise ImportError('AioRedis is not installed. Install it via "pip install aioredis"')
|
||||||
|
|
||||||
|
if is_actual_aioredis:
|
||||||
aioredis_version = tuple(map(int, aioredis.__version__.split(".")[0]))
|
aioredis_version = tuple(map(int, aioredis.__version__.split(".")[0]))
|
||||||
if aioredis_version < (2,):
|
if aioredis_version < (2,):
|
||||||
raise ImportError('Invalid aioredis version. Aioredis version should be >= 2.0.0')
|
raise ImportError('Invalid aioredis version. Aioredis version should be >= 2.0.0')
|
||||||
self.redis = aioredis.Redis(host=host, port=port, db=db, password=password)
|
self.redis = aioredis.Redis(host=host, port=port, db=db, password=password)
|
||||||
|
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
@ -61,8 +61,8 @@ def escape_markdown(content: str) -> str:
|
|||||||
:rtype: :obj:`str`
|
:rtype: :obj:`str`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parse = re.sub(r"([_*\[\]()~`>\#\+\-=|\.!\{\}])", r"\\\1", content)
|
parse = re.sub(r"([_*\[\]()~`>\#\+\-=|\.!\{\}\\])", r"\\\1", content)
|
||||||
reparse = re.sub(r"\\\\([_*\[\]()~`>\#\+\-=|\.!\{\}])", r"\1", parse)
|
reparse = re.sub(r"\\\\([_*\[\]()~`>\#\+\-=|\.!\{\}\\])", r"\1", parse)
|
||||||
return reparse
|
return reparse
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user