diff --git a/botogram/objects/mixins.py b/botogram/objects/mixins.py index 61e9a6e..9a2e20b 100644 --- a/botogram/objects/mixins.py +++ b/botogram/objects/mixins.py @@ -416,6 +416,20 @@ def send_album(self, album=None, reply_to=None, notify=True): return albums.send() return albums + @_require_api + def set_title(self, title): + """Set a new chat title""" + if type(title) is not str or len(title) > 255 or len(title) < 1: + raise ValueError( + "The new chat title must be a string between" + + " 1 and 255 characters long" + ) + else: + return self._api.call("setChatTitle", { + "chat_id": self.id, + "title": title + }) + class MessageMixin: """Add some methods for messages""" diff --git a/docs/api/telegram.rst b/docs/api/telegram.rst index a83dcc0..0470be8 100644 --- a/docs/api/telegram.rst +++ b/docs/api/telegram.rst @@ -1558,6 +1558,15 @@ about its business. .. versionadded:: 0.6 + + .. py:method:: set_title(title) + + Set a new chat title. + + The bot must be an administrator with the correct rights for this method to work. + + :param str title: The new chat title, must be between 1 and 255 characters long + .. py:method:: set_photo(path) Set a new chat photo, by providing its path. diff --git a/docs/changelog/0.7.rst b/docs/changelog/0.7.rst index 6160a66..faa5ff8 100644 --- a/docs/changelog/0.7.rst +++ b/docs/changelog/0.7.rst @@ -99,6 +99,9 @@ New features * Added automatic type conversion for command arguments +* Added support for editing the chat title + + * New method :py:meth:`~Chat.set_title` Bug fixes ---------