mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-02-16 18:31:45 +01:00
Merge pull request #195 from aidarbiktimirov/master
Added disable_notification parameter for silent messages
This commit is contained in:
commit
0c676b1a75
2 changed files with 63 additions and 0 deletions
|
@ -161,6 +161,10 @@ class Bot(TelegramObject):
|
||||||
reply_to_message_id = kwargs.get('reply_to_message_id')
|
reply_to_message_id = kwargs.get('reply_to_message_id')
|
||||||
data['reply_to_message_id'] = reply_to_message_id
|
data['reply_to_message_id'] = reply_to_message_id
|
||||||
|
|
||||||
|
if kwargs.get('disable_notification'):
|
||||||
|
disable_notification = kwargs.get('disable_notification')
|
||||||
|
data['disable_notification'] = disable_notification
|
||||||
|
|
||||||
if kwargs.get('reply_markup'):
|
if kwargs.get('reply_markup'):
|
||||||
reply_markup = kwargs.get('reply_markup')
|
reply_markup = kwargs.get('reply_markup')
|
||||||
if isinstance(reply_markup, ReplyMarkup):
|
if isinstance(reply_markup, ReplyMarkup):
|
||||||
|
@ -213,6 +217,10 @@ class Bot(TelegramObject):
|
||||||
UTF8 characters.
|
UTF8 characters.
|
||||||
disable_web_page_preview:
|
disable_web_page_preview:
|
||||||
Disables link previews for links in this message. [Optional]
|
Disables link previews for links in this message. [Optional]
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
@ -252,6 +260,10 @@ class Bot(TelegramObject):
|
||||||
- Chat id.
|
- Chat id.
|
||||||
message_id:
|
message_id:
|
||||||
Unique message identifier.
|
Unique message identifier.
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A telegram.Message instance representing the message forwarded.
|
A telegram.Message instance representing the message forwarded.
|
||||||
|
@ -288,6 +300,10 @@ class Bot(TelegramObject):
|
||||||
caption:
|
caption:
|
||||||
Photo caption (may also be used when resending photos by file_id).
|
Photo caption (may also be used when resending photos by file_id).
|
||||||
[Optional]
|
[Optional]
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
@ -342,6 +358,10 @@ class Bot(TelegramObject):
|
||||||
Performer of sent audio. [Optional]
|
Performer of sent audio. [Optional]
|
||||||
title:
|
title:
|
||||||
Title of sent audio. [Optional]
|
Title of sent audio. [Optional]
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
@ -386,6 +406,10 @@ class Bot(TelegramObject):
|
||||||
filename:
|
filename:
|
||||||
File name that shows in telegram message (it is usefull when you
|
File name that shows in telegram message (it is usefull when you
|
||||||
send file generated by temp module, for example). [Optional]
|
send file generated by temp module, for example). [Optional]
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
@ -422,6 +446,10 @@ class Bot(TelegramObject):
|
||||||
Sticker to send. You can either pass a file_id as String to resend
|
Sticker to send. You can either pass a file_id as String to resend
|
||||||
a sticker that is already on the Telegram servers, or upload a new
|
a sticker that is already on the Telegram servers, or upload a new
|
||||||
sticker using multipart/form-data.
|
sticker using multipart/form-data.
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
@ -466,6 +494,10 @@ class Bot(TelegramObject):
|
||||||
timeout:
|
timeout:
|
||||||
float. If this value is specified, use it as the definitive timeout
|
float. If this value is specified, use it as the definitive timeout
|
||||||
(in seconds) for urlopen() operations. [Optional]
|
(in seconds) for urlopen() operations. [Optional]
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
@ -512,6 +544,10 @@ class Bot(TelegramObject):
|
||||||
a new audio file using multipart/form-data.
|
a new audio file using multipart/form-data.
|
||||||
duration:
|
duration:
|
||||||
Duration of sent audio in seconds. [Optional]
|
Duration of sent audio in seconds. [Optional]
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
@ -549,6 +585,10 @@ class Bot(TelegramObject):
|
||||||
Latitude of location.
|
Latitude of location.
|
||||||
longitude:
|
longitude:
|
||||||
Longitude of location.
|
Longitude of location.
|
||||||
|
disable_notification:
|
||||||
|
Sends the message silently. iOS users will not receive
|
||||||
|
a notification, Android users will receive a notification
|
||||||
|
with no sound. Other apps coming soon. [Optional]
|
||||||
reply_to_message_id:
|
reply_to_message_id:
|
||||||
If the message is a reply, ID of the original message. [Optional]
|
If the message is a reply, ID of the original message. [Optional]
|
||||||
reply_markup:
|
reply_markup:
|
||||||
|
|
|
@ -61,6 +61,17 @@ class BotTest(BaseTest, unittest.TestCase):
|
||||||
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||||
self.assertTrue(isinstance(message.date, datetime))
|
self.assertTrue(isinstance(message.date, datetime))
|
||||||
|
|
||||||
|
@flaky(3, 1)
|
||||||
|
@timeout(10)
|
||||||
|
def testSilentSendMessage(self):
|
||||||
|
message = self._bot.sendMessage(chat_id=self._chat_id,
|
||||||
|
text='Моё судно на воздушной подушке полно угрей',
|
||||||
|
disable_notification=True)
|
||||||
|
|
||||||
|
self.assertTrue(self.is_json(message.to_json()))
|
||||||
|
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||||
|
self.assertTrue(isinstance(message.date, datetime))
|
||||||
|
|
||||||
@flaky(3, 1)
|
@flaky(3, 1)
|
||||||
@timeout(10)
|
@timeout(10)
|
||||||
def testGetUpdates(self):
|
def testGetUpdates(self):
|
||||||
|
@ -93,6 +104,18 @@ class BotTest(BaseTest, unittest.TestCase):
|
||||||
self.assertEqual(message.photo[0].file_size, 1451)
|
self.assertEqual(message.photo[0].file_size, 1451)
|
||||||
self.assertEqual(message.caption, 'testSendPhoto')
|
self.assertEqual(message.caption, 'testSendPhoto')
|
||||||
|
|
||||||
|
@flaky(3, 1)
|
||||||
|
@timeout(10)
|
||||||
|
def testSilentSendPhoto(self):
|
||||||
|
message = self._bot.sendPhoto(photo=open('tests/data/telegram.png', 'rb'),
|
||||||
|
caption='testSendPhoto',
|
||||||
|
chat_id=self._chat_id,
|
||||||
|
disable_notification=True)
|
||||||
|
|
||||||
|
self.assertTrue(self.is_json(message.to_json()))
|
||||||
|
self.assertEqual(message.photo[0].file_size, 1451)
|
||||||
|
self.assertEqual(message.caption, 'testSendPhoto')
|
||||||
|
|
||||||
@flaky(3, 1)
|
@flaky(3, 1)
|
||||||
@timeout(10)
|
@timeout(10)
|
||||||
def testResendPhoto(self):
|
def testResendPhoto(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue