mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 15:17:00 +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')
|
||||
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'):
|
||||
reply_markup = kwargs.get('reply_markup')
|
||||
if isinstance(reply_markup, ReplyMarkup):
|
||||
|
@ -213,6 +217,10 @@ class Bot(TelegramObject):
|
|||
UTF8 characters.
|
||||
disable_web_page_preview:
|
||||
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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
@ -252,6 +260,10 @@ class Bot(TelegramObject):
|
|||
- Chat id.
|
||||
message_id:
|
||||
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:
|
||||
A telegram.Message instance representing the message forwarded.
|
||||
|
@ -288,6 +300,10 @@ class Bot(TelegramObject):
|
|||
caption:
|
||||
Photo caption (may also be used when resending photos by file_id).
|
||||
[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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
@ -342,6 +358,10 @@ class Bot(TelegramObject):
|
|||
Performer of sent audio. [Optional]
|
||||
title:
|
||||
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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
@ -386,6 +406,10 @@ class Bot(TelegramObject):
|
|||
filename:
|
||||
File name that shows in telegram message (it is usefull when you
|
||||
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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
@ -422,6 +446,10 @@ class Bot(TelegramObject):
|
|||
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
|
||||
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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
@ -466,6 +494,10 @@ class Bot(TelegramObject):
|
|||
timeout:
|
||||
float. If this value is specified, use it as the definitive timeout
|
||||
(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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
@ -512,6 +544,10 @@ class Bot(TelegramObject):
|
|||
a new audio file using multipart/form-data.
|
||||
duration:
|
||||
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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
@ -549,6 +585,10 @@ class Bot(TelegramObject):
|
|||
Latitude of location.
|
||||
longitude:
|
||||
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:
|
||||
If the message is a reply, ID of the original message. [Optional]
|
||||
reply_markup:
|
||||
|
|
|
@ -61,6 +61,17 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||
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)
|
||||
@timeout(10)
|
||||
def testGetUpdates(self):
|
||||
|
@ -93,6 +104,18 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(message.photo[0].file_size, 1451)
|
||||
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)
|
||||
@timeout(10)
|
||||
def testResendPhoto(self):
|
||||
|
|
Loading…
Reference in a new issue