forked from xieyumc/YuYuWechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSendMessageOnce.py
More file actions
executable file
·93 lines (67 loc) · 2.26 KB
/
SendMessageOnce.py
File metadata and controls
executable file
·93 lines (67 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import io
import sys
import ProcessedExcel
import AutoWechat
import time
def SendMessageOnce(ExcelFile,
Sheet,
ExcelWechatName,
ExcelWechatSentMessage,
ExcelSentDate,
ExcelAddDate,
Path,
Locale):
buffer=io.StringIO()
sys.stdout=buffer
try:
Excel=ProcessedExcel.Excel(ExcelFile,Sheet,ExcelWechatName,ExcelWechatSentMessage,ExcelSentDate,ExcelAddDate)
except Exception as e:
print("读取表格失败,请检查路径和表格是否符合格式要求\n\n",e)
sys.stdout = sys.__stdout__
output = buffer.getvalue()
buffer.close()
return output
try:
Wechat=AutoWechat.WeChat(Path,Locale)
except Exception as e:
print("请检查微信路径和语言是否正确\n\n",e)
sys.stdout = sys.__stdout__
output = buffer.getvalue()
buffer.close()
return output
try:
Excel.FilterExcel()
except Exception as e:
print("请检查表格是否符合格式要求\n\n",e)
sys.stdout = sys.__stdout__
output = buffer.getvalue()
buffer.close()
return output
try:
Excel.GetInformation()
except Exception as e:
print("请检查表格是否符合格式要求\n\n",e)
sys.stdout = sys.__stdout__
output = buffer.getvalue()
buffer.close()
return output
print(f"发送给{len(Excel.ProcessedList)}个好友\n")
try:
for i in range(len(Excel.ProcessedList)):
print("发送给:",Excel.Information[i][0],"信息:",Excel.Information[i][1],"\n")
Wechat.send_msg(Excel.Information[i][0],Excel.Information[i][1])
try:
Excel.AddDate(Excel.ProcessedList[i])
except Exception as ea:
print("添加日期失败\n\n",ea)
print("发送结束,已给表格添加日期\n")
except Exception as e:
print("发送信息失败\n\n",e)
sys.stdout = sys.__stdout__
output = buffer.getvalue()
buffer.close()
return output
sys.stdout=sys.__stdout__
output=buffer.getvalue()
buffer.close()
return output