mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-04 20:05:16 +02:00
refactor(gateway): abstract platform command handling
This commit is contained in:
parent
f6eb955676
commit
e953be5e99
2 changed files with 73 additions and 6 deletions
41
surfsense_backend/app/gateway/base/commands.py
Normal file
41
surfsense_backend/app/gateway/base/commands.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
"""Provider-neutral command hooks for external chat gateways."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.gateway.base.adapter import BasePlatformAdapter, ParsedInboundEvent
|
||||
|
||||
|
||||
def command_name(text: str | None) -> str | None:
|
||||
if not text or not text.startswith("/"):
|
||||
return None
|
||||
return text.split(maxsplit=1)[0].split("@", 1)[0].lower()
|
||||
|
||||
|
||||
class BaseGatewayCommands:
|
||||
"""Default command behavior for platforms without slash-command onboarding."""
|
||||
|
||||
async def handle_start_command(
|
||||
self,
|
||||
*,
|
||||
session,
|
||||
adapter: BasePlatformAdapter,
|
||||
event: ParsedInboundEvent,
|
||||
) -> bool:
|
||||
return False
|
||||
|
||||
async def handle_help_command(
|
||||
self,
|
||||
*,
|
||||
adapter: BasePlatformAdapter,
|
||||
event: ParsedInboundEvent,
|
||||
) -> bool:
|
||||
return False
|
||||
|
||||
async def send_unbound_onboarding(
|
||||
self,
|
||||
*,
|
||||
adapter: BasePlatformAdapter,
|
||||
event: ParsedInboundEvent,
|
||||
dashboard_url: str,
|
||||
) -> None:
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue