Skip to content

Commit

Permalink
add loging wait robot response chatkey
Browse files Browse the repository at this point in the history
  • Loading branch information
noahzark committed Jun 7, 2018
1 parent e87c84d commit 8f49379
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from dns_cache import _set_dns_cache

GRADER_VERSION = '1.3.1'
GRADER_VERSION = '1.3.'

if __name__ == '__main__':
report_logger.info("QiwuGrader ver {0}".format(GRADER_VERSION))
Expand Down
11 changes: 7 additions & 4 deletions controller/private_msg_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def pre_chat(self, from_name, msg):
return True

# Process the message, and returns response
def process_chat(self, from_name, msg):
def process_chat(self, from_name, msg, login_wait=None):

result = ''
skip_first = False
Expand All @@ -72,6 +72,9 @@ def process_chat(self, from_name, msg):
result_str = to_str(result)
self.logging.info('Login Res: {0} Length: {1} for chatkey {2}'.format(result_str, str(len(result_str)), chat_key))

if login_wait:
time.sleep(login_wait)

self.logging.debug('User ask: {0} with chatkey'.format(msg.encode('utf-8'), chat_key))

if skip_first and len(result) != 0:
Expand All @@ -95,13 +98,13 @@ def process_chat(self, from_name, msg):

return result

def handle_chat(self, from_name, msg):
def handle_chat(self, from_name, msg, login_wait=None):
# Pre process and check if we really need to handle this message
if self.pre_chat(from_name, msg):
# Process the message and give a response
result = self.process_chat(from_name, msg)
result = self.process_chat(from_name, msg, login_wait=None)

self.logging.debug('Robot Response: {0}'.format(result))
self.logging.debug('Robot Response: {0} for chatkey {1}'.format(result, from_name))

if result and result != '':
return result
Expand Down
2 changes: 1 addition & 1 deletion grader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_robot(self, name, questions, answers):
question_str = str(question)
else:
question_str = question
response = test_service.handle_chat(uid, question_str)
response = test_service.handle_chat(uid, question_str, login_wait=self.question_interval)
process_time = time.time() - process_time

correct = True
Expand Down

0 comments on commit 8f49379

Please sign in to comment.