-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFixedResponses.py
53 lines (43 loc) · 1.23 KB
/
FixedResponses.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
from random import randint
import pickle
import os
from TwitterAPI import *
import time
class FixedResponses:
dict = {}
def __init__(self):
if os.path.isfile("answers.pickle"):
self.dict = pickle.load(open("answers.pickle", "rb"))
else:
self.save_pickle()
def get_response(self, word):
w = str(word).lower()
posible_responses = self.dict[w]
return posible_responses[randint(0, len(posible_responses) - 1)]
def append_response(self,key, value):
key = str(key).lower()
if self.contains_response(key):
self.dict[key].append(value.lower())
self.save_pickle()
else:
self.dict[key] = [value.lower()]
self.save_pickle()
def save_pickle(self):
pickle.dump(self.dict, open("answers.pickle", "wb"))
#self.dict = pickle.load(open("answers.pickle", "rb"))
def contains_response(self,k):
return k in self.dict
"""f = float(((60+96)/2) * 0.50) - 70.0
print(str(f))
f += float(80*.25)
print(str(f))
f += float(55*.20)
print(str(f))"""
"""f = float(78 * 0.45) - 70
print(str(f))
f += float(80*.10)
print(str(f))
f += float(70*.25)
print(str(f))
f += float(50*.20)
print(str(f))"""