@@ -249,6 +249,8 @@ def extract_msg_content(self, msg_type_id, msg):
249
249
else : # Self, Contact, Special, Public, Unknown
250
250
pass
251
251
252
+ msg_prefix = (msg_content ['user' ]['name' ] + ':' ) if 'user' in msg_content else ''
253
+
252
254
if mtype == 1 :
253
255
if content .find ('http://weixin.qq.com/cgi-bin/redirectforward?args=' ) != - 1 :
254
256
r = self .session .get (content )
@@ -259,24 +261,24 @@ def extract_msg_content(self, msg_type_id, msg):
259
261
msg_content ['data' ] = pos
260
262
msg_content ['detail' ] = data
261
263
if self .DEBUG :
262
- print ' [Location] I am at %s ' % pos
264
+ print ' %s [Location] I am at %s ' % ( msg_prefix , pos )
263
265
else :
264
266
msg_content ['type' ] = 0
265
267
msg_content ['data' ] = content .replace (u'\u2005 ' , '' )
266
268
if self .DEBUG :
267
- print ' [Text] %s' % msg_content ['data' ]
269
+ print ' %s [Text] %s' % ( msg_prefix , msg_content ['data' ])
268
270
elif mtype == 3 :
269
271
msg_content ['type' ] = 3
270
272
msg_content ['data' ] = self .get_msg_img_url (msg_id )
271
273
if self .DEBUG :
272
274
image = self .get_msg_img (msg_id )
273
- print ' [Image] %s' % image
275
+ print ' %s [Image] %s' % ( msg_prefix , image )
274
276
elif mtype == 34 :
275
277
msg_content ['type' ] = 4
276
278
msg_content ['data' ] = self .get_voice_url (msg_id )
277
279
if self .DEBUG :
278
280
voice = self .get_voice (msg_id )
279
- print ' [Voice] %s' % voice
281
+ print ' %s [Voice] %s' % ( msg_prefix , voice )
280
282
elif mtype == 42 :
281
283
msg_content ['type' ] = 5
282
284
info = msg ['RecommendInfo' ]
@@ -286,7 +288,7 @@ def extract_msg_content(self, msg_type_id, msg):
286
288
'city' : info ['City' ],
287
289
'gender' : ['unknown' , 'male' , 'female' ][info ['Sex' ]]}
288
290
if self .DEBUG :
289
- print ' [Recommend]'
291
+ print ' %s [Recommend]' % msg_prefix
290
292
print ' -----------------------------'
291
293
print ' | NickName: %s' % info ['NickName' ]
292
294
print ' | Alias: %s' % info ['Alias' ]
@@ -297,7 +299,7 @@ def extract_msg_content(self, msg_type_id, msg):
297
299
msg_content ['type' ] = 6
298
300
msg_content ['data' ] = self .search_content ('cdnurl' , content )
299
301
if self .DEBUG :
300
- print ' [Animation] %s' % msg_content ['data' ]
302
+ print ' %s [Animation] %s' % ( msg_prefix , msg_content ['data' ])
301
303
elif mtype == 49 :
302
304
msg_content ['type' ] = 7
303
305
app_msg_type = ''
@@ -315,7 +317,7 @@ def extract_msg_content(self, msg_type_id, msg):
315
317
'url' : msg ['Url' ],
316
318
'from' : self .search_content ('appname' , content , 'xml' )}
317
319
if self .DEBUG :
318
- print ' [Share] %s' % app_msg_type
320
+ print ' %s [Share] %s' % ( msg_prefix , app_msg_type )
319
321
print ' --------------------------'
320
322
print ' | title: %s' % msg ['FileName' ]
321
323
print ' | desc: %s' % self .search_content ('des' , content , 'xml' )
@@ -327,22 +329,22 @@ def extract_msg_content(self, msg_type_id, msg):
327
329
msg_content ['type' ] = 8
328
330
msg_content ['data' ] = content
329
331
if self .DEBUG :
330
- print ' [Video] Please check on mobiles'
332
+ print ' %s [Video] Please check on mobiles' % msg_prefix
331
333
elif mtype == 53 :
332
334
msg_content ['type' ] = 9
333
335
msg_content ['data' ] = content
334
336
if self .DEBUG :
335
- print ' [Video Call]'
337
+ print ' %s [Video Call]' % msg_prefix
336
338
elif mtype == 10002 :
337
339
msg_content ['type' ] = 10
338
340
msg_content ['data' ] = content
339
341
if self .DEBUG :
340
- print ' [Redraw]'
342
+ print ' %s [Redraw]' % msg_prefix
341
343
else :
342
344
msg_content ['type' ] = 99
343
345
msg_content ['data' ] = content
344
346
if self .DEBUG :
345
- print ' [Unknown]'
347
+ print ' %s [Unknown]' % msg_prefix
346
348
return msg_content
347
349
348
350
def handle_msg (self , r ):
0 commit comments