Skip to content

Commit 612eda0

Browse files
Merge branch 'master' into badge
2 parents a0b0b9b + 96761f8 commit 612eda0

8 files changed

Lines changed: 704 additions & 607 deletions

File tree

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
copyright = f'2022-{datetime.now().year}, {author}'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '4.21.0'
25+
release = '4.22.0'
2626

2727

2828
# -- General configuration ---------------------------------------------------

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "pyTelegramBotAPI"
7-
version = "4.21.0"
7+
version = "4.22.0"
88
description = "Python Telegram bot api."
99
authors = [{name = "eternnoir", email = "eternnoir@gmail.com"}]
1010
license = {text = "GPL2"}

telebot/__init__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# random module to generate random string
2121
import random
2222
import string
23+
import copy
2324

2425
import ssl
2526

@@ -4640,7 +4641,7 @@ def set_chat_description(self, chat_id: Union[int, str], description: Optional[s
46404641

46414642
def pin_chat_message(
46424643
self, chat_id: Union[int, str], message_id: int,
4643-
disable_notification: Optional[bool]=False) -> bool:
4644+
disable_notification: Optional[bool]=False, business_connection_id: Optional[str]=None) -> bool:
46444645
"""
46454646
Use this method to pin a message in a supergroup.
46464647
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
@@ -4659,15 +4660,19 @@ def pin_chat_message(
46594660
to all group members about the new pinned message
46604661
:type disable_notification: :obj:`bool`
46614662
4663+
:param business_connection_id: Unique identifier of the business connection
4664+
:type business_connection_id: :obj:`str`
4665+
46624666
:return: True on success.
46634667
:rtype: :obj:`bool`
46644668
"""
46654669
disable_notification = self.disable_notification if (disable_notification is None) else disable_notification
46664670

4667-
return apihelper.pin_chat_message(self.token, chat_id, message_id, disable_notification=disable_notification)
4671+
return apihelper.pin_chat_message(self.token, chat_id, message_id, disable_notification=disable_notification,
4672+
business_connection_id=business_connection_id)
46684673

46694674

4670-
def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optional[int]=None) -> bool:
4675+
def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optional[int]=None, business_connection_id: Optional[str]=None) -> bool:
46714676
"""
46724677
Use this method to unpin specific pinned message in a supergroup chat.
46734678
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
@@ -4682,10 +4687,13 @@ def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optional[int]
46824687
:param message_id: Int: Identifier of a message to unpin
46834688
:type message_id: :obj:`int`
46844689
4690+
:param business_connection_id: Unique identifier of the business connection
4691+
:type business_connection_id: :obj:`str`
4692+
46854693
:return: True on success.
46864694
:rtype: :obj:`bool`
46874695
"""
4688-
return apihelper.unpin_chat_message(self.token, chat_id, message_id)
4696+
return apihelper.unpin_chat_message(self.token, chat_id, message_id, business_connection_id=business_connection_id)
46894697

46904698

