Skip to content

Commit

Permalink
Added the parameter business_connection_id to the method stopPoll, al…
Browse files Browse the repository at this point in the history
…lowing the bot to stop polls it sent on behalf of a business account.
  • Loading branch information
coder2020official committed Jun 18, 2024
1 parent 67e2ec5 commit c7130d5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5418,7 +5418,8 @@ def send_poll(

def stop_poll(
self, chat_id: Union[int, str], message_id: int,
reply_markup: Optional[types.InlineKeyboardMarkup]=None) -> types.Poll:
reply_markup: Optional[types.InlineKeyboardMarkup]=None,
business_connection_id: Optional[str]=None) -> types.Poll:
"""
Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
Expand All @@ -5433,11 +5434,14 @@ def stop_poll(
:param reply_markup: A JSON-serialized object for a new message markup.
:type reply_markup: :obj:`InlineKeyboardMarkup`
:param business_connection_id: Identifier of the business connection to use for the poll
:type business_connection_id: :obj:`str`
:return: On success, the stopped Poll is returned.
:rtype: :obj:`types.Poll`
"""
return types.Poll.de_json(
apihelper.stop_poll(self.token, chat_id, message_id, reply_markup=reply_markup)
apihelper.stop_poll(self.token, chat_id, message_id, reply_markup=reply_markup, business_connection_id=business_connection_id)
)


Expand Down
4 changes: 3 additions & 1 deletion telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1997,11 +1997,13 @@ def get_forum_topic_icon_stickers(token):
method_url = r'getForumTopicIconStickers'
return _make_request(token, method_url)

def stop_poll(token, chat_id, message_id, reply_markup=None):
def stop_poll(token, chat_id, message_id, reply_markup=None, business_connection_id=None):
method_url = r'stopPoll'
payload = {'chat_id': str(chat_id), 'message_id': message_id}
if reply_markup:
payload['reply_markup'] = _convert_markup(reply_markup)
if business_connection_id:
payload['business_connection_id'] = business_connection_id
return _make_request(token, method_url, params=payload)

def edit_general_forum_topic(token, chat_id, name):
Expand Down
8 changes: 6 additions & 2 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6746,7 +6746,8 @@ async def send_poll(

async def stop_poll(
self, chat_id: Union[int, str], message_id: int,
reply_markup: Optional[types.InlineKeyboardMarkup]=None) -> types.Poll:
reply_markup: Optional[types.InlineKeyboardMarkup]=None,
business_connection_id: Optional[str]=None) -> types.Poll:
"""
Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
Expand All @@ -6761,10 +6762,13 @@ async def stop_poll(
:param reply_markup: A JSON-serialized object for a new message markup.
:type reply_markup: :obj:`InlineKeyboardMarkup`
:param business_connection_id: Identifier of the business connection to send the message through
:type business_connection_id: :obj:`str`
:return: On success, the stopped Poll is returned.
:rtype: :obj:`types.Poll`
"""
return types.Poll.de_json(await asyncio_helper.stop_poll(self.token, chat_id, message_id, reply_markup))
return types.Poll.de_json(await asyncio_helper.stop_poll(self.token, chat_id, message_id, reply_markup, business_connection_id))

async def answer_shipping_query(
self, shipping_query_id: str, ok: bool,
Expand Down
4 changes: 3 additions & 1 deletion telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2084,11 +2084,13 @@ def wrapper(key, val):

return wrapper

async def stop_poll(token, chat_id, message_id, reply_markup=None):
async def stop_poll(token, chat_id, message_id, reply_markup=None, business_connection_id=None):
method_url = r'stopPoll'
payload = {'chat_id': str(chat_id), 'message_id': message_id}
if reply_markup:
payload['reply_markup'] = await _convert_markup(reply_markup)
if business_connection_id:
payload['business_connection_id'] = business_connection_id
return await _process_request(token, method_url, params=payload)

# exceptions
Expand Down

0 comments on commit c7130d5

Please sign in to comment.