diff --git a/botogram/frozenbot.py b/botogram/frozenbot.py index 67afabc..beced73 100644 --- a/botogram/frozenbot.py +++ b/botogram/frozenbot.py @@ -121,12 +121,12 @@ def command(self, name): def send(self, chat, message, preview=True, reply_to=None, syntax=None, extra=None): """Send a message in a chat""" - obj = objects.GenericChat({"id": chat}, self.api) + obj = objects.Chat({"id": chat, type: ""}, self.api) obj.send(message, preview, reply_to, syntax, extra) def send_photo(self, chat, path, caption="", reply_to=None, extra=None): """Send a photo in a chat""" - obj = objects.GenericChat({"id": chat}, self.api) + obj = objects.GenericChat({"id": chat, type: ""}, self.api) obj.send_photo(path, caption, reply_to, extra) # Let's process the messages diff --git a/botogram/objects/__init__.py b/botogram/objects/__init__.py index c41286e..33f2613 100644 --- a/botogram/objects/__init__.py +++ b/botogram/objects/__init__.py @@ -15,14 +15,6 @@ class EmptyObject(BaseObject): pass -class GenericChat(BaseObject, mixins.ChatMixin): - """Internal representation of a generic chat""" - - required = { - "id": int, - } - - class User(BaseObject, mixins.ChatMixin): """Telegram API representation of an user @@ -39,15 +31,21 @@ class User(BaseObject, mixins.ChatMixin): } -class GroupChat(BaseObject, mixins.ChatMixin): - """Telegram API representation of a group chat +class Chat(BaseObject, mixins.ChatMixin): + """Telegram API representation of a chat - https://core.telegram.org/bots/api#groupchat + https://core.telegram.org/bots/api#chat """ required = { "id": int, + "type": str, + } + optional = { "title": str, + "username": str, + "first_name": str, + "last_name": str, } @@ -204,7 +202,7 @@ class Message(BaseObject, mixins.MessageMixin): "message_id": int, "from": User, "date": int, - "chat": one_of(User, GroupChat), + "chat": Chat, } optional = { "forward_from": User, diff --git a/tests/conftest.py b/tests/conftest.py index 7d7cddd..77929a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -67,6 +67,7 @@ def sample_update(request): "message_id": 2, "chat": { "id": -1, + "type": "group", "title": "test", }, "from": {