diff --git a/AUTHORS.rst b/AUTHORS.rst index 2c30ad999b3..13c10c1f5bf 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -24,6 +24,7 @@ The following wonderful people contributed directly or indirectly to this projec - `daimajia `_ - `Daniel Reed `_ - `Eli Gao `_ +- `Emilio Molinari `_ - `ErgoZ Riftbit Vaper `_ - `Eugene Lisitsky `_ - `Eugenio Panadero `_ diff --git a/telegram/chat.py b/telegram/chat.py index 861ac648a1d..d6994910362 100644 --- a/telegram/chat.py +++ b/telegram/chat.py @@ -224,7 +224,7 @@ def send_message(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_message(chat_id=self.id, *args, **kwargs) + return self.bot.send_message(self.id, *args, **kwargs) def send_photo(self, *args, **kwargs): """Shortcut for:: @@ -237,7 +237,7 @@ def send_photo(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_photo(chat_id=self.id, *args, **kwargs) + return self.bot.send_photo(self.id, *args, **kwargs) def send_audio(self, *args, **kwargs): """Shortcut for:: @@ -250,7 +250,7 @@ def send_audio(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_audio(chat_id=self.id, *args, **kwargs) + return self.bot.send_audio(self.id, *args, **kwargs) def send_document(self, *args, **kwargs): """Shortcut for:: @@ -263,7 +263,7 @@ def send_document(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_document(chat_id=self.id, *args, **kwargs) + return self.bot.send_document(self.id, *args, **kwargs) def send_sticker(self, *args, **kwargs): """Shortcut for:: @@ -276,7 +276,7 @@ def send_sticker(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_sticker(chat_id=self.id, *args, **kwargs) + return self.bot.send_sticker(self.id, *args, **kwargs) def send_video(self, *args, **kwargs): """Shortcut for:: @@ -289,7 +289,7 @@ def send_video(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_video(chat_id=self.id, *args, **kwargs) + return self.bot.send_video(self.id, *args, **kwargs) def send_video_note(self, *args, **kwargs): """Shortcut for:: @@ -302,7 +302,7 @@ def send_video_note(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_video_note(chat_id=self.id, *args, **kwargs) + return self.bot.send_video_note(self.id, *args, **kwargs) def send_voice(self, *args, **kwargs): """Shortcut for:: @@ -315,4 +315,4 @@ def send_voice(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_voice(chat_id=self.id, *args, **kwargs) + return self.bot.send_voice(self.id, *args, **kwargs) diff --git a/telegram/user.py b/telegram/user.py index 2d760cac80b..018dde25ee6 100644 --- a/telegram/user.py +++ b/telegram/user.py @@ -158,7 +158,7 @@ def send_message(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_message(chat_id=self.id, *args, **kwargs) + return self.bot.send_message(self.id, *args, **kwargs) def send_photo(self, *args, **kwargs): """Shortcut for:: @@ -171,7 +171,7 @@ def send_photo(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_photo(chat_id=self.id, *args, **kwargs) + return self.bot.send_photo(self.id, *args, **kwargs) def send_audio(self, *args, **kwargs): """Shortcut for:: @@ -184,7 +184,7 @@ def send_audio(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_audio(chat_id=self.id, *args, **kwargs) + return self.bot.send_audio(self.id, *args, **kwargs) def send_document(self, *args, **kwargs): """Shortcut for:: @@ -197,7 +197,7 @@ def send_document(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_document(chat_id=self.id, *args, **kwargs) + return self.bot.send_document(self.id, *args, **kwargs) def send_sticker(self, *args, **kwargs): """Shortcut for:: @@ -210,7 +210,7 @@ def send_sticker(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_sticker(chat_id=self.id, *args, **kwargs) + return self.bot.send_sticker(self.id, *args, **kwargs) def send_video(self, *args, **kwargs): """Shortcut for:: @@ -223,7 +223,7 @@ def send_video(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_video(chat_id=self.id, *args, **kwargs) + return self.bot.send_video(self.id, *args, **kwargs) def send_video_note(self, *args, **kwargs): """Shortcut for:: @@ -236,7 +236,7 @@ def send_video_note(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_video_note(chat_id=self.id, *args, **kwargs) + return self.bot.send_video_note(self.id, *args, **kwargs) def send_voice(self, *args, **kwargs): """Shortcut for:: @@ -249,4 +249,4 @@ def send_voice(self, *args, **kwargs): :class:`telegram.Message`: On success, instance representing the message posted. """ - return self.bot.send_voice(chat_id=self.id, *args, **kwargs) + return self.bot.send_voice(self.id, *args, **kwargs) diff --git a/tests/test_chat.py b/tests/test_chat.py index 909d304d555..ce686e42ef0 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -126,52 +126,59 @@ def test(*args, **kwargs): def test_instance_method_send_message(self, monkeypatch, chat): def test(*args, **kwargs): - return kwargs['chat_id'] == chat.id and args[1] == 'test' + return args[1] == chat.id and args[2] == 'test' monkeypatch.setattr('telegram.Bot.send_message', test) assert chat.send_message('test') + def test_instance_method_send_photo(self, monkeypatch, chat): + def test(*args, **kwargs): + return args[1] == chat.id and args[2] == 'test_photo' + + monkeypatch.setattr('telegram.Bot.send_photo', test) + assert chat.send_photo('test_photo') + def test_instance_method_send_audio(self, monkeypatch, chat): def test(*args, **kwargs): - return kwargs['chat_id'] == chat.id and kwargs['audio'] == 'test_audio' + return args[1] == chat.id and args[2] == 'test_audio' monkeypatch.setattr('telegram.Bot.send_audio', test) - assert chat.send_audio(audio='test_audio') + assert chat.send_audio('test_audio') def test_instance_method_send_document(self, monkeypatch, chat): def test(*args, **kwargs): - return kwargs['chat_id'] == chat.id and kwargs['document'] == 'test_document' + return args[1] == chat.id and args[2] == 'test_document' monkeypatch.setattr('telegram.Bot.send_document', test) - assert chat.send_document(document='test_document') + assert chat.send_document('test_document') def test_instance_method_send_sticker(self, monkeypatch, chat): def test(*args, **kwargs): - return kwargs['chat_id'] == chat.id and kwargs['sticker'] == 'test_sticker' + return args[1] == chat.id and args[2] == 'test_sticker' monkeypatch.setattr('telegram.Bot.send_sticker', test) - assert chat.send_sticker(sticker='test_sticker') + assert chat.send_sticker('test_sticker') def test_instance_method_send_video(self, monkeypatch, chat): def test(*args, **kwargs): - return kwargs['chat_id'] == chat.id and kwargs['video'] == 'test_video' + return args[1] == chat.id and args[2] == 'test_video' monkeypatch.setattr('telegram.Bot.send_video', test) - assert chat.send_video(video='test_video') + assert chat.send_video('test_video') def test_instance_method_send_video_note(self, monkeypatch, chat): def test(*args, **kwargs): - return kwargs['chat_id'] == chat.id and kwargs['video_note'] == 'test_video_note' + return args[1] == chat.id and args[2] == 'test_video_note' monkeypatch.setattr('telegram.Bot.send_video_note', test) - assert chat.send_video_note(video_note='test_video_note') + assert chat.send_video_note('test_video_note') def test_instance_method_send_voice(self, monkeypatch, chat): def test(*args, **kwargs): - return kwargs['chat_id'] == chat.id and kwargs['voice'] == 'test_voice' + return args[1] == chat.id and args[2] == 'test_voice' monkeypatch.setattr('telegram.Bot.send_voice', test) - assert chat.send_voice(voice='test_voice') + assert chat.send_voice('test_voice') def test_equality(self): a = Chat(self.id, self.title, self.type) diff --git a/tests/test_user.py b/tests/test_user.py index 05114e745e6..67975ca0bc4 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -105,52 +105,59 @@ def test(_, *args, **kwargs): def test_instance_method_send_message(self, monkeypatch, user): def test(*args, **kwargs): - return kwargs['chat_id'] == user.id and args[1] == 'test' + return args[1] == user.id and args[2] == 'test' monkeypatch.setattr('telegram.Bot.send_message', test) assert user.send_message('test') + def test_instance_method_send_photo(self, monkeypatch, user): + def test(*args, **kwargs): + return args[1] == user.id and args[2] == 'test_photo' + + monkeypatch.setattr('telegram.Bot.send_photo', test) + assert user.send_photo('test_photo') + def test_instance_method_send_audio(self, monkeypatch, user): def test(*args, **kwargs): - return kwargs['chat_id'] == user.id and kwargs['audio'] == 'test_audio' + return args[1] == user.id and args[2] == 'test_audio' monkeypatch.setattr('telegram.Bot.send_audio', test) - assert user.send_audio(audio='test_audio') + assert user.send_audio('test_audio') def test_instance_method_send_document(self, monkeypatch, user): def test(*args, **kwargs): - return kwargs['chat_id'] == user.id and kwargs['document'] == 'test_document' + return args[1] == user.id and args[2] == 'test_document' monkeypatch.setattr('telegram.Bot.send_document', test) - assert user.send_document(document='test_document') + assert user.send_document('test_document') def test_instance_method_send_sticker(self, monkeypatch, user): def test(*args, **kwargs): - return kwargs['chat_id'] == user.id and kwargs['sticker'] == 'test_sticker' + return args[1] == user.id and args[2] == 'test_sticker' monkeypatch.setattr('telegram.Bot.send_sticker', test) - assert user.send_sticker(sticker='test_sticker') + assert user.send_sticker('test_sticker') def test_instance_method_send_video(self, monkeypatch, user): def test(*args, **kwargs): - return kwargs['chat_id'] == user.id and kwargs['video'] == 'test_video' + return args[1] == user.id and args[2] == 'test_video' monkeypatch.setattr('telegram.Bot.send_video', test) - assert user.send_video(video='test_video') + assert user.send_video('test_video') def test_instance_method_send_video_note(self, monkeypatch, user): def test(*args, **kwargs): - return kwargs['chat_id'] == user.id and kwargs['video_note'] == 'test_video_note' + return args[1] == user.id and args[2] == 'test_video_note' monkeypatch.setattr('telegram.Bot.send_video_note', test) - assert user.send_video_note(video_note='test_video_note') + assert user.send_video_note('test_video_note') def test_instance_method_send_voice(self, monkeypatch, user): def test(*args, **kwargs): - return kwargs['chat_id'] == user.id and kwargs['voice'] == 'test_voice' + return args[1] == user.id and args[2] == 'test_voice' monkeypatch.setattr('telegram.Bot.send_voice', test) - assert user.send_voice(voice='test_voice') + assert user.send_voice('test_voice') def test_equality(self): a = User(self.id, self.first_name, self.is_bot, self.last_name) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy