-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.py
More file actions
43 lines (33 loc) · 1.02 KB
/
Copy pathCard.py
File metadata and controls
43 lines (33 loc) · 1.02 KB
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
from typing import List
from DialogFlowPy.Button import Button
from DialogFlowPy.OpenUriAction import OpenUriAction
class Card(dict):
"""
{
"title": string,
"subtitle": string,
"imageUri": string,
"buttons": [
{
object(Button)
}
],
}
"""
def __init__(self, title: str = '', image_uri: str = '', subtitle: str = '', buttons: List[Button] = None):
super().__init__()
self['buttons'] = []
for item in buttons:
print(type(item))
assert isinstance(item, Button)
self['buttons'].append(item)
if title is not None:
self['title'] = title
if image_uri is not None:
self['imageUri'] = image_uri
if subtitle is not None:
self['subtitle'] = subtitle
def add_button(self, title: str, uri: str) -> Button:
button = Button(title=title, open_uri_action=OpenUriAction(uri=uri))
self['buttons'].append(button)
return button