wappa 0.1.9__py3-none-any.whl ā 0.1.10__py3-none-any.whl
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.
Potentially problematic release.
This version of wappa might be problematic. Click here for more details.
- wappa/__init__.py +4 -5
- wappa/api/controllers/webhook_controller.py +5 -2
- wappa/api/dependencies/__init__.py +0 -5
- wappa/api/middleware/error_handler.py +4 -4
- wappa/api/middleware/owner.py +11 -5
- wappa/api/routes/webhooks.py +2 -2
- wappa/cli/__init__.py +1 -1
- wappa/cli/examples/init/app/main.py +2 -1
- wappa/cli/examples/init/app/master_event.py +5 -3
- wappa/cli/examples/json_cache_example/app/__init__.py +1 -1
- wappa/cli/examples/json_cache_example/app/main.py +56 -44
- wappa/cli/examples/json_cache_example/app/master_event.py +181 -145
- wappa/cli/examples/json_cache_example/app/models/__init__.py +1 -1
- wappa/cli/examples/json_cache_example/app/models/json_demo_models.py +32 -51
- wappa/cli/examples/json_cache_example/app/scores/__init__.py +2 -2
- wappa/cli/examples/json_cache_example/app/scores/score_base.py +52 -46
- wappa/cli/examples/json_cache_example/app/scores/score_cache_statistics.py +70 -62
- wappa/cli/examples/json_cache_example/app/scores/score_message_history.py +41 -44
- wappa/cli/examples/json_cache_example/app/scores/score_state_commands.py +83 -71
- wappa/cli/examples/json_cache_example/app/scores/score_user_management.py +73 -57
- wappa/cli/examples/json_cache_example/app/utils/__init__.py +2 -2
- wappa/cli/examples/json_cache_example/app/utils/cache_utils.py +54 -56
- wappa/cli/examples/json_cache_example/app/utils/message_utils.py +85 -80
- wappa/cli/examples/openai_transcript/app/main.py +2 -1
- wappa/cli/examples/openai_transcript/app/master_event.py +31 -22
- wappa/cli/examples/openai_transcript/app/openai_utils/__init__.py +1 -1
- wappa/cli/examples/openai_transcript/app/openai_utils/audio_processing.py +37 -24
- wappa/cli/examples/redis_cache_example/app/__init__.py +1 -1
- wappa/cli/examples/redis_cache_example/app/main.py +56 -44
- wappa/cli/examples/redis_cache_example/app/master_event.py +181 -145
- wappa/cli/examples/redis_cache_example/app/models/redis_demo_models.py +31 -50
- wappa/cli/examples/redis_cache_example/app/scores/__init__.py +2 -2
- wappa/cli/examples/redis_cache_example/app/scores/score_base.py +52 -46
- wappa/cli/examples/redis_cache_example/app/scores/score_cache_statistics.py +70 -62
- wappa/cli/examples/redis_cache_example/app/scores/score_message_history.py +41 -44
- wappa/cli/examples/redis_cache_example/app/scores/score_state_commands.py +83 -71
- wappa/cli/examples/redis_cache_example/app/scores/score_user_management.py +73 -57
- wappa/cli/examples/redis_cache_example/app/utils/__init__.py +2 -2
- wappa/cli/examples/redis_cache_example/app/utils/cache_utils.py +54 -56
- wappa/cli/examples/redis_cache_example/app/utils/message_utils.py +85 -80
- wappa/cli/examples/simple_echo_example/app/__init__.py +1 -1
- wappa/cli/examples/simple_echo_example/app/main.py +41 -33
- wappa/cli/examples/simple_echo_example/app/master_event.py +78 -57
- wappa/cli/examples/wappa_full_example/app/__init__.py +1 -1
- wappa/cli/examples/wappa_full_example/app/handlers/__init__.py +1 -1
- wappa/cli/examples/wappa_full_example/app/handlers/command_handlers.py +134 -126
- wappa/cli/examples/wappa_full_example/app/handlers/message_handlers.py +237 -229
- wappa/cli/examples/wappa_full_example/app/handlers/state_handlers.py +170 -148
- wappa/cli/examples/wappa_full_example/app/main.py +51 -39
- wappa/cli/examples/wappa_full_example/app/master_event.py +179 -120
- wappa/cli/examples/wappa_full_example/app/models/__init__.py +1 -1
- wappa/cli/examples/wappa_full_example/app/models/state_models.py +113 -104
- wappa/cli/examples/wappa_full_example/app/models/user_models.py +92 -76
- wappa/cli/examples/wappa_full_example/app/models/webhook_metadata.py +109 -83
- wappa/cli/examples/wappa_full_example/app/utils/__init__.py +1 -1
- wappa/cli/examples/wappa_full_example/app/utils/cache_utils.py +132 -113
- wappa/cli/examples/wappa_full_example/app/utils/media_handler.py +175 -132
- wappa/cli/examples/wappa_full_example/app/utils/metadata_extractor.py +126 -87
- wappa/cli/main.py +9 -4
- wappa/core/__init__.py +18 -23
- wappa/core/config/settings.py +7 -5
- wappa/core/events/default_handlers.py +1 -1
- wappa/core/factory/wappa_builder.py +38 -25
- wappa/core/plugins/redis_plugin.py +1 -3
- wappa/core/plugins/wappa_core_plugin.py +7 -6
- wappa/core/types.py +12 -12
- wappa/core/wappa_app.py +10 -8
- wappa/database/__init__.py +3 -4
- wappa/domain/enums/messenger_platform.py +1 -2
- wappa/domain/factories/media_factory.py +5 -20
- wappa/domain/factories/message_factory.py +5 -20
- wappa/domain/factories/messenger_factory.py +2 -4
- wappa/domain/interfaces/cache_interface.py +7 -7
- wappa/domain/interfaces/media_interface.py +2 -5
- wappa/domain/models/media_result.py +1 -3
- wappa/domain/models/platforms/platform_config.py +1 -3
- wappa/messaging/__init__.py +9 -12
- wappa/messaging/whatsapp/handlers/whatsapp_media_handler.py +20 -22
- wappa/models/__init__.py +27 -35
- wappa/persistence/__init__.py +12 -15
- wappa/persistence/cache_factory.py +0 -1
- wappa/persistence/json/__init__.py +1 -1
- wappa/persistence/json/cache_adapters.py +37 -25
- wappa/persistence/json/handlers/state_handler.py +60 -52
- wappa/persistence/json/handlers/table_handler.py +51 -49
- wappa/persistence/json/handlers/user_handler.py +71 -55
- wappa/persistence/json/handlers/utils/file_manager.py +42 -39
- wappa/persistence/json/handlers/utils/key_factory.py +1 -1
- wappa/persistence/json/handlers/utils/serialization.py +13 -11
- wappa/persistence/json/json_cache_factory.py +4 -8
- wappa/persistence/json/storage_manager.py +66 -79
- wappa/persistence/memory/__init__.py +1 -1
- wappa/persistence/memory/cache_adapters.py +37 -25
- wappa/persistence/memory/handlers/state_handler.py +62 -52
- wappa/persistence/memory/handlers/table_handler.py +59 -53
- wappa/persistence/memory/handlers/user_handler.py +75 -55
- wappa/persistence/memory/handlers/utils/key_factory.py +1 -1
- wappa/persistence/memory/handlers/utils/memory_store.py +75 -71
- wappa/persistence/memory/handlers/utils/ttl_manager.py +59 -67
- wappa/persistence/memory/memory_cache_factory.py +3 -7
- wappa/persistence/memory/storage_manager.py +52 -62
- wappa/persistence/redis/cache_adapters.py +27 -21
- wappa/persistence/redis/ops.py +11 -11
- wappa/persistence/redis/redis_client.py +4 -6
- wappa/persistence/redis/redis_manager.py +12 -4
- wappa/processors/factory.py +5 -5
- wappa/schemas/factory.py +2 -5
- wappa/schemas/whatsapp/message_types/errors.py +3 -12
- wappa/schemas/whatsapp/validators.py +3 -3
- wappa/webhooks/__init__.py +17 -18
- wappa/webhooks/factory.py +3 -5
- wappa/webhooks/whatsapp/__init__.py +10 -13
- wappa/webhooks/whatsapp/message_types/audio.py +0 -4
- wappa/webhooks/whatsapp/message_types/document.py +1 -9
- wappa/webhooks/whatsapp/message_types/errors.py +3 -12
- wappa/webhooks/whatsapp/message_types/location.py +1 -21
- wappa/webhooks/whatsapp/message_types/sticker.py +1 -5
- wappa/webhooks/whatsapp/message_types/text.py +0 -6
- wappa/webhooks/whatsapp/message_types/video.py +1 -20
- wappa/webhooks/whatsapp/status_models.py +2 -2
- wappa/webhooks/whatsapp/validators.py +3 -3
- {wappa-0.1.9.dist-info ā wappa-0.1.10.dist-info}/METADATA +362 -8
- {wappa-0.1.9.dist-info ā wappa-0.1.10.dist-info}/RECORD +126 -126
- {wappa-0.1.9.dist-info ā wappa-0.1.10.dist-info}/WHEEL +0 -0
- {wappa-0.1.9.dist-info ā wappa-0.1.10.dist-info}/entry_points.txt +0 -0
- {wappa-0.1.9.dist-info ā wappa-0.1.10.dist-info}/licenses/LICENSE +0 -0
|
@@ -47,29 +47,29 @@ from .master_event import WappaFullExampleHandler
|
|
|
47
47
|
def validate_configuration() -> bool:
|
|
48
48
|
"""
|
|
49
49
|
Validate required configuration settings.
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
Returns:
|
|
52
52
|
True if configuration is valid, False otherwise
|
|
53
53
|
"""
|
|
54
54
|
missing_configs = []
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
if not settings.wp_access_token:
|
|
57
57
|
missing_configs.append("WP_ACCESS_TOKEN")
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
if not settings.wp_phone_id:
|
|
60
60
|
missing_configs.append("WP_PHONE_ID")
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
if not settings.wp_bid:
|
|
63
63
|
missing_configs.append("WP_BID")
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
if not settings.has_redis:
|
|
66
66
|
missing_configs.append("REDIS_URL")
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
if missing_configs:
|
|
69
69
|
logger.error(f"ā Missing required configuration: {', '.join(missing_configs)}")
|
|
70
70
|
logger.error("š” Create a .env file with the required credentials")
|
|
71
71
|
return False
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
logger.info("ā
Configuration validation passed")
|
|
74
74
|
return True
|
|
75
75
|
|
|
@@ -81,7 +81,7 @@ def display_startup_information() -> None:
|
|
|
81
81
|
print(f"š Wappa v{__version__} - Full Example (Comprehensive Demo)")
|
|
82
82
|
print("=" * 80)
|
|
83
83
|
print()
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
print("šÆ *COMPREHENSIVE WAPPA FRAMEWORK DEMONSTRATION*")
|
|
86
86
|
print(" This example showcases ALL major Wappa framework features:")
|
|
87
87
|
print(" ⢠Complete message type handling with metadata extraction")
|
|
@@ -91,15 +91,21 @@ def display_startup_information() -> None:
|
|
|
91
91
|
print(" ⢠Welcome messages for first-time users")
|
|
92
92
|
print(" ⢠Professional error handling and logging")
|
|
93
93
|
print()
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
print("š *CONFIGURATION STATUS:*")
|
|
96
|
-
print(
|
|
97
|
-
|
|
96
|
+
print(
|
|
97
|
+
f" ⢠Access Token: {'ā
Configured' if settings.wp_access_token else 'ā Missing'}"
|
|
98
|
+
)
|
|
99
|
+
print(
|
|
100
|
+
f" ⢠Phone ID: {settings.wp_phone_id if settings.wp_phone_id else 'ā Missing'}"
|
|
101
|
+
)
|
|
98
102
|
print(f" ⢠Business ID: {'ā
Configured' if settings.wp_bid else 'ā Missing'}")
|
|
99
103
|
print(f" ⢠Redis URL: {'ā
Configured' if settings.has_redis else 'ā Missing'}")
|
|
100
|
-
print(
|
|
104
|
+
print(
|
|
105
|
+
f" ⢠Environment: {'š ļø Development' if settings.is_development else 'š Production'}"
|
|
106
|
+
)
|
|
101
107
|
print()
|
|
102
|
-
|
|
108
|
+
|
|
103
109
|
print("š® *INTERACTIVE DEMO COMMANDS:*")
|
|
104
110
|
print(" ⢠`/button` ā Interactive button demo with animal selection")
|
|
105
111
|
print(" - Creates buttons for Kitty š± and Puppy š¶")
|
|
@@ -120,7 +126,7 @@ def display_startup_information() -> None:
|
|
|
120
126
|
print(" - Shares predefined location (BogotĆ”, Colombia)")
|
|
121
127
|
print(" - Shows location message implementation")
|
|
122
128
|
print()
|
|
123
|
-
|
|
129
|
+
|
|
124
130
|
print("šØ *MESSAGE TYPE HANDLING:*")
|
|
125
131
|
print(" ⢠Text Messages ā Echo with 'Echo - {content}' + metadata")
|
|
126
132
|
print(" ⢠Media Messages ā Relay same media using media_id + metadata")
|
|
@@ -128,14 +134,14 @@ def display_startup_information() -> None:
|
|
|
128
134
|
print(" ⢠Contact Messages ā Echo contact information + metadata")
|
|
129
135
|
print(" ⢠Interactive Messages ā Process selections + metadata")
|
|
130
136
|
print()
|
|
131
|
-
|
|
137
|
+
|
|
132
138
|
print("š¤ *USER MANAGEMENT FEATURES:*")
|
|
133
139
|
print(" ⢠First-time user detection and welcome messages")
|
|
134
140
|
print(" ⢠User profile caching with activity tracking")
|
|
135
141
|
print(" ⢠Message count and interaction statistics")
|
|
136
142
|
print(" ⢠Command usage analytics")
|
|
137
143
|
print()
|
|
138
|
-
|
|
144
|
+
|
|
139
145
|
print("šļø *TECHNICAL ARCHITECTURE:*")
|
|
140
146
|
print(" ⢠Redis cache for user profiles and interactive states")
|
|
141
147
|
print(" ⢠Comprehensive metadata extraction per message type")
|
|
@@ -144,7 +150,7 @@ def display_startup_information() -> None:
|
|
|
144
150
|
print(" ⢠Structured logging with performance metrics")
|
|
145
151
|
print(" ⢠Clean code architecture with separation of concerns")
|
|
146
152
|
print()
|
|
147
|
-
|
|
153
|
+
|
|
148
154
|
print("š *DEMONSTRATED PATTERNS:*")
|
|
149
155
|
print(" ⢠Complete IMessenger interface utilization")
|
|
150
156
|
print(" ⢠Media handling with download/upload capabilities")
|
|
@@ -158,7 +164,7 @@ def display_startup_information() -> None:
|
|
|
158
164
|
def create_wappa_application() -> Wappa:
|
|
159
165
|
"""
|
|
160
166
|
Create and configure the Wappa application.
|
|
161
|
-
|
|
167
|
+
|
|
162
168
|
Returns:
|
|
163
169
|
Configured Wappa application instance
|
|
164
170
|
"""
|
|
@@ -166,10 +172,10 @@ def create_wappa_application() -> Wappa:
|
|
|
166
172
|
# Create Wappa instance with Redis cache
|
|
167
173
|
logger.info("šļø Creating Wappa application with Redis cache...")
|
|
168
174
|
app = Wappa(cache="redis")
|
|
169
|
-
|
|
175
|
+
|
|
170
176
|
logger.info("ā
Wappa application created successfully")
|
|
171
177
|
return app
|
|
172
|
-
|
|
178
|
+
|
|
173
179
|
except Exception as e:
|
|
174
180
|
logger.error(f"ā Failed to create Wappa application: {e}")
|
|
175
181
|
raise
|
|
@@ -178,7 +184,7 @@ def create_wappa_application() -> Wappa:
|
|
|
178
184
|
def main() -> None:
|
|
179
185
|
"""
|
|
180
186
|
Main application entry point.
|
|
181
|
-
|
|
187
|
+
|
|
182
188
|
Demonstrates complete Wappa framework integration with:
|
|
183
189
|
- Configuration validation
|
|
184
190
|
- Application setup
|
|
@@ -186,50 +192,54 @@ def main() -> None:
|
|
|
186
192
|
- Professional startup flow
|
|
187
193
|
"""
|
|
188
194
|
logger.info("š Starting Wappa Full Example - Comprehensive Demo")
|
|
189
|
-
|
|
195
|
+
|
|
190
196
|
try:
|
|
191
197
|
# Display comprehensive startup information
|
|
192
198
|
display_startup_information()
|
|
193
|
-
|
|
199
|
+
|
|
194
200
|
# Validate configuration before proceeding
|
|
195
201
|
if not validate_configuration():
|
|
196
|
-
logger.error(
|
|
202
|
+
logger.error(
|
|
203
|
+
"ā Configuration validation failed - cannot start application"
|
|
204
|
+
)
|
|
197
205
|
return
|
|
198
|
-
|
|
206
|
+
|
|
199
207
|
# Create Wappa application
|
|
200
208
|
app = create_wappa_application()
|
|
201
|
-
|
|
209
|
+
|
|
202
210
|
# Create and set our comprehensive WappaEventHandler implementation
|
|
203
211
|
handler = WappaFullExampleHandler()
|
|
204
212
|
app.set_event_handler(handler)
|
|
205
|
-
|
|
206
|
-
logger.info(
|
|
207
|
-
|
|
213
|
+
|
|
214
|
+
logger.info(
|
|
215
|
+
"ā
Application initialization completed with comprehensive WappaEventHandler"
|
|
216
|
+
)
|
|
217
|
+
|
|
208
218
|
print("š Starting comprehensive Wappa demo server...")
|
|
209
219
|
print("š” Press CTRL+C to stop the server")
|
|
210
220
|
print()
|
|
211
221
|
print("šÆ *Try these features once connected:*")
|
|
212
222
|
print(" 1. Send any message ā See metadata extraction + echo")
|
|
213
223
|
print(" 2. Send /button ā Interactive button demo")
|
|
214
|
-
print(" 3. Send /list ā Interactive list demo")
|
|
224
|
+
print(" 3. Send /list ā Interactive list demo")
|
|
215
225
|
print(" 4. Send /cta ā Call-to-action button")
|
|
216
226
|
print(" 5. Send /location ā Location sharing demo")
|
|
217
227
|
print(" 6. Send media files ā See media relay functionality")
|
|
218
228
|
print("=" * 80)
|
|
219
229
|
print()
|
|
220
|
-
|
|
230
|
+
|
|
221
231
|
# Start the application
|
|
222
232
|
# The framework will handle dependency injection automatically
|
|
223
233
|
app.run()
|
|
224
|
-
|
|
234
|
+
|
|
225
235
|
except KeyboardInterrupt:
|
|
226
236
|
logger.info("š Application stopped by user")
|
|
227
237
|
print("\nš Wappa Full Example stopped by user")
|
|
228
|
-
|
|
238
|
+
|
|
229
239
|
except Exception as e:
|
|
230
240
|
logger.error(f"ā Application startup error: {e}", exc_info=True)
|
|
231
241
|
print(f"\nā Server error: {e}")
|
|
232
|
-
|
|
242
|
+
|
|
233
243
|
finally:
|
|
234
244
|
logger.info("š Wappa Full Example completed")
|
|
235
245
|
print("š Wappa Full Example completed")
|
|
@@ -241,17 +251,19 @@ def main() -> None:
|
|
|
241
251
|
try:
|
|
242
252
|
logger.info("š¦ Creating module-level Wappa application instance")
|
|
243
253
|
app = Wappa(cache="redis")
|
|
244
|
-
|
|
254
|
+
|
|
245
255
|
# Create and set our comprehensive WappaEventHandler implementation
|
|
246
256
|
handler = WappaFullExampleHandler()
|
|
247
257
|
app.set_event_handler(handler)
|
|
248
|
-
|
|
249
|
-
logger.info(
|
|
250
|
-
|
|
258
|
+
|
|
259
|
+
logger.info(
|
|
260
|
+
"ā
Module-level application instance ready with comprehensive WappaEventHandler"
|
|
261
|
+
)
|
|
262
|
+
|
|
251
263
|
except Exception as e:
|
|
252
264
|
logger.error(f"ā Failed to create module-level app instance: {e}")
|
|
253
265
|
raise
|
|
254
266
|
|
|
255
267
|
|
|
256
268
|
if __name__ == "__main__":
|
|
257
|
-
main()
|
|
269
|
+
main()
|