File tree Expand file tree Collapse file tree 5 files changed +32
-11
lines changed
Expand file tree Collapse file tree 5 files changed +32
-11
lines changed Original file line number Diff line number Diff line change 2222* .egg-info /
2323.installed.cfg
2424* .egg
25+ .env
2526
2627# PyInstaller
2728# Usually these files are written by a python script from a template
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ def sendPhoto(self,
8181
8282 data = {'chat_id' : chat_id ,
8383 'photo' : photo }
84+
8485 if caption :
8586 data ['caption' ] = caption
8687 if reply_to_message_id :
@@ -143,13 +144,25 @@ def _requestUrl(self,
143144 data = None ):
144145
145146 if method == 'POST' :
146- try :
147- return requests .post (
148- url ,
149- data = data
150- )
151- except requests .RequestException as e :
152- pass
147+ if data .has_key ('photo' ):
148+ try :
149+ photo = data .pop ('photo' )
150+
151+ return requests .post (
152+ url ,
153+ data = data ,
154+ files = {'photo' : photo }
155+ )
156+ except requests .RequestException as e :
157+ pass
158+ else :
159+ try :
160+ return requests .post (
161+ url ,
162+ data = data
163+ )
164+ except requests .RequestException as e :
165+ pass
153166 if method == 'GET' :
154167 try :
155168 return requests .get (url )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+
4+ class InputFile (object ):
5+ pass
Original file line number Diff line number Diff line change @@ -44,7 +44,9 @@ def testForwardMessage(self):
4444 self .assertEqual (u'Oi' , message .text )
4545 self .assertEqual (u'leandrotoledo' , message .forward_from .username )
4646
47- # def testSendPhoto(self):
48- # '''Test the telegram.Bot sendPhoto method'''
49- # print 'Testing sendPhoto'
50- # message = self._bot.sendPhoto()
47+ def testSendPhoto (self ):
48+ '''Test the telegram.Bot sendPhoto method'''
49+ print 'Testing sendPhoto'
50+ message = self ._bot .sendPhoto (photo = open ('tests/telegram.png' , 'rb' ),
51+ chat_id = 12173560 )
52+ #self.assertEqual(u'')
You can’t perform that action at this time.
0 commit comments