mirror of
https://github.com/cline/cline.git
synced 2026-09-21 13:21:23 +08:00
feat(cli): improve Telegram connector with --allowed-user-id flag (#11256)
* feat(cli): add Telegram allowed user id flag * fix(cli): tighten connector authorization hooks
This commit is contained in:
+14
-6
@@ -54,24 +54,32 @@ cline connect
|
||||
|
||||
### Security
|
||||
|
||||
By default, anyone who finds your bot can message it and it will execute tasks on your machine. Lock it down with the `--hook-command` flag.
|
||||
By default, anyone who finds your bot can message it and it will execute tasks on your machine. The `cline connect` wizard asks whether to restrict Telegram access and can configure this for you.
|
||||
|
||||
<Steps>
|
||||
<Step title="Get your Telegram user ID">
|
||||
Message [@userinfobot](https://t.me/userinfobot) on Telegram. It replies with your user ID immediately.
|
||||
Message [@userinfobot](https://t.me/userinfobot) on Telegram. It replies with your numeric user ID immediately.
|
||||
</Step>
|
||||
|
||||
<Step title="Start with access control">
|
||||
Replace `12345` with your actual Telegram user ID:
|
||||
<Step title="Use the wizard">
|
||||
```bash
|
||||
cline connect
|
||||
```
|
||||
|
||||
Choose Telegram, enter the bot token, answer yes to access restriction, then enter your user ID.
|
||||
</Step>
|
||||
|
||||
<Step title="Or pass the flag manually">
|
||||
Replace `12345` with your Telegram user ID:
|
||||
|
||||
```bash
|
||||
cline connect telegram -k <BOT-TOKEN> \
|
||||
--hook-command 'jq -r ".payload.actor.participantKey" | grep -q "telegram:id:12345" && echo "{\"action\":\"allow\"}" || echo "{\"action\":\"deny\",\"message\":\"unauthorized\"}"'
|
||||
--allowed-user-id 12345
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
The `--hook-command` receives each incoming message with sender info via stdin. Your script returns `{"action": "allow"}` or `{"action": "deny", "message": "reason"}`. Without `--hook-command`, everything is auto-approved.
|
||||
Use `--hook-command` only when you need custom access logic. The hook receives each incoming message with sender info via stdin. Your script returns `{"action": "allow"}` or `{"action": "deny", "message": "reason"}`. Without `--allowed-user-id` or `--hook-command`, everything is auto-approved, so restrict Telegram bots that can reach a running Cline instance.
|
||||
|
||||
## Slack
|
||||
|
||||
|
||||
@@ -129,14 +129,14 @@ Scan profiles control where Bumblebee looks. `baseline` checks standard global t
|
||||
</Steps>
|
||||
|
||||
<Warning>
|
||||
By default, anyone who finds your bot can message it and it will run tasks on your machine. Lock it down. Message [@userinfobot](https://t.me/userinfobot) to get your Telegram user ID, then restart the connector with an access-control hook:
|
||||
By default, anyone who finds your bot can message it and it will run tasks on your machine. Lock it down before leaving the connector running. The `cline connect` wizard can guide you through Telegram user ID setup, or you can message [@userinfobot](https://t.me/userinfobot) and restart the connector with your allowed user ID:
|
||||
|
||||
```bash
|
||||
cline connect telegram -k "<BOT-TOKEN>" --cwd ~/tools/bumblebee \
|
||||
--hook-command 'jq -r ".payload.actor.participantKey" | grep -q "telegram:id:12345" && echo "{\"action\":\"allow\"}" || echo "{\"action\":\"deny\",\"message\":\"unauthorized\"}"'
|
||||
--allowed-user-id 12345
|
||||
```
|
||||
|
||||
Replace `12345` with your user ID.
|
||||
Replace `12345` with your Telegram user ID.
|
||||
</Warning>
|
||||
|
||||
## 5. Schedule the scan
|
||||
|
||||
Reference in New Issue
Block a user