from typing import NamedTuple, List, Sequence from hippolyzer.lib.base.message.message import Message from hippolyzer.lib.base.templates import ChatType class RLVCommand(NamedTuple): behaviour: str param: str options: List[str] class RLVParser: @staticmethod def is_rlv_message(msg: Message) -> bool: chat: str = msg["ChatData"]["Message"] chat_type: int = msg["ChatData"]["ChatType"] return chat and chat.startswith("@") and chat_type == ChatType.OWNER @staticmethod def parse_chat(chat: str) -> List[RLVCommand]: assert chat.startswith("@") chat = chat.lstrip("@") commands = [] for command_str in chat.split(","): if not command_str: continue # RLV-style command, `(:;)?(=)?` # Roughly (?[^:=]+)(:(?