@@ -336,6 +336,16 @@ def send_contact(self, phone, first_name, last_name=None, *, reply_to=None,
336336
337337 return self ._api .call ("sendContact" , args , expect = _objects ().Message )
338338
339+ @_require_api
340+ def send_poll (self , question , * kargs , reply_to = None , extra = None ,
341+ attach = None , notify = True ):
342+ """Send a poll"""
343+ args = self ._get_call_args (reply_to , extra , attach , notify )
344+ args ["question" ] = question
345+ args ["options" ] = json .dumps (list (kargs ))
346+
347+ return self ._api .call ("sendPoll" , args , expect = _objects ().Message )
348+
339349 @_require_api
340350 def delete_message (self , message ):
341351 """Delete a message from chat"""
@@ -543,6 +553,11 @@ def reply_with_album(self, *args, **kwargs):
543553 """Reply with an album to the current message"""
544554 return self .chat .send_album (* args , reply_to = self , ** kwargs )
545555
556+ @_require_api
557+ def reply_with_poll (self , * args , ** kwargs ):
558+ """Reply with a poll to the current message"""
559+ return self .chat .send_poll (* args , reply_to = self , ** kwargs )
560+
546561 @_require_api
547562 def delete (self ):
548563 """Delete the message"""
@@ -551,6 +566,27 @@ def delete(self):
551566 "message_id" : self .id ,
552567 })
553568
569+ @_require_api
570+ def stop_poll (self , extra = None , attach = None ):
571+ """Stops a poll"""
572+ args = dict ()
573+ args ["chat_id" ] = self .chat .id
574+ args ["message_id" ] = self .id
575+
576+ if extra is not None :
577+ _deprecated_message (
578+ "The extra parameter" , "1.0" , "use the attach parameter" , - 3
579+ )
580+ args ["reply_markup" ] = json .dumps (extra .serialize ())
581+ if attach is not None :
582+ if not hasattr (attach , "_serialize_attachment" ):
583+ raise ValueError ("%s is not an attachment" % attach )
584+ args ["reply_markup" ] = json .dumps (attach ._serialize_attachment (
585+ self .chat
586+ ))
587+ return self ._api .call ("stopPoll" , args ,
588+ expect = _objects ().Poll )
589+
554590
555591class FileMixin :
556592 """Add some methods for files"""
0 commit comments