@@ -241,6 +241,37 @@ def send_video_note(self, path=None, file_id=None, duration=None,
241241 return self ._api .call ("sendVideoNote" , args , files ,
242242 expect = _objects ().Message )
243243
244+ @_require_api
245+ def send_gif (self , path = None , file_id = None , url = None , duration = None ,
246+ width = None , height = None , caption = None , thumb = None ,
247+ reply_to = None , extra = None , attach = None ,
248+ notify = True , syntax = None ):
249+ """Send an animation"""
250+ args = self ._get_call_args (reply_to , extra , attach , notify )
251+ if duration is not None :
252+ args ["duration" ] = duration
253+ if caption is not None :
254+ args ["caption" ] = caption
255+ if syntax is not None :
256+ syntax = syntaxes .guess_syntax (caption , syntax )
257+ args ["parse_mode" ] = syntax
258+ if width is not None :
259+ args ["width" ] = width
260+ if height is not None :
261+ args ["height" ] = height
262+
263+ files = dict ()
264+ args ["animation" ], files ["animation" ] = self ._get_file_args (path ,
265+ file_id ,
266+ url )
267+ if files ["animation" ] is None :
268+ del files ["animation" ]
269+ if thumb is not None :
270+ files ["thumb" ] = thumb
271+
272+ return self ._api .call ("sendAnimation" , args , files ,
273+ expect = _objects ().Message )
274+
244275 @_require_api
245276 def send_file (self , path = None , file_id = None , url = None , thumb = None ,
246277 reply_to = None , extra = None , attach = None ,
@@ -336,6 +367,16 @@ def send_contact(self, phone, first_name, last_name=None, *, reply_to=None,
336367
337368 return self ._api .call ("sendContact" , args , expect = _objects ().Message )
338369
370+ @_require_api
371+ def send_poll (self , question , * kargs , reply_to = None , extra = None ,
372+ attach = None , notify = True ):
373+ """Send a poll"""
374+ args = self ._get_call_args (reply_to , extra , attach , notify )
375+ args ["question" ] = question
376+ args ["options" ] = json .dumps (list (kargs ))
377+
378+ return self ._api .call ("sendPoll" , args , expect = _objects ().Message )
379+
339380 @_require_api
340381 def delete_message (self , message ):
341382 """Delete a message from chat"""
@@ -526,6 +567,10 @@ def reply_with_video_note(self, *args, **kwargs):
526567 """Reply with a video note to the current message"""
527568 return self .chat .send_video_note (* args , reply_to = self , ** kwargs )
528569
570+ @_require_api
571+ def reply_with_gif (self , * args , ** kwargs ):
572+ return self .chat .send_gif (* args , reply_to = self , ** kwargs )
573+
529574 @_require_api
530575 def reply_with_file (self , * args , ** kwargs ):
531576 """Reply with a generic file to the current chat"""
@@ -556,6 +601,11 @@ def reply_with_album(self, *args, **kwargs):
556601 """Reply with an album to the current message"""
557602 return self .chat .send_album (* args , reply_to = self , ** kwargs )
558603
604+ @_require_api
605+ def reply_with_poll (self , * args , ** kwargs ):
606+ """Reply with a poll to the current message"""
607+ return self .chat .send_poll (* args , reply_to = self , ** kwargs )
608+
559609 @_require_api
560610 def delete (self ):
561611 """Delete the message"""
@@ -564,6 +614,27 @@ def delete(self):
564614 "message_id" : self .id ,
565615 })
566616
617+ @_require_api
618+ def stop_poll (self , extra = None , attach = None ):
619+ """Stops a poll"""
620+ args = dict ()
621+ args ["chat_id" ] = self .chat .id
622+ args ["message_id" ] = self .id
623+
624+ if extra is not None :
625+ _deprecated_message (
626+ "The extra parameter" , "1.0" , "use the attach parameter" , - 3
627+ )
628+ args ["reply_markup" ] = json .dumps (extra .serialize ())
629+ if attach is not None :
630+ if not hasattr (attach , "_serialize_attachment" ):
631+ raise ValueError ("%s is not an attachment" % attach )
632+ args ["reply_markup" ] = json .dumps (attach ._serialize_attachment (
633+ self .chat
634+ ))
635+ return self ._api .call ("stopPoll" , args ,
636+ expect = _objects ().Poll )
637+
567638
568639class FileMixin :
569640 """Add some methods for files"""
0 commit comments