diff --git a/slixmpp/plugins/xep_0084/stanza.py b/slixmpp/plugins/xep_0084/stanza.py index 4b6370ce..57754265 100644 --- a/slixmpp/plugins/xep_0084/stanza.py +++ b/slixmpp/plugins/xep_0084/stanza.py @@ -65,6 +65,35 @@ class Info(ElementBase): plugin_multi_attrib = 'items' interfaces = {'bytes', 'height', 'id', 'type', 'url', 'width'} + def _get_int(self, name: str) -> int: + try: + return int(self._get_attr(name)) + except ValueError: + return 0 + + def _set_int(self, name: str, value: int): + if value not in ('', None): + int(value) + self._set_attr(name, value) + + def get_bytes(self) -> int: + return self._get_int('bytes') + + def _set_bytes(self, value: int): + self._set_int('bytes', value) + + def get_height(self) -> int: + self._get_int('height') + + def set_height(self, value: int): + self._set_int('height', value) + + def get_width(self) -> int: + self._get_int(self, 'width') + + def set_width(self, value: int): + self._set_int('with', value) + class Pointer(ElementBase): name = 'pointer'