Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
 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, "")
Esempio n. 4
0
 def test_divide_command(self):
     response = functions.get_chatbot_response('!! divide 6 2')
     self.assertEquals(response, 3)
Esempio n. 5
0
 def test_add_command(self):
     response = functions.get_chatbot_response('!! add 2 3')
     self.assertEquals(response, 5)
Esempio n. 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})
Esempio n. 7
0
 def test_help(self):
     response = functions.get_chatbot_response('!! help')
     self.assertEquals(response, help)
Esempio n. 8
0
 def test_not_command(self):
     response = functions.get_chatbot_response("!! add 2 2")
     print(response)
     self.assertEquals(response,22)
Esempio n. 9
0
 def test_about(self):
     response = functions.get_chatbot_response('!! about')
     self.assertEquals(response, about)
Esempio n. 10
0
 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")
Esempio n. 11
0
 def test_not_command(self):
     response = functions.get_chatbot_response("!! Purple ")
     self.assertEqual(response, "Oops! I didn't recognize your command :(")
Esempio n. 12
0
 def test_regular_strings(self):
     response = functions.get_chatbot_response("blah blah")
     self.assertEqual(response,'')
Esempio n. 13
0
 def test_say_command(self):
     response = functions.get_chatbot_response("!! say Hello World!")
     self.assertEqual(response,"Hello World!")
Esempio n. 14
0
 def test_hey_command(self):
     response = functions.get_chatbot_response("!! Hey ")
     self.assertEqual(response,"What's up!")
Esempio n. 15
0
 def test_divide_command(self):
     response = functions.get_chatbot_response("!! divide 8 2")
     self.assertEqual(response,4)
Esempio n. 16
0
 def test_add_command(self):
     response = functions.get_chatbot_response("!! add 10 10")
     self.assertEquals(response, 20)
Esempio n. 17
0
 def test_say_command(self):
     response = functions.get_chatbot_response("!! say word")
     self.assertEquals(response, "word")
Esempio n. 18
0
 def test_say_command(self):
     response = functions.get_chatbot_response('!! say butts')
     self.assertEquals(response, 'butts')
Esempio n. 19
0
 def test_hello_command(self):
     response = functions.get_chatbot_response('!! hello there')
     self.assertEquals(response, 'Hey there!')
Esempio n. 20
0
 def test_add_command(self):
     response = functions.get_chatbot_response("!! add 8 2")
     self.assertEqual(response,10)
Esempio n. 21
0
 def test_Rank_region2(self):
     response = functions.get_chatbot_response('!! rank na doublelift')
     self.assertEquals(response, doublelift)
Esempio n. 22
0
 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)
Esempio n. 23
0
 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)
Esempio n. 25
0
 def test_not_command(self):
     response = functions.get_chatbot_response('!! Potato')
     self.assertEquals(response, potato)
Esempio n. 26
0
 def test_not_command(self):
     response = functions.get_chatbot_response("Purple")
     self.assertEqual(response, "")
Esempio n. 27
0
 def test_say_blank(self):
     response = functions.get_chatbot_response('!! say')
     self.assertEquals(response, blank)
Esempio n. 28
0
 def test_add_command(self):
     response = functions.get_chatbot_response(''' put something here ''')
     self.assertEqual(''' put something here''')
Esempio n. 29
0
 def test_Rank_region(self):
     response = functions.get_chatbot_response('!! rank na anniebot')
     self.assertEquals(response, annie)
Esempio n. 30
0
 def test_not_command(self):
     response = functions.get_chatbot_response('hello')
     self.assertEquals(response, '')