Exemple #1
0
 def test_not_command(self):
     response = functions.get_chatbot_response("!! add 4 6")
     #print(response)
     self.assertEquals(response, 10)
     #self.assertEquals(response, 9)
     
     response2 = functions.get_chatbot_response("!! divide 10 5")
     #print(response)
     self.assertEquals(response2, 2)
Exemple #2
0
 def test_not_command(self):
     # response = functions.get_chatbot_response("Purple")
     response = functions.get_chatbot_response("!! add 5 3")
     print(response)
     self.assertEquals(response, 8)
     
     response = functions.get_chatbot_response("!! divide 5 3")
     print(response)
     self.assertEquals(response, 1)
 def test_Cross(self):
     response = functions.get_chatbot_response('!! cross')
     if (response == cross1):
         self.assertEquals(response, cross1)
     elif (response == cross2):
         self.assertEquals(response, cross2)
     else:
         self.assertEquals(response, "")
Exemple #4
0
 def test_divide_command(self):
     response = functions.get_chatbot_response('!! divide 6 2')
     self.assertEquals(response, 3)
Exemple #5
0
 def test_add_command(self):
     response = functions.get_chatbot_response('!! add 2 3')
     self.assertEquals(response, 5)
Exemple #6
0
def on_new_number(data):
    response = requests.get(
        'https://graph.facebook.com/v2.8/me?fields=id%2Cname%2Cpicture&access_token='
        + data['facebook_user_token'])
    json = response.json()

    global chickenBotVer
    check = True
    ##connected user messages--------------------------------------------------------------------------------------------------------------------------------------------
    if (data['number'] == "connected"):
        if (data['facebook_user_token'] != ''):
            check = True
            for key in all_users:

                if key['name'] == json['name']:
                    check = False
                    socketio.emit('all users', {'users': all_users})

            all_mah_numbers.append({
                'name':
                'ChickenBot ' + str(chickenBotVer),
                'picture':
                'https://cdn4.iconfinder.com/data/icons/social-productivity-line-art-5/128/chatbot-128.png',
                'number':
                json['name'] + " " + data['number']
            })
            socketio.emit('all numbers', {'numbers': all_mah_numbers})

            if check == True:
                all_users.append({
                    'name': json['name'],
                    'picture': json['picture']['data']['url'],
                })

            socketio.emit('all users', {'users': all_users})

        elif (data['facebook_user_token'] == ''):
            response2 = requests.get(
                'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=' +
                data['google_user_token'])
            json2 = response2.json()
            check = True
            for key in all_users:

                if key['name'] == json['name']:
                    print "name" + key
                    check = False
                    socketio.emit('all users', {'users': all_users})

                all_mah_numbers.append({
                    'name':
                    'ChickenBot ' + str(chickenBotVer),
                    'picture':
                    'https://cdn4.iconfinder.com/data/icons/social-productivity-line-art-5/128/chatbot-128.png',
                    'number':
                    json2['name'] + " " + data['number']
                })
            socketio.emit('all numbers', {'numbers': all_mah_numbers})

            if check == True:
                all_users.append({
                    'name': json2['name'],
                    'picture': json2['picture']
                })
##---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## APPEND Facebook user message to list---------------------------------------------------------------------------------------------------------------------------------------------
    elif (data['number'] != "connected"):

        if data['facebook_user_token'] != '':
            if links.checkURL(data['number']):
                t1 = links.isImage(data['number'])
                print t1
                if t1 == True:
                    all_mah_numbers.append({
                        'name':
                        json['name'],
                        'picture':
                        json['picture']['data']['url'],
                        'number':
                        "",
                        'link':
                        "",
                        'picL':
                        data['number']
                    })
                else:
                    all_mah_numbers.append({
                        'name':
                        json['name'],
                        'picture':
                        json['picture']['data']['url'],
                        'number':
                        "",
                        'link':
                        data['number'],
                    })
            else:
                all_mah_numbers.append({
                    'name':
                    json['name'],
                    'picture':
                    json['picture']['data']['url'],
                    'number':
                    data['number'],
                    'link':
                    "",
                })
        elif data['facebook_user_token'] == '':
            t = links.checkURL(data['number'])
            print "**********************************" + str(
                links.checkURL(data['number']))

            if links.checkURL(data['number']):
                t1 = links.isImage(data['number'])
                print t1
                if t1 == True:
                    response2 = requests.get(
                        'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='
                        + data['google_user_token'])
                    json2 = response2.json()
                    print "**********************************************************************************" + data[
                        'number']
                    all_mah_numbers.append({
                        'name': json2['name'],
                        'picture': json2['picture'],
                        'number': "",
                        'link': "",
                        'picL': data['number']
                    })
                else:
                    response2 = requests.get(
                        'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='
                        + data['google_user_token'])
                    json2 = response2.json()
                    all_mah_numbers.append({
                        'name': json2['name'],
                        'picture': json2['picture'],
                        'number': "",
                        'link': data['number'],
                        'n.picL': ""
                    })
            else:
                response2 = requests.get(
                    'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='
                    + data['google_user_token'])
                json2 = response2.json()
                all_mah_numbers.append({
                    'name': json2['name'],
                    'picture': json2['picture'],
                    'number': data['number'],
                    'link': "",
                    'n.picL': ""
                })

