Code Monkey home page Code Monkey logo

wechatrobot-go's Introduction

weChatRobot

一个基于微信公众号的智能聊天机器人项目,支持图灵机器人(V2)和ChatGPT对话模式回复内容

本项目还有Java实现的版本:https://github.com/MartinDai/weChatRobot

qrcode

项目介绍

本项目是一个微信公众号项目,需配合微信公众号使用,在微信公众号配置本项目运行的服务器域名,用户关注公众号后,向公众号发送任意信息,公众号会根据用户发送的内容自动回复。

涉及框架及技术

支持的功能

  • 自定义关键字回复内容
  • 调用ChatGPT接口回复内容(需配置环境变量:OPENAI_API_KEY
  • 调用图灵机器人(V2)接口回复内容(需配置环境变量:TULING_API_KEY

使用说明

  1. 使用之前需要有微信公众号的帐号,没有的请戳微信公众号申请
  2. 如果需要使用图灵机器人的回复内容则需要注册图灵机器人帐号获取相应的ApiKey并配置在环境变量中
  3. 如果需要使用ChatGPT的回复内容则需要创建OpenAI的API Key并配置在环境变量中
  4. 可以通过配置环境变量OPENAI_BASE_DOMAIN更换访问OpenAI的域名
  5. 可以通过配置环境变量OPENAI_PROXY使用代理服务访问OpenAI
  6. 内容响应来源的优先级自定义关键 > ChatGPT > 图灵机器人
  7. 在微信公众号后台配置回调URL为https://wechatrobot.doodl6.com/weChat/receiveMessage,其中wechatrobot.doodl6.com是你自己的域名,token与config.yml里面配置的保持一致即可

本地开发

GoLand

需要配置Program Arguments为-config ./config.yml,然后运行main.go

VS Code

可以直接使用launch.json的配置,里面还包含了环境变量的配置直接设置即可

编译运行

直接构建

go build -o weChatRobot main.go

构建完成在项目根目录会生成名为weChatRobot的文件

执行启动

./weChatRobot -config ./config.yml

通过Makefile构建

构建适合当前系统的可执行文件

make

构建指定平台架构的可执行文件

make linux_amd64

编译全平台的可执行文件

make all

生成的可执行文件在bin目录下

Docker运行

构建适用于当前操作系统架构的镜像

docker build --no-cache -t wechatrobot-go:latest .

构建指定架构的镜像

docker buildx build -f docker/Dockerfile --no-cache -t wechatrobot-go:latest --platform=linux/amd64 -o type=docker .

后台启动镜像

docker run --name wechatrobot-go -p 8080:8080 -d wechatrobot-go:latest

wechatrobot-go's People

Contributors

martindai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.