Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for setting the chat title #132

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions botogram/objects/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,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:
self._api.call("setChatTitle", {
Haloghen marked this conversation as resolved.
Show resolved Hide resolved
"chat_id": self.id,
"title": title
})


class MessageMixin:
"""Add some methods for messages"""
Expand Down
10 changes: 10 additions & 0 deletions docs/api/telegram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,16 @@ 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

.. versionadded:: 0.7

.. py:class:: botogram.ParsedText

This class contains the parsed representation of the text of a received
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog/0.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ New features
* New method :py:meth:`~Message.edit_live_location`
* New method :py:meth:`~Message.stop_live_location`

* Added support for editing the chat title

* New method :py:meth:`~Chat.set_title`

Bug fixes
---------