微信个人订阅号连接ChatGPT

需要使用到的GitHub仓库:

  1. clash-for-linux
  2. bot-on-anything

应用运行在腾讯云服务器上,使用的操作系统是OpenCloudOS(兼容CentOS 8)

在Linux服务器上启动代理

  1. 基本安装步骤参考clash-for-linux项目的使用说明
  2. 编辑.env文件时,CLASH_URL的值应为自己Clash订阅链接的地址
查看Clash日志

查看Clash错误日志

  1. 如果启动后出现unsupported rule type RULE-SET错误,可以参考如下issue:
  1. 进入Clash Dashboard,配置不同选择的节点
进入Clash Dashboard

Clash Dashboard界面

部署bot-on-anything程序

注意:下面仅以个人订阅号的使用为例

  1. 基本安装步骤参考bot-on-anything项目的使用说明
  2. 以下是关于在个人订阅号启用服务器配置的一些说明
  • 服务器地址(URL)格式为http://<IP>:<port>/wx, 由于服务器地址(URL)只能配置80/443端口,但我们启动的python程序默认监听8088端口,因此需要通过nginx做转发
nginx配置如下
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;


# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }
}
server {
  listen    80 default_server;
  listen    [::]:80 default_server;
  server_name  <xxx.xxx.xxx.xxx>; # 填写自己主机的IP地址 

  location /wx {
    proxy_pass  http://127.0.0.1:8088;
    proxy_read_timeout  300;
    proxy_connect_timeout   300;
    proxy_redirect  off;

    proxy_set_header    X-Forwarded-Proto $scheme;
    proxy_set_header    Host          $http_host;
    proxy_set_header    X-Real-IP     $remote_addr;
  }

  error_page 404 /404.html;
  location = /40x.html {
  }

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
  }
}
  • 令牌(Token)为自己手动输入,并满足格式要求即可
  • EncodingAESKey点击随机生成即可
  • 消息加解密方式处于简单的考虑选择明文模式即可,如有需要可以自行根据需求修改
  1. 将应用程序挂到后台运行 进入项目目录执行如下命令
# 通过nohup命令将python应用程序挂到后台运行
# 并将输出的日志重定向到当前用户目录下的bot.log文件中
# 关于 2>&1 的说明: 
# 将标准错误 2 重定向到标准输出 &1 ,标准输出 &1 再被重定向输入到 bot.log 文件中
# 0 – stdin (standard input,标准输入)
# 1 – stdout (standard output,标准输出)
# 2 – stderr (standard error,标准错误输出)
nohup python3 app.py > ~/bot.log 2>&1 &