Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
7b65f1ca7a
commit
8fec5a75e9
7 changed files with 18 additions and 9 deletions
|
|
@ -523,7 +523,7 @@ picoclaw onboard weixin
|
||||||
Scan the printed QR code with your WeChat mobile app. On success, the token is saved to your config.
|
Scan the printed QR code with your WeChat mobile app. On success, the token is saved to your config.
|
||||||
|
|
||||||
**2. Configure**
|
**2. Configure**
|
||||||
(Optional) Update `allow_from` with your WeChat User ID to restrict who can message the bot:
|
(Optional) Update `allow_from` with your WeChat User ID to restrict who can message the bot:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"channels": {
|
"channels": {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ func runWeixinOnboard(baseURL, proxy string, timeout time.Duration) error {
|
||||||
|
|
||||||
fmt.Println("✓ Config updated. Start the gateway with:")
|
fmt.Println("✓ Config updated. Start the gateway with:")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println(" picoclaw gateway start")
|
fmt.Println(" picoclaw gateway")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("To restrict which WeChat users can send messages, add their user IDs")
|
fmt.Println("To restrict which WeChat users can send messages, add their user IDs")
|
||||||
fmt.Println("to channels.weixin.allow_from in your config.")
|
fmt.Println("to channels.weixin.allow_from in your config.")
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ This command will:
|
||||||
After onboarding, you can start the gateway:
|
After onboarding, you can start the gateway:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
picoclaw gateway start
|
picoclaw gateway
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ picoclaw onboard weixin
|
||||||
配置完成后,即可启动网关:
|
配置完成后,即可启动网关:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
picoclaw gateway start
|
picoclaw gateway
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ picoclaw onboard weixin
|
||||||
Scan the printed QR code with your WeChat mobile app. On success, the token is saved to your config.
|
Scan the printed QR code with your WeChat mobile app. On success, the token is saved to your config.
|
||||||
|
|
||||||
**2. Configure**
|
**2. Configure**
|
||||||
(Optional) Update `allow_from` with your WeChat User ID to restrict who can message the bot:
|
(Optional) Update `allow_from` with your WeChat User ID to restrict who can message the bot:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"channels": {
|
"channels": {
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,19 @@ func NewApiClient(baseURL, token string, proxy string) (*ApiClient, error) {
|
||||||
if proxy != "" {
|
if proxy != "" {
|
||||||
proxyURL, err := url.Parse(proxy)
|
proxyURL, err := url.Parse(proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid proxy URL %q: %v", proxy, err)
|
return nil, fmt.Errorf("invalid proxy URL %q: %w", proxy, err)
|
||||||
}
|
}
|
||||||
client.Transport = &http.Transport{
|
|
||||||
Proxy: http.ProxyURL(proxyURL),
|
// Clone the default transport so we preserve all default settings (TLS, HTTP/2, timeouts, keep-alives)
|
||||||
|
if defaultTransport, ok := http.DefaultTransport.(*http.Transport); ok {
|
||||||
|
transport := defaultTransport.Clone()
|
||||||
|
transport.Proxy = http.ProxyURL(proxyURL)
|
||||||
|
client.Transport = transport
|
||||||
|
} else {
|
||||||
|
// Fallback: preserve previous behavior if DefaultTransport is not the expected type
|
||||||
|
client.Transport = &http.Transport{
|
||||||
|
Proxy: http.ProxyURL(proxyURL),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ func (c *WeixinChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
|
||||||
logger.ErrorCF("weixin", "Missing context token, cannot send message", map[string]any{
|
logger.ErrorCF("weixin", "Missing context token, cannot send message", map[string]any{
|
||||||
"to_user_id": toUserID,
|
"to_user_id": toUserID,
|
||||||
})
|
})
|
||||||
return fmt.Errorf("weixin send: missing context token for chat %s", toUserID)
|
return fmt.Errorf("weixin send: %w: missing context token for chat %s", channels.ErrSendFailed, toUserID)
|
||||||
}
|
}
|
||||||
clientID := "picoclaw-" + uuid.New().String()
|
clientID := "picoclaw-" + uuid.New().String()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue