first commit
This commit is contained in:
35
bot/command_registry.py
Normal file
35
bot/command_registry.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
command_registry.py - Module registration for bot commands
|
||||
|
||||
Register domain-specific handlers for different interaction types.
|
||||
"""
|
||||
|
||||
COMMAND_MODULES = {}
|
||||
|
||||
|
||||
def register_module(interaction_type, handler):
|
||||
"""
|
||||
Register a handler for an interaction type.
|
||||
|
||||
Args:
|
||||
interaction_type: String key (e.g., 'med', 'habit', 'task')
|
||||
handler: Async function(message, session, parsed) -> None
|
||||
|
||||
Example:
|
||||
async def handle_med(message, session, parsed):
|
||||
action = parsed['action']
|
||||
# ... handle medication logic ...
|
||||
|
||||
register_module('med', handle_med)
|
||||
"""
|
||||
COMMAND_MODULES[interaction_type] = handler
|
||||
|
||||
|
||||
def get_handler(interaction_type):
|
||||
"""Get the registered handler for an interaction type."""
|
||||
return COMMAND_MODULES.get(interaction_type)
|
||||
|
||||
|
||||
def list_registered():
|
||||
"""List all registered interaction types."""
|
||||
return list(COMMAND_MODULES.keys())
|
||||
Reference in New Issue
Block a user