vk_chat_bot/utils.py

23 lines
489 B
Python

from calendar import timegm
from typing import Optional
from pymorphy3 import MorphAnalyzer
from time import gmtime
_morph = MorphAnalyzer()
def make_word_agree_with_number(n: int, word: str) -> str:
w = _morph.parse(word)[0]
return w.make_agree_with_number(n).word
def posix_time():
return timegm(gmtime())
def full_name(first_name: str, last_name: Optional[str]) -> str:
if last_name is not None:
return f"{first_name} {last_name}"
return first_name