File tree 3 files changed +28
-3
lines changed
3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 1
1
from PyOfficeRobot .core .WeChatType import WeChat
2
2
from PyOfficeRobot .lib .CONST import ACT_TYPE
3
3
from PyOfficeRobot .lib .dec .act_dec import act_info
4
+ import datetime
5
+ import os
4
6
5
7
wx = WeChat ()
6
8
@@ -40,3 +42,23 @@ def chat_by_keywords(who, keywords):
40
42
wx .SendMsg (keywords [receive_msg ]) # 向`who`发送消息
41
43
except :
42
44
pass
45
+
46
+
47
+ def receive_message (who = '文件传输助手' , txt = 'userMessage.txt' , output_path = './' ):
48
+ wx .GetSessionList () # 获取会话列表
49
+ wx .ChatWith (who ) # 打开`who`聊天窗口
50
+ while True :
51
+ friend_name , receive_msg = wx .GetAllMessage [- 1 ][0 ], wx .GetAllMessage [- 1 ][1 ] # 获取朋友的名字、发送的信息
52
+ current_time = datetime .datetime .now ()
53
+ cut_line = '^^^----------^^^'
54
+ print ('--' * 88 )
55
+ with open (os .path .join (output_path , txt ), 'a+' ) as output_file :
56
+ output_file .write ('\n ' )
57
+ output_file .write (cut_line )
58
+ output_file .write ('\n ' )
59
+ output_file .write (str (current_time ))
60
+ output_file .write ('\n ' )
61
+ output_file .write (str (friend_name ))
62
+ output_file .write ('\n ' )
63
+ output_file .write (str (receive_msg ))
64
+ output_file .write ('\n ' )
Original file line number Diff line number Diff line change 1
1
[metadata]
2
2
name = PyOfficeRobot
3
- version = 0.0.10
3
+ version = 0.0.11
4
4
description = pip install PyOfficeRobot
5
5
long_description = file: README.md
6
6
long_description_content_type = text/markdown
Original file line number Diff line number Diff line change 1
1
import unittest
2
2
3
- from PyOfficeRobot .api .chat import chat_by_keyword
3
+ from PyOfficeRobot .api .chat import *
4
4
from PyOfficeRobot .api .file import *
5
5
6
6
keywords = {
@@ -13,4 +13,7 @@ def test_send_file(self):
13
13
send_file (who = '文件传输助手' , file = r'./test_files/0816.jpg' )
14
14
15
15
def test_chat_by_keyword (self ):
16
- chat_by_keyword (who = '兆锋' , keywords = keywords )
16
+ chat_by_keywords (who = '程序员晚枫' , keywords = keywords )
17
+
18
+ def test_receive_message (self ):
19
+ receive_message (who = '程序员晚枫' )
You can’t perform that action at this time.
0 commit comments