##---------------------------------------------------------------------------------------------------------------------------------------------
    socketio.emit('all numbers', {'numbers': all_mah_numbers})
    socketio.emit('all users', {'users': all_users})
    ###Bot functionality --------------------------------------------------------------------------------------------------------------------------
    spl = str.split(str(data['number']))

    if (spl[0] == "!!"):
        all_mah_numbers.append(functions.get_chatbot_response(data['number']))


###-------------------------------------------------------------------------------------------------------------------------------------------
    socketio.emit('all numbers', {'numbers': all_mah_numbers})
    socketio.emit('all users', {'users': all_users})
 def test_help(self):
     response = functions.get_chatbot_response('!! help')
     self.assertEquals(response, help)
Exemple #8
0
 def test_not_command(self):
     response = functions.get_chatbot_response("!! add 2 2")
     print(response)
     self.assertEquals(response,22)
 def test_about(self):
     response = functions.get_chatbot_response('!! about')
     self.assertEquals(response, about)
 def test_Rank_No_region(self):
     response = functions.get_chatbot_response('!! rank anniebot')
     self.assertEquals(response['number'],
                       "ERROR: Either no summoner name or Region given")
Exemple #11
0
 def test_not_command(self):
     response = functions.get_chatbot_response("!! Purple ")
     self.assertEqual(response, "Oops! I didn't recognize your command :(")
Exemple #12
0
 def test_regular_strings(self):
     response = functions.get_chatbot_response("blah blah")
     self.assertEqual(response,'')
Exemple #13
0
 def test_say_command(self):
     response = functions.get_chatbot_response("!! say Hello World!")
     self.assertEqual(response,"Hello World!")
Exemple #14
0
 def test_hey_command(self):
     response = functions.get_chatbot_response("!! Hey ")
     self.assertEqual(response,"What's up!")
Exemple #15
0
 def test_divide_command(self):
     response = functions.get_chatbot_response("!! divide 8 2")
     self.assertEqual(response,4)
 def test_add_command(self):
     response = functions.get_chatbot_response("!! add 10 10")
     self.assertEquals(response, 20)
 def test_say_command(self):
     response = functions.get_chatbot_response("!! say word")
     self.assertEquals(response, "word")
Exemple #18
0
 def test_say_command(self):
     response = functions.get_chatbot_response('!! say butts')
     self.assertEquals(response, 'butts')
Exemple #19
0
 def test_hello_command(self):
     response = functions.get_chatbot_response('!! hello there')
     self.assertEquals(response, 'Hey there!')
Exemple #20
0
 def test_add_command(self):
     response = functions.get_chatbot_response("!! add 8 2")
     self.assertEqual(response,10)
 def test_Rank_region2(self):
     response = functions.get_chatbot_response('!! rank na doublelift')
     self.assertEquals(response, doublelift)
 def test_joke(self):
     response = functions.get_chatbot_response('!! joke')
     for i in jokes:
         if str(response['number']) == str(i):
             k = i
     self.assertEqual(str(response['number']), k)
 def test_say_command(self):
     response = functions.get_chatbot_response('!! say dang dude')
     self.assertEquals(response, say)
 def test_first_command(self):
     response = functions.get_chatbot_response('hello')
     self.assertEquals(response, points, a)
 def test_not_command(self):
     response = functions.get_chatbot_response('!! Potato')
     self.assertEquals(response, potato)
Exemple #26
0
 def test_not_command(self):
     response = functions.get_chatbot_response("Purple")
     self.assertEqual(response, "")
 def test_say_blank(self):
     response = functions.get_chatbot_response('!! say')
     self.assertEquals(response, blank)
Exemple #28
0
 def test_add_command(self):
     response = functions.get_chatbot_response(''' put something here ''')
     self.assertEqual(''' put something here''')
 def test_Rank_region(self):
     response = functions.get_chatbot_response('!! rank na anniebot')
     self.assertEquals(response, annie)
Exemple #30
0
 def test_not_command(self):
     response = functions.get_chatbot_response('hello')
     self.assertEquals(response, '')