46914699
def unpin_all_chat_messages(self, chat_id: Union[int, str]) -> bool:
@@ -8749,7 +8757,7 @@ def _run_middlewares_and_handler(self, message, handlers, middlewares, update_ty
87498757
logger.error("It is not allowed to pass data and values inside data to the handler. Check your handler: {}".format(handler['function']))
87508758
return
87518759
else:
8752-
data_copy = data.copy()
8760+
data_copy = copy.deepcopy(data)
87538761
for key in list(data_copy):
87548762
# remove data from data_copy if handler does not accept it
87558763
if key not in params:

telebot/apihelper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,19 +1386,23 @@ def set_chat_description(token, chat_id, description):
13861386
return _make_request(token, method_url, params=payload, method='post')
13871387

13881388

1389-
def pin_chat_message(token, chat_id, message_id, disable_notification=None):
1389+
def pin_chat_message(token, chat_id, message_id, disable_notification=None, business_connection_id=None):
13901390
method_url = 'pinChatMessage'
13911391
payload = {'chat_id': chat_id, 'message_id': message_id}
13921392
if disable_notification is not None:
13931393
payload['disable_notification'] = disable_notification
1394+
if business_connection_id:
1395+
payload['business_connection_id'] = business_connection_id
13941396
return _make_request(token, method_url, params=payload, method='post')
13951397

13961398

1397-
def unpin_chat_message(token, chat_id, message_id):
1399+
def unpin_chat_message(token, chat_id, message_id, business_connection_id=None):
13981400
method_url = 'unpinChatMessage'
13991401
payload = {'chat_id': chat_id}
14001402
if message_id:
14011403
payload['message_id'] = message_id
1404+
if business_connection_id:
1405+
payload['business_connection_id'] = business_connection_id
14021406
return _make_request(token, method_url, params=payload, method='post')
14031407

14041408

telebot/async_telebot.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import string
3333
import random
3434
import ssl
35-
35+
import copy
3636

3737
"""
3838
Module : telebot
@@ -558,7 +558,7 @@ async def _run_middlewares_and_handlers(self, message, handlers, middlewares, up
558558
logger.error("It is not allowed to pass data and values inside data to the handler. Check your handler: {}".format(handler['function']))
559559
return
560560
else:
561-
data_copy = data.copy()
561+
data_copy = copy.deepcopy(data)
562562
for key in list(data_copy):
563563
# remove data from data_copy if handler does not accept it
564564
if key not in params:
@@ -6023,7 +6023,7 @@ async def set_chat_description(self, chat_id: Union[int, str], description: Opti
60236023

60246024
async def pin_chat_message(
60256025
self, chat_id: Union[int, str], message_id: int,
6026-
disable_notification: Optional[bool]=False) -> bool:
6026+
disable_notification: Optional[bool]=False, business_connection_id: Optional[str]=None) -> bool:
60276027
"""
60286028
Use this method to pin a message in a supergroup.
60296029
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
@@ -6042,14 +6042,17 @@ async def pin_chat_message(
60426042
to all group members about the new pinned message
60436043
:type disable_notification: :obj:`bool`
60446044
6045+
:param business_connection_id: Unique identifier of the business connection
6046+
:type business_connection_id: :obj:`str`
6047+
60456048
:return: True on success.
60466049
:rtype: :obj:`bool`
60476050
"""
60486051
disable_notification = self.disable_notification if (disable_notification is None) else disable_notification
60496052

6050-
return await asyncio_helper.pin_chat_message(self.token, chat_id, message_id, disable_notification)
6053+
return await asyncio_helper.pin_chat_message(self.token, chat_id, message_id, disable_notification, business_connection_id)
60516054

6052-
async def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optional[int]=None) -> bool:
6055+
async def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optional[int]=None, business_connection_id: Optional[str]=None) -> bool:
60536056
"""
60546057
Use this method to unpin specific pinned message in a supergroup chat.
60556058
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
@@ -6064,10 +6067,13 @@ async def unpin_chat_message(self, chat_id: Union[int, str], message_id: Optiona
60646067
:param message_id: Int: Identifier of a message to unpin
60656068
:type message_id: :obj:`int`
60666069
6070+
:param business_connection_id: Unique identifier of the business connection
6071+
:type business_connection_id: :obj:`str`
6072+
60676073
:return: True on success.
60686074
:rtype: :obj:`bool`
60696075
"""
6070-
return await asyncio_helper.unpin_chat_message(self.token, chat_id, message_id)
6076+
return await asyncio_helper.unpin_chat_message(self.token, chat_id, message_id, business_connection_id)
60716077

60726078
async def unpin_all_chat_messages(self, chat_id: Union[int, str]) -> bool:
60736079
"""

telebot/asyncio_helper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,19 +1365,23 @@ async def set_chat_description(token, chat_id, description):
13651365
return await _process_request(token, method_url, params=payload, method='post')
13661366

13671367

1368-
async def pin_chat_message(token, chat_id, message_id, disable_notification=None):
1368+
async def pin_chat_message(token, chat_id, message_id, disable_notification=None, business_connection_id=None):
13691369
method_url = 'pinChatMessage'
13701370
payload = {'chat_id': chat_id, 'message_id': message_id}
13711371
if disable_notification is not None:
13721372
payload['disable_notification'] = disable_notification
1373+
if business_connection_id:
1374+
payload['business_connection_id'] = business_connection_id
13731375
return await _process_request(token, method_url, params=payload, method='post')
13741376

13751377

1376-
async def unpin_chat_message(token, chat_id, message_id):
1378+
async def unpin_chat_message(token, chat_id, message_id, business_connection_id=None):
13771379
method_url = 'unpinChatMessage'
13781380
payload = {'chat_id': chat_id}
13791381
if message_id:
13801382
payload['message_id'] = message_id
1383+
if business_connection_id:
1384+
payload['business_connection_id'] = business_connection_id
13811385
return await _process_request(token, method_url, params=payload, method='post')
13821386

13831387

0 commit comments

Comments
 (0)