@@ -131,6 +131,18 @@ class TeleBot:
131131
132132 :param use_class_middlewares: Use class middlewares, defaults to False
133133 :type use_class_middlewares: :obj:`bool`, optional
134+
135+ :param disable_web_page_preview: Default value for disable_web_page_preview, defaults to None
136+ :type disable_web_page_preview: :obj:`bool`, optional
137+
138+ :param disable_notification: Default value for disable_notification, defaults to None
139+ :type disable_notification: :obj:`bool`, optional
140+
141+ :param protect_content: Default value for protect_content, defaults to None
142+ :type protect_content: :obj:`bool`, optional
143+
144+ :param allow_sending_without_reply: Default value for allow_sending_without_reply, defaults to None
145+ :type allow_sending_without_reply: :obj:`bool`, optional
134146 """
135147
136148 def __init__ (
@@ -139,18 +151,32 @@ def __init__(
139151 next_step_backend : Optional [HandlerBackend ]= None , reply_backend : Optional [HandlerBackend ]= None ,
140152 exception_handler : Optional [ExceptionHandler ]= None , last_update_id : Optional [int ]= 0 ,
141153 suppress_middleware_excepions : Optional [bool ]= False , state_storage : Optional [StateStorageBase ]= StateMemoryStorage (),
142- use_class_middlewares : Optional [bool ]= False
154+ use_class_middlewares : Optional [bool ]= False ,
155+ disable_web_page_preview : Optional [bool ]= None ,
156+ disable_notification : Optional [bool ]= None ,
157+ protect_content : Optional [bool ]= None ,
158+ allow_sending_without_reply : Optional [bool ]= None
143159 ):
160+
161+ # update-related
144162 self .token = token
145- self .parse_mode = parse_mode
146- self .update_listener = []
147- self .skip_pending = skip_pending
163+ self .skip_pending = skip_pending # backward compatibility
164+ self .last_update_id = last_update_id
165+
166+ # propertys
148167 self .suppress_middleware_excepions = suppress_middleware_excepions
168+ self .parse_mode = parse_mode
169+ self .disable_web_page_preview = disable_web_page_preview
170+ self .disable_notification = disable_notification
171+ self .protect_content = protect_content
172+ self .allow_sending_without_reply = allow_sending_without_reply
149173
174+ # threading-related
150175 self .__stop_polling = threading .Event ()
151- self .last_update_id = last_update_id
152176 self .exc_info = None
153177
178+ # states & register_next_step_handler
179+ self .current_states = state_storage
154180 self .next_step_backend = next_step_backend
155181 if not self .next_step_backend :
156182 self .next_step_backend = MemoryHandlerBackend ()
@@ -159,8 +185,9 @@ def __init__(
159185 if not self .reply_backend :
160186 self .reply_backend = MemoryHandlerBackend ()
161187
188+ # handlers
162189 self .exception_handler = exception_handler
163-
190+ self . update_listener = []
164191 self .message_handlers = []
165192 self .edited_message_handlers = []
166193 self .channel_post_handlers = []
@@ -178,8 +205,7 @@ def __init__(
178205 self .custom_filters = {}
179206 self .state_handlers = []
180207
181- self .current_states = state_storage
182-
208+ # middlewares
183209 self .use_class_middlewares = use_class_middlewares
184210 if apihelper .ENABLE_MIDDLEWARE and not use_class_middlewares :
185211 self .typed_middleware_handlers = {
@@ -205,6 +231,8 @@ def __init__(
205231 'You are using class based middlewares while having ENABLE_MIDDLEWARE set to True. This is not recommended.'
206232 )
207233 self .middlewares = [] if use_class_middlewares else None
234+
235+ # threads
208236 self .threaded = threaded
209237 if self .threaded :
210238 self .worker_pool = util .ThreadPool (self , num_threads = num_threads )
@@ -1440,6 +1468,10 @@ def send_message(
14401468 :rtype: :class:`telebot.types.Message`
14411469 """
14421470 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
1471+ disable_web_page_preview = self .disable_web_page_preview if (disable_web_page_preview is None ) else disable_web_page_preview
1472+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1473+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1474+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
14431475
14441476 return types .Message .de_json (
14451477 apihelper .send_message (
@@ -1478,6 +1510,9 @@ def forward_message(
14781510 :return: On success, the sent Message is returned.
14791511 :rtype: :class:`telebot.types.Message`
14801512 """
1513+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1514+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1515+
14811516 return types .Message .de_json (
14821517 apihelper .forward_message (self .token , chat_id , from_chat_id , message_id , disable_notification , timeout , protect_content ))
14831518
@@ -1540,6 +1575,11 @@ def copy_message(
15401575 :return: On success, the sent Message is returned.
15411576 :rtype: :class:`telebot.types.Message`
15421577 """
1578+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1579+ parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
1580+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1581+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
1582+
15431583 return types .MessageID .de_json (
15441584 apihelper .copy_message (self .token , chat_id , from_chat_id , message_id , caption , parse_mode , caption_entities ,
15451585 disable_notification , reply_to_message_id , allow_sending_without_reply , reply_markup ,
@@ -1617,6 +1657,10 @@ def send_dice(
16171657 :return: On success, the sent Message is returned.
16181658 :rtype: :class:`telebot.types.Message`
16191659 """
1660+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1661+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1662+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
1663+
16201664 return types .Message .de_json (
16211665 apihelper .send_dice (
16221666 self .token , chat_id , emoji , disable_notification , reply_to_message_id ,
@@ -1680,6 +1724,9 @@ def send_photo(
16801724 :rtype: :class:`telebot.types.Message`
16811725 """
16821726 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
1727+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1728+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1729+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
16831730
16841731 return types .Message .de_json (
16851732 apihelper .send_photo (
@@ -1765,6 +1812,9 @@ def send_audio(
17651812 :rtype: :class:`telebot.types.Message`
17661813 """
17671814 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
1815+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1816+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1817+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
17681818
17691819 return types .Message .de_json (
17701820 apihelper .send_audio (
@@ -1833,6 +1883,9 @@ def send_voice(
18331883 :return: On success, the sent Message is returned.
18341884 """
18351885 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
1886+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1887+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1888+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
18361889
18371890 return types .Message .de_json (
18381891 apihelper .send_voice (
@@ -1913,6 +1966,10 @@ def send_document(
19131966 :rtype: :class:`telebot.types.Message`
19141967 """
19151968 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
1969+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
1970+ protect_content = self .protect_content if (protect_content is None ) else protect_content
1971+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
1972+
19161973 if data and not (document ):
19171974 # function typo miss compatibility
19181975 document = data
@@ -1977,9 +2034,14 @@ def send_sticker(
19772034 :return: On success, the sent Message is returned.
19782035 :rtype: :class:`telebot.types.Message`
19792036 """
2037+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2038+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2039+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
2040+
19802041 if data and not (sticker ):
19812042 # function typo miss compatibility
19822043 sticker = data
2044+
19832045 return types .Message .de_json (
19842046 apihelper .send_data (
19852047 self .token , chat_id , sticker , 'sticker' ,
@@ -2067,6 +2129,10 @@ def send_video(
20672129 :rtype: :class:`telebot.types.Message`
20682130 """
20692131 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
2132+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2133+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2134+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
2135+
20702136 if data and not (video ):
20712137 # function typo miss compatibility
20722138 video = data
@@ -2153,6 +2219,9 @@ def send_animation(
21532219 :rtype: :class:`telebot.types.Message`
21542220 """
21552221 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
2222+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2223+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2224+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
21562225
21572226 return types .Message .de_json (
21582227 apihelper .send_animation (
@@ -2220,6 +2289,10 @@ def send_video_note(
22202289 :return: On success, the sent Message is returned.
22212290 :rtype: :class:`telebot.types.Message`
22222291 """
2292+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2293+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2294+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
2295+
22232296 return types .Message .de_json (
22242297 apihelper .send_video_note (
22252298 self .token , chat_id , data , duration , length , reply_to_message_id , reply_markup ,
@@ -2266,6 +2339,10 @@ def send_media_group(
22662339 :return: On success, an array of Messages that were sent is returned.
22672340 :rtype: List[types.Message]
22682341 """
2342+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2343+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2344+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
2345+
22692346 result = apihelper .send_media_group (
22702347 self .token , chat_id , media , disable_notification , reply_to_message_id , timeout ,
22712348 allow_sending_without_reply , protect_content )
@@ -2334,6 +2411,10 @@ def send_location(
23342411 :return: On success, the sent Message is returned.
23352412 :rtype: :class:`telebot.types.Message`
23362413 """
2414+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2415+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2416+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
2417+
23372418 return types .Message .de_json (
23382419 apihelper .send_location (
23392420 self .token , chat_id , latitude , longitude , live_period ,
@@ -2505,6 +2586,10 @@ def send_venue(
25052586 :return: On success, the sent Message is returned.
25062587 :rtype: :class:`telebot.types.Message`
25072588 """
2589+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2590+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2591+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
2592+
25082593 return types .Message .de_json (
25092594 apihelper .send_venue (
25102595 self .token , chat_id , latitude , longitude , title , address , foursquare_id , foursquare_type ,
@@ -2567,6 +2652,10 @@ def send_contact(
25672652 :return: On success, the sent Message is returned.
25682653 :rtype: :class:`telebot.types.Message`
25692654 """
2655+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
2656+ protect_content = self .protect_content if (protect_content is None ) else protect_content
2657+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
2658+
25702659 return types .Message .de_json (
25712660 apihelper .send_contact (
25722661 self .token , chat_id , phone_number , first_name , last_name , vcard ,
@@ -3318,6 +3407,8 @@ def pin_chat_message(
33183407 :return: True on success.
33193408 :rtype: :obj:`bool`
33203409 """
3410+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
3411+
33213412 return apihelper .pin_chat_message (self .token , chat_id , message_id , disable_notification )
33223413
33233414 def unpin_chat_message (self , chat_id : Union [int , str ], message_id : Optional [int ]= None ) -> bool :
@@ -3399,6 +3490,7 @@ def edit_message_text(
33993490 :rtype: :obj:`types.Message` or :obj:`bool`
34003491 """
34013492 parse_mode = self .parse_mode if (parse_mode is None ) else parse_mode
3493+ disable_web_page_preview = self .disable_web_page_preview if (disable_web_page_preview is None ) else disable_web_page_preview
34023494
34033495 result = apihelper .edit_message_text (self .token , text , chat_id , message_id , inline_message_id , parse_mode ,
34043496 entities , disable_web_page_preview , reply_markup )
@@ -3511,6 +3603,10 @@ def send_game(
35113603 :return: On success, the sent Message is returned.
35123604 :rtype: :obj:`types.Message`
35133605 """
3606+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
3607+ protect_content = self .protect_content if (protect_content is None ) else protect_content
3608+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
3609+
35143610 result = apihelper .send_game (
35153611 self .token , chat_id , game_short_name , disable_notification ,
35163612 reply_to_message_id , reply_markup , timeout ,
@@ -3713,6 +3809,10 @@ def send_invoice(
37133809 :return: On success, the sent Message is returned.
37143810 :rtype: :obj:`types.Message`
37153811 """
3812+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
3813+ protect_content = self .protect_content if (protect_content is None ) else protect_content
3814+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
3815+
37163816 result = apihelper .send_invoice (
37173817 self .token , chat_id , title , description , invoice_payload , provider_token ,
37183818 currency , prices , start_parameter , photo_url , photo_size , photo_width ,
@@ -3914,6 +4014,10 @@ def send_poll(
39144014 :return: On success, the sent Message is returned.
39154015 :rtype: :obj:`types.Message`
39164016 """
4017+ disable_notification = self .disable_notification if (disable_notification is None ) else disable_notification
4018+ protect_content = self .protect_content if (protect_content is None ) else protect_content
4019+ allow_sending_without_reply = self .allow_sending_without_reply if (allow_sending_without_reply is None ) else allow_sending_without_reply
4020+
39174021 if isinstance (question , types .Poll ):
39184022 raise RuntimeError ("The send_poll signature was changed, please see send_poll function details." )
39194023
0 commit comments