trading_agent.gateway.routes.channel_routes
¶
Routes for the messaging channels: Telegram's state and its pairings.
GET /api/channels Telegram's state, paired chats and waiting codes POST /api/channels/telegram/pairings/{code}/approve pair the chat that was given a code DELETE /api/channels/telegram/chats/{chat_id} unpair a chat
Typical usage example:
application.include_router(ChannelRoutes(guard, store, configuration, secrets_present, channel).router())
ChannelRoutes
¶
Bases: RouteGroup
The channel routes.
Creates the routes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guard
|
AccessGuard
|
Checks the access token. |
required |
store
|
PairingStore
|
The pairing file. |
required |
configuration
|
TelegramConfiguration
|
The [telegram] settings. |
required |
token_present
|
bool
|
Whether TRADING_AGENT_TELEGRAM_BOT_TOKEN is set. |
required |
channel
|
TelegramChannel | None
|
The running channel, or None when Telegram is off. |
required |
Source code in src/trading_agent/gateway/routes/channel_routes.py
channels
¶
Telegram's state.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Whether it is enabled and has a token, its connection state, its bot name, the paired chats and the waiting codes. |
Source code in src/trading_agent/gateway/routes/channel_routes.py
approve
async
¶
Pairs the chat that was given a code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The code. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The paired chat. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
No valid code matches (status 404). |
Source code in src/trading_agent/gateway/routes/channel_routes.py
revoke
¶
Unpairs a chat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
int
|
The chat. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The chat that was removed. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
The chat is not paired (status 404). |