2022-06-03 08:09:47 -06:00
|
|
|
import re
|
|
|
|
|
from typing import List, Union
|
|
|
|
|
|
2022-12-06 22:42:58 +08:00
|
|
|
uuid_regex = "[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"
|
|
|
|
|
TELEGRAM_VERIFICATION_CODE_REGEX = f"^{uuid_regex}_{uuid_regex}$"
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_verification_message(text: str) -> bool:
|
2022-10-25 14:53:07 +08:00
|
|
|
return bool(re.match(TELEGRAM_VERIFICATION_CODE_REGEX, text))
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class CallbackQueryFactory:
|
|
|
|
|
SEPARATOR = ":"
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def encode_data(cls, *args: Union[str, int]) -> str:
|
|
|
|
|
return cls.SEPARATOR.join(map(str, args))
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def decode_data(cls, data: str) -> List[str]:
|
|
|
|
|
return data.split(cls.SEPARATOR)
|