def on_new_number(data): if (data['facebook_user_token'] != ''): response = requests.get( 'https://graph.facebook.com/v2.8/me?fields=id%2Cname%2Cpicture&access_token=' + data['facebook_user_token']) json = response.json() print "Got an event for new number with data:", data all_mah_numbers.append({ 'name': json['name'], 'picture': json['picture']['data']['url'], 'message': data['message'], }) for x in user_list: if (x['sesId'] == flask.request.sid): x['user'] = json['name'] r = chatbot.get_chatbot_response(data['message']) if (r != ''): all_mah_numbers.append({ 'name': "Robbie", 'picture': bot_img_url, 'message': str(r), }) elif (data['google_user_token'] != ''): response = requests.get( 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=' + data['google_user_token']) json = response.json() print "Got an event for new number with data:", data all_mah_numbers.append({ 'name': json['name'], 'picture': json['picture'], 'message': data['message'], }) for x in user_list: if (x['sesId'] == flask.request.sid): x['user'] = json['name'] r = chatbot.get_chatbot_response(data['message']) if (r != ''): all_mah_numbers.append({ 'name': "Robbie", 'picture': bot_img_url, 'message': str(r), }) socketio.emit('all numbers', {'numbers': all_mah_numbers}) socketio.emit('user list', {'users': user_list}) socketio.emit('user count', {'count': user_count})
def test_help(self): r = chatbot.get_chatbot_response('!! help ') self.assertEquals(r, 'Available commands: !! about -> descriptions of the chat room !! help -> lists available chatbot commands !! add <num> <num> -> add two integers together !! sub <num> <num> -> subtract two integers !! divide <num> <num> -> divide two integers !! say <text> -> the chatbot repeats the text input by the user !! <text> -> chatbot will have a conversation with you ')
def test_random(self): r = chatbot.get_chatbot_response('!! say this is another test ') self.assertEquals(r, "this is another test ")
def test_about(self): r = chatbot.get_chatbot_response('!! about ') self.assertEquals(r, 'This is a chat room to discuss random things in a spacey environment.')
def test_say(self): r = chatbot.get_chatbot_response('!! say this is a test ') self.assertEquals(r, "this is a test ")
def test_another_sub(self): r = chatbot.get_chatbot_response('!! sub 10 5 ') self.assertEquals(r, 5)
def test_sub(self): r = chatbot.get_chatbot_response('!! sub 5 2 ') self.assertEquals(r, 3)
def test_another_divide(self): r = chatbot.get_chatbot_response('!! divide 8 2 ') self.assertEquals(r, 4)
def test_divide(self): r = chatbot.get_chatbot_response('!! divide 4 2 ') self.assertEquals(r, 2)
def test_another_add(self): r = chatbot.get_chatbot_response('!! add 4 6 ') self.assertEquals(r, 10)
def test_add(self): r = chatbot.get_chatbot_response('!! add 2 3 ') self.assertEquals(r, 5)