16 lines
406 B
Python
16 lines
406 B
Python
|
from dataclasses import dataclass
|
||
|
|
||
|
from pyrogram.types import CallbackQuery
|
||
|
|
||
|
|
||
|
@dataclass
|
||
|
class CallbackLanguage:
|
||
|
language: str
|
||
|
|
||
|
@classmethod
|
||
|
def from_callback(cls, callback: CallbackQuery):
|
||
|
action, language = str(callback.data).split(":")
|
||
|
if action.lower() != "language":
|
||
|
raise ValueError("Callback provided is not a language callback")
|
||
|
return cls(language)
|