Git Product home page Git Product logo

wechaty-bot's Introduction

ChatGPT Bot

新版微信机器人

旧版,不建议使用

封号严重不建议使用

一个 基于 OpenAI + Wechaty 智能回复、支持上下文回复、AI绘画的微信机器人,可以用来帮助你自动回复微信消息。

反向代理 api.openai.com

api.openai.com 国内无法访问,利用Cloudflare Workers反向代理,教程

当你的环境无法使用,不想自建,也可以用我的https://openai.1rmb.tk

准备

准备

API Key 创建成功。复制好这个Key接下来会用到。点击OK后,Key不会再完整显示。只能删了重新生成Key! 如果没账号,可以参考V2EX上这个帖子注册 地址https://www.v2ex.com/t/900126

# $wechaty-bot
# 执行下面命令,拷贝一份 .env.example 文件
cp .env.example .env
#群聊chatgpt自动回复总开关 0为关闭 1为开启
AutoReplyGroup = 1
#开启chatgpt群聊列表,群聊名称必须与微信群聊名称一致,否则无法自动回复 为空则自动回复所有群聊 ["群聊1","群聊2","群聊3"]
RoomList = [ ]
#好友chatgpt自动回复总开关 0为关闭 1为开启 
AutoReplyFriend = 1
#开启chatgpt好友列表,好友名称必须与微信好友名称一致,否则无法自动回复 为空则自动回复所有好友 ["好友1","好友2","好友3"]
FriendList = [ ]
# openai的key,需要自己去获取 ,地址:https://beta.openai.com/account/api-keys
OPENAI_API_KEY ='sk-xxxxxxxxxxxxxxxxx'
# 反代的api,为空时为默认值 https://api.openai.com
PROXY_API = ''

启动服务

使用Docker #### 1、使用Docker

下载并编辑.env配置文件

mkdir my-wechaty-bot && cd my-wechaty-bot
wget -O .env  https://raw.githubusercontent.com/x-dr/wechaty-bot/main/.env.example 
vim .env

运行

docker run -itd --name my-wechaty-bot \
            --restart=always \
           -v $PWD/.env:/app/.env  \
           gindex/wechaty-bot:latest
                    

查看日志扫码登录

docker logs my-wechaty-bot -f

自行打包docker镜像

docker build -t wechaty-bot .
docker run -it --rm --name wechaty-bot wechaty-bot

2、本地启动

本地启动
git clone https://github.com/x-dr/wechaty-bot.git
npm i
node app.js

就可以扫码登录了。

用pm2启动后台运行

npm install pm2 -g

pm2 start app.js

使用

使用
  • 智能回复
/c xxxx   #对话

/c 结束对话  #结束本轮对话

chatgpt.png chatgpt.png
  • AI绘画
/img xxx
openai.png

费用情况

openai是要付费的,价格的计算方式不是简单的按照请求次数计算,包括相应内容的文字的多少。新账号有18美元免费额度。

官方价格:https://openai.com/api/pricing

pay.png

故障排除

感谢

@wechaty

@transitive-bullshit

wechaty-bot's People

Contributors

x-dr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wechaty-bot's Issues

图片上传失败,超过1M的媒体文件

cause: Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
},
tips: '上传媒体文件失败'

本地跑出问题

node app.js
internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'wechaty' imported from /wechaty-bot/app.js
at packageResolve (internal/modules/esm/resolve.js:664:9)
at moduleResolve (internal/modules/esm/resolve.js:705:18)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:798:11)
at Loader.resolve (internal/modules/esm/loader.js:100:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:246:28)
at ModuleWrap. (internal/modules/esm/module_job.js:47:40)
at link (internal/modules/esm/module_job.js:46:36) {
code: 'ERR_MODULE_NOT_FOUND'
}

error

[email protected] start
node app.js

undefined:1
undefined
^

SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at file:///app/listeners/on-message.js:9:23
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)

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.