-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathresponses.py
61 lines (50 loc) · 1.94 KB
/
responses.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
54
55
56
57
58
59
60
61
import asyncio
from random import choice, randint
from typing import List, Dict
from cron_job import scrape_data
from db import FoodDatabase
def get_response(user_input: str) -> str:
lowered: str = user_input.lower()
if lowered[0] != "!":
return None
lowered = lowered[1:]
if lowered == '':
return 'Well, you\'re silent...'
elif lowered.startswith('hello'):
return 'Hello there!'
elif lowered.startswith('good'):
return 'Good, thanks!'
elif lowered.startswith('bye'):
return 'See you!'
elif lowered.startswith('dice'):
return f'You rolled: {randint(1,6)}'
elif lowered.startswith('events --user admin --pass admin'):
scrape_data()
return "I am scraping some events and adding them to the database"
elif lowered.startswith('events'):
"""
return every row in database as event as a joined string
"""
#datetime
#time == 12 ->
# data = scrape_data()
db = FoodDatabase()
# TODO: Replace with today's event
data = db.get_today_event()
output = ""
if not data:
return "No events found in database, check back after 12AM or 12PM"
for index, event in enumerate(data):
event_str = f"## Event {index+1} \n > **Name**: {event[0]}\n > **Location**: {event[4]}\n > **Time**: {event[3]}\n"
output += str(event_str)
return output
elif lowered.startswith('help'):
return """!hello: Say hello to users \n !good: My feeling now \n !bye: Say goodbye to Bot \n !dice: How lucky are you today \n !events: List of food events today \n !help: Showing this lists"""
else:
return choice(['I do not understand...',
'What are you talking about?',
'Do you mind rephrasing that?'])
if __name__ == "__main__":
cmd = '!events'
output = get_response(cmd)
print(output)