from dataclasses import dataclass
from pyrogram.types import CallbackQuery
@dataclass
class CallbackVerify:
user_id: int
@classmethod
def from_callback(cls, callback: CallbackQuery):
action, user_id = str(callback.data).split(":")
if action.lower() != "verify":
raise ValueError("Callback provided is not a verification callback")
return cls(int(user_id))
class CallbackEmoji:
emoji: str
action, user_id, emoji = str(callback.data).split(":")
if action.lower() != "emoji":
raise ValueError("Callback provided is not an emoji button callback")
return cls(int(user_id), emoji)
class CallbackBan:
if action.lower() != "ban":
raise ValueError("Callback provided is not a ban callback")
class CallbackLanguage:
language: str
action, language = str(callback.data).split(":")
if action.lower() != "language":
raise ValueError("Callback provided is not a language callback")
return cls(language)