Skip to content

Commit abad2ac

Browse files
committed
Change group debug information format.
1 parent e0fd2fc commit abad2ac

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

wxbot.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ def extract_msg_content(self, msg_type_id, msg):
249249
else: # Self, Contact, Special, Public, Unknown
250250
pass
251251

252+
msg_prefix = (msg_content['user']['name'] + ':') if 'user' in msg_content else ''
253+
252254
if mtype == 1:
253255
if content.find('http://weixin.qq.com/cgi-bin/redirectforward?args=') != -1:
254256
r = self.session.get(content)
@@ -259,24 +261,24 @@ def extract_msg_content(self, msg_type_id, msg):
259261
msg_content['data'] = pos
260262
msg_content['detail'] = data
261263
if self.DEBUG:
262-
print ' [Location] I am at %s ' % pos
264+
print ' %s[Location] I am at %s ' % (msg_prefix, pos)
263265
else:
264266
msg_content['type'] = 0
265267
msg_content['data'] = content.replace(u'\u2005', '')
266268
if self.DEBUG:
267-
print ' [Text] %s' % msg_content['data']
269+
print ' %s[Text] %s' % (msg_prefix, msg_content['data'])
268270
elif mtype == 3:
269271
msg_content['type'] = 3
270272
msg_content['data'] = self.get_msg_img_url(msg_id)
271273
if self.DEBUG:
272274
image = self.get_msg_img(msg_id)
273-
print ' [Image] %s' % image
275+
print ' %s[Image] %s' % (msg_prefix, image)
274276
elif mtype == 34:
275277
msg_content['type'] = 4
276278
msg_content['data'] = self.get_voice_url(msg_id)
277279
if self.DEBUG:
278280
voice = self.get_voice(msg_id)
279-
print ' [Voice] %s' % voice
281+
print ' %s[Voice] %s' % (msg_prefix, voice)
280282
elif mtype == 42:
281283
msg_content['type'] = 5
282284
info = msg['RecommendInfo']
@@ -286,7 +288,7 @@ def extract_msg_content(self, msg_type_id, msg):
286288
'city': info['City'],
287289
'gender': ['unknown', 'male', 'female'][info['Sex']]}
288290
if self.DEBUG:
289-
print ' [Recommend]'
291+
print ' %s[Recommend]' % msg_prefix
290292
print ' -----------------------------'
291293
print ' | NickName: %s' % info['NickName']
292294
print ' | Alias: %s' % info['Alias']
@@ -297,7 +299,7 @@ def extract_msg_content(self, msg_type_id, msg):
297299
msg_content['type'] = 6
298300
msg_content['data'] = self.search_content('cdnurl', content)
299301
if self.DEBUG:
300-
print ' [Animation] %s' % msg_content['data']
302+
print ' %s[Animation] %s' % (msg_prefix, msg_content['data'])
301303
elif mtype == 49:
302304
msg_content['type'] = 7
303305
app_msg_type = ''
@@ -315,7 +317,7 @@ def extract_msg_content(self, msg_type_id, msg):
315317
'url': msg['Url'],
316318
'from': self.search_content('appname', content, 'xml')}
317319
if self.DEBUG:
318-
print ' [Share] %s' % app_msg_type
320+
print ' %s[Share] %s' % (msg_prefix, app_msg_type)
319321
print ' --------------------------'
320322
print ' | title: %s' % msg['FileName']
321323
print ' | desc: %s' % self.search_content('des', content, 'xml')
@@ -327,22 +329,22 @@ def extract_msg_content(self, msg_type_id, msg):
327329
msg_content['type'] = 8
328330
msg_content['data'] = content
329331
if self.DEBUG:
330-
print ' [Video] Please check on mobiles'
332+
print ' %s[Video] Please check on mobiles' % msg_prefix
331333
elif mtype == 53:
332334
msg_content['type'] = 9
333335
msg_content['data'] = content
334336
if self.DEBUG:
335-
print ' [Video Call]'
337+
print ' %s[Video Call]' % msg_prefix
336338
elif mtype == 10002:
337339
msg_content['type'] = 10
338340
msg_content['data'] = content
339341
if self.DEBUG:
340-
print ' [Redraw]'
342+
print ' %s[Redraw]' % msg_prefix
341343
else:
342344
msg_content['type'] = 99
343345
msg_content['data'] = content
344346
if self.DEBUG:
345-
print ' [Unknown]'
347+
print ' %s[Unknown]' % msg_prefix
346348
return msg_content
347349

348350
def handle_msg(self, r):

0 commit comments

Comments
 (0)