-
Notifications
You must be signed in to change notification settings - Fork 0
/
real_demo_windows.py
173 lines (110 loc) · 6.67 KB
/
real_demo_windows.py
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import time, datetime, requests, itchat
from itchat.content import *
import logging
itchat.auto_login(hotReload=True,enableCmdQR=2)
#############################################################Try using Content = input(msg.text)
#group = itchat.search_chatrooms(bool(name.find(u'Coderbunker')=True)
#group = itchat.search_chatrooms('UserName'.startswith('Coderbunker'))
#group = itchat.search_chatrooms(name=u'Coderbunker')
#group = itchat.search_chatrooms(NickName=u'Coderbunker')
#reply = itchat.send(u'MY LAST HOPING BOT TEST. This is your time:\n{:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now()), friend[0]['UserName'])
#print(reply['BaseResponse']['ErrMsg'])
#reply = itchat.send_image('C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\joseph.jpg',friend[0]['UserName'])
#print(reply['BaseResponse']['ErrMsg'])
#reply = itchat.send_file('C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\sunflower.mp3', friend[0]['UserName'])
#reply = itchat.send(u'MY LAST HOPING BOT TEST. This is your time:\n{:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now()), group[0]['UserName'])
#print(reply['BaseResponse']['ErrMsg'])
customer = itchat.search_friends(name =u'None')
@itchat.msg_register(itchat.content.TEXT)
def personal_reply(msg):
try:
print(msg.text)
reply_text = ''
if msg.text == '#freelancer':
reply_text ='''
[Bot]Please answer these questions below. Completing these questions will allow us to provide the service quickly 😊 \n\n
1. What are your programming skills and experience? \n
2. What is your availability per week (in hours)? \n
3. What is your current location?'''
elif msg.text == '#client':
reply_text = '[Bot]These are some of the files for your reference! Below is a questionnaire that will speed up the process if completed 😊 \nhttps://forms.gle/8quKU4C1anJtZq6P8'
return reply_text
elif msg.text == '#other':
reply_text = '[Bot]If you tell us your order, we will come to you as soon as possible!'
return reply_text
except:
logging.warning('PM not working? ')
@itchat.msg_register(TEXT,isGroupChat=True)
def auto_reply(msg):
coming_from = msg.get('ActualNickName')
context = msg.text
friend = itchat.search_friends(name=coming_from)
print(f'{coming_from}:{context}')
words = context.split(" ")
file_name = words[0]
receiving_name = words[-1]
print(receiving_name)
# this gives ricky.jpg after @
receiving_friend= itchat.search_friends(name=receiving_name)
if len(words)>1:
#for two word names
receiving_name_two = words[-2] + ' ' + words[-1]
print(receiving_name_two)
receiving_friend_two = itchat.search_friends(name=receiving_name_two)
try:
try:
reply = itchat.send_file(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\'+ msg.text, friend[0]['UserName'])
reply = itchat.send_image('C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\' + file_name, receiving_friend[0][
'UserName'])
except:
reply = itchat.send_image(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\' + file_name, receiving_friend_two[0][
'UserName'])
except:
logging.warning('The text received seems to be containing special symbol or unordinary length ')
pass
if context == '#freelancer':
reply = itchat.send_msg(
u'[Bot]Please answer these questions below. Completing these questions will allow us to provide the service quickly 😊',
friend[0]['UserName'])
reply = itchat.send_msg(
u'[Bot]1. What are your programming skills and experience? \n2.What is your availability per week (in hours)? \n 3.What is your current location? ',
friend[0]['UserName'])
elif context == '#client':
reply = itchat.send_file(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\Coderbunker collaboration model with clients.pdf',
friend[0]['UserName'])
reply = itchat.send_file(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\Coderbunker Contract template - Agora Space.pdf',
friend[0]['UserName'])
reply = itchat.send_msg(
u'[Bot]These are some of the files for your reference! Below is a questionnaire that will speed up the process if completed 😊 \nhttps://forms.gle/8quKU4C1anJtZq6P8',
friend[0]['UserName'])
@itchat.msg_register(FRIENDS)
def add_friend(msg):
print(u'[ Terminal Info ] New Friend Request 新朋友的请求,自动通过验证添加加好友 From: %s' % msg['RecommendInfo']['UserName'])
itchat.add_friend(**msg['Text']) # 该操作会自动将新好友的消息录入,不需要重载通讯录
itchat.send_image(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\ricky.jpg',
msg['RecommendInfo']['UserName'])
itchat.send_image(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\fred.jpg',
msg['RecommendInfo']['UserName'])
itchat.send_image(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\introduction.jpg',
msg['RecommendInfo']['UserName'])
itchat.send_image(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\space.jpg',msg['RecommendInfo']['UserName'])
itchat.send_msg(
u'[Bot]The documents below are for you if you are a client'
, msg['RecommendInfo']['UserName'])
reply = itchat.send_file(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\Coderbunker collaboration model with clients.pdf',
msg['RecommendInfo']['UserName'])
reply = itchat.send_file(
'C:\\Users\\user\\Desktop\\CODER BUNKER INTERN\\workspace\\chatbot\\images\\Coderbunker Contract template - Agora Space.pdf',
msg['RecommendInfo']['UserName'])
itchat.send_msg(u'[Bot]Thank you for adding CoderBunker! Will you please tell us if you are here for freelancer, client, or other purposes? \n #freelancer for freelancer #client for client and #other for other 😊'
,msg['RecommendInfo']['UserName'])
itchat.run()