-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatterbot.py
36 lines (32 loc) · 1.12 KB
/
chatterbot.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
class Chatterbot:
def __init__(self, display):
self.display = display
# x and y define top left corner of text
self.x = 10
self.y = 220
# wrap is number of pixels before text wraps
self.wrap = 250
def babble(self, datetime):
self.display.set_pen(118, 82, 46)
if self.decide_what_to_say() == "time":
text = self.format_date_time(datetime)
self.display.text(text, self.x + 5, self.y, self.wrap)
def decide_what_to_say(self):
return "time"
def format_date_time(self, datetime):
months = {
1 : "January",
2 : "February",
3 : "March",
4 : "April",
5 : "May",
6 : "June",
7 : "July",
8 : "August",
9 : "September",
10 : "October",
11 : "November",
12 : "December",}
date = str(datetime[2]) + " " + months[datetime[1]] + " " + str(datetime[0])
time = str(datetime[3]) + "." + str(datetime[4]) + ":" + str(datetime[5])
return date + " " + time