tgs / bot /utils /command.py
AZILS's picture
Upload 119 files
054900e verified
raw
history blame contribute delete
604 Bytes
from __future__ import annotations
def is_command(message: str | None) -> bool:
return bool(message and message.startswith("/"))
def find_command_argument(message: str | None) -> str | None:
"""Finds the value of argument in command message text.
Get string from Message.text.
Example:
>>> find_command_argument("/start referrer")
"referrer"
>>> find_command_argument("/start")
None
>>> find_command_argument("hi! it's me")
None
"""
if not is_command(message):
return None
return str(message).split()[1] if " " in str(message) else None