diff --git a/telegram/user.py b/telegram/user.py index 084fd65a0cf..69afb57de13 100644 --- a/telegram/user.py +++ b/telegram/user.py @@ -296,3 +296,16 @@ def send_voice(self, *args, **kwargs): """ return self.bot.send_voice(self.id, *args, **kwargs) + + def send_poll(self, *args, **kwargs): + """Shortcut for:: + + bot.send_poll(User.id, *args, **kwargs) + + Where User is the current instance. + + Returns: + :class:`telegram.Message`: On success, instance representing the message posted. + + """ + return self.bot.send_poll(self.id, *args, **kwargs) diff --git a/tests/test_user.py b/tests/test_user.py index bab96aa66a3..9328c55fe09 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -190,6 +190,13 @@ def test(*args, **kwargs): monkeypatch.setattr(user.bot, 'send_animation', test) assert user.send_animation('test_animation') + def test_instance_method_send_poll(self, monkeypatch, user): + def test(*args, **kwargs): + return args[0] == user.id and args[1] == 'test_poll' + + monkeypatch.setattr(user.bot, 'send_poll', test) + assert user.send_poll('test_poll') + def test_mention_html(self, user): expected = u'{}' 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