digitalguide 0.0.552__tar.gz → 0.0.554__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {digitalguide-0.0.552 → digitalguide-0.0.554}/PKG-INFO +1 -1
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/generateActions.py +43 -26
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide.egg-info/PKG-INFO +1 -1
- {digitalguide-0.0.552 → digitalguide-0.0.554}/setup.py +1 -1
- {digitalguide-0.0.552 → digitalguide-0.0.554}/LICENSE +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/README.md +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/__init__.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/db_objects.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/generateStates.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/pattern.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/send_utils.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/__init__.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/contextActions.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/imageActions.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/listenfrageActions.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/schaetzfragenActions.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/writeActions.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/wa_utils.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide.egg-info/SOURCES.txt +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide.egg-info/dependency_links.txt +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide.egg-info/requires.txt +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide.egg-info/top_level.txt +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/setup.cfg +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/tests/test_emoji_pattern.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/tests/test_image_actions.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/tests/test_jahreszahl_pattern.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/tests/test_kommazahl_pattern.py +0 -0
- {digitalguide-0.0.552 → digitalguide-0.0.554}/tests/test_pattern.py +0 -0
|
@@ -54,46 +54,63 @@ class Action():
|
|
|
54
54
|
placeholder_dict["profile_name"] = update.from_user.name
|
|
55
55
|
placeholder_dict["echo"] = get_message_text(update)
|
|
56
56
|
|
|
57
|
+
def fill(text):
|
|
58
|
+
# replace placeholders like {teamname} in every user-facing text
|
|
59
|
+
return text.format(**placeholder_dict) if isinstance(text, str) else text
|
|
60
|
+
|
|
57
61
|
|
|
58
62
|
if item["type"] == "message":
|
|
59
63
|
|
|
60
64
|
if "reply_buttons" in item.keys():
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
buttons = [
|
|
66
|
+
types.Button(title=fill(btn["text"]), callback_data=btn["id"])
|
|
67
|
+
for btn in item["reply_buttons"]
|
|
68
|
+
]
|
|
69
|
+
header = item.get("header")
|
|
70
|
+
if header and header.startswith(("http://", "https://")):
|
|
71
|
+
# media header: pywa sends an interactive message with an image header
|
|
72
|
+
result = client.send_image(
|
|
73
|
+
to=update.from_user.wa_id,
|
|
74
|
+
image=header,
|
|
75
|
+
caption=fill(item["text"]),
|
|
76
|
+
footer=fill(item.get("footer")),
|
|
77
|
+
buttons=buttons
|
|
78
|
+
)
|
|
79
|
+
else:
|
|
80
|
+
result = client.send_message(
|
|
81
|
+
to=update.from_user.wa_id,
|
|
82
|
+
text=fill(item["text"]),
|
|
83
|
+
header=fill(header),
|
|
84
|
+
footer=fill(item.get("footer")),
|
|
85
|
+
buttons=buttons
|
|
86
|
+
)
|
|
70
87
|
|
|
71
88
|
elif "button" in item.keys() and "section_title" in item.keys():
|
|
72
89
|
section_dict = [
|
|
73
90
|
{
|
|
74
|
-
"title": item["section_title"],
|
|
91
|
+
"title": fill(item["section_title"]),
|
|
75
92
|
"rows": [],
|
|
76
93
|
}
|
|
77
94
|
]
|
|
78
95
|
|
|
79
96
|
for row in item["rows"]:
|
|
80
97
|
row_dict = {"id": row["id"],
|
|
81
|
-
"title": row["title"],
|
|
82
|
-
"description": row.get("description", "")}
|
|
98
|
+
"title": fill(row["title"]),
|
|
99
|
+
"description": fill(row.get("description", ""))}
|
|
83
100
|
section_dict[0]["rows"].append(row_dict)
|
|
84
101
|
|
|
85
102
|
result = send_interactive_list(client,
|
|
86
103
|
recipient_id=update.from_user.wa_id,
|
|
87
|
-
body_text=item["text"]
|
|
88
|
-
button_text=item["button"],
|
|
104
|
+
body_text=fill(item["text"]),
|
|
105
|
+
button_text=fill(item["button"]),
|
|
89
106
|
sections=section_dict,
|
|
90
|
-
header_text=item.get("header", None),
|
|
91
|
-
footer_text=item.get("footer", None))
|
|
107
|
+
header_text=fill(item.get("header", None)),
|
|
108
|
+
footer_text=fill(item.get("footer", None)))
|
|
92
109
|
|
|
93
110
|
else:
|
|
94
111
|
result = client.send_message(
|
|
95
112
|
to=update.from_user.wa_id,
|
|
96
|
-
text=item["text"]
|
|
113
|
+
text=fill(item["text"])
|
|
97
114
|
)
|
|
98
115
|
|
|
99
116
|
elif item["type"] == "carousel":
|
|
@@ -101,13 +118,13 @@ class Action():
|
|
|
101
118
|
new_cards = []
|
|
102
119
|
for i, card in enumerate(item["cards"]):
|
|
103
120
|
if "action_url" in card and "action_text" in card:
|
|
104
|
-
actions = pywa.types.callback.URLButton(title=card["action_text"], url=card["action_url"])
|
|
121
|
+
actions = pywa.types.callback.URLButton(title=fill(card["action_text"]), url=card["action_url"])
|
|
105
122
|
elif "quick_reply_text" in card:
|
|
106
|
-
actions = [pywa.types.callback.Button(title=card["quick_reply_text"], callback_data=card["quick_reply_text"])]
|
|
123
|
+
actions = [pywa.types.callback.Button(title=fill(card["quick_reply_text"]), callback_data=card["quick_reply_text"])]
|
|
107
124
|
else:
|
|
108
125
|
actions = []
|
|
109
126
|
|
|
110
|
-
new_card = pywa.types.callback.ImageCarouselCard(body=card["body"]
|
|
127
|
+
new_card = pywa.types.callback.ImageCarouselCard(body=fill(card["body"]),
|
|
111
128
|
image=card["header"],
|
|
112
129
|
buttons=actions)
|
|
113
130
|
|
|
@@ -115,7 +132,7 @@ class Action():
|
|
|
115
132
|
|
|
116
133
|
logger.info("Cards created, sending carousel")
|
|
117
134
|
result = client.send_carousel(to=update.from_user.wa_id,
|
|
118
|
-
body=item["text"]
|
|
135
|
+
body=fill(item["text"]),
|
|
119
136
|
cards=new_cards)
|
|
120
137
|
|
|
121
138
|
|
|
@@ -124,12 +141,12 @@ class Action():
|
|
|
124
141
|
to=update.from_user.wa_id,
|
|
125
142
|
latitude=item["latitude"],
|
|
126
143
|
longitude=item["longitude"],
|
|
127
|
-
name=item.get("title", None),
|
|
128
|
-
address=item.get("address", None),
|
|
144
|
+
name=fill(item.get("title", None)),
|
|
145
|
+
address=fill(item.get("address", None)),
|
|
129
146
|
)
|
|
130
147
|
|
|
131
148
|
elif item["type"] == "photo":
|
|
132
|
-
caption = item.get("caption")
|
|
149
|
+
caption = fill(item.get("caption"))
|
|
133
150
|
if "url" in item.keys():
|
|
134
151
|
result = client.send_image(
|
|
135
152
|
to=update.from_user.wa_id,
|
|
@@ -171,9 +188,9 @@ class Action():
|
|
|
171
188
|
)
|
|
172
189
|
|
|
173
190
|
elif item["type"] == "poll":
|
|
174
|
-
message = item["question"] + "\n"
|
|
191
|
+
message = fill(item["question"]) + "\n"
|
|
175
192
|
for option in item["options"]:
|
|
176
|
-
message += option + "\n"
|
|
193
|
+
message += fill(option) + "\n"
|
|
177
194
|
result = client.send_message(to=update.from_user.wa_id, text=message)
|
|
178
195
|
|
|
179
196
|
elif item["type"] == "function":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/contextActions.py
RENAMED
|
File without changes
|
|
File without changes
|
{digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/listenfrageActions.py
RENAMED
|
File without changes
|
{digitalguide-0.0.552 → digitalguide-0.0.554}/digitalguide/special_actions/schaetzfragenActions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|