51 строка
822 B
Python
51 строка
822 B
Python
from configparser import RawConfigParser
|
|
import os
|
|
|
|
from redis import Redis
|
|
|
|
|
|
cwd = os.getcwd()
|
|
config = RawConfigParser()
|
|
config.read(
|
|
filenames=os.path.join(
|
|
cwd,
|
|
'config.ini',
|
|
),
|
|
)
|
|
|
|
|
|
class Telegram:
|
|
token = config.get(
|
|
section='Telegram',
|
|
option='token',
|
|
)
|
|
|
|
|
|
class Dynamic:
|
|
@classmethod
|
|
def get(
|
|
cls,
|
|
key: str,
|
|
):
|
|
with Redis(
|
|
db=3,
|
|
) as redis:
|
|
return redis.get(
|
|
name=key,
|
|
)
|
|
|
|
@classmethod
|
|
def set(
|
|
cls,
|
|
key: str,
|
|
value,
|
|
):
|
|
with Redis(
|
|
db=3,
|
|
decode_responses=True,
|
|
) as redis:
|
|
redis.set(
|
|
name=key,
|
|
value=value,
|
|
)
|