Convert Figma logo to code with AI

AutumnWhj logoChatGPT-wechat-bot

ChatGPT for wechat https://github.com/AutumnWhj/ChatGPT-wechat-bot

4,661
982
4,661
107

Top Related Projects

🤖一个基于 WeChaty 结合 OpenAi ChatGPT / Kimi / 讯飞等Ai服务实现的微信机器人 ,可以用来帮助你自动回复微信消息,或者管理微信群/好友,检测僵尸粉等...

Use ChatGPT On Wechat via wechaty

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT4.0/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。

Quick Overview

ChatGPT-wechat-bot is a project that integrates ChatGPT with WeChat, allowing users to interact with ChatGPT through their WeChat accounts. It provides a bridge between the popular messaging platform and OpenAI's language model, enabling automated responses and conversations within WeChat.

Pros

  • Seamless integration of ChatGPT with WeChat, a widely used messaging platform
  • Supports multiple ChatGPT API providers, including OpenAI and Azure
  • Customizable conversation settings and user management
  • Easy deployment using Docker

Cons

  • Limited documentation, which may make setup and customization challenging for some users
  • Potential issues with WeChat's anti-bot measures, requiring careful configuration
  • Relies on third-party libraries that may need regular updates for compatibility
  • May require additional costs for API usage depending on the chosen provider

Code Examples

  1. Setting up the ChatGPT configuration:
chatgpt_config = {
    "api_key": "your-api-key",
    "model": "gpt-3.5-turbo",
    "temperature": 0.7,
    "max_tokens": 1000,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0,
}
  1. Initializing the WeChat bot:
from wechat_bot import WeChatBot

bot = WeChatBot(chatgpt_config)
bot.run()
  1. Customizing response handling:
@bot.handler
def on_message(message):
    if message.type == 'text':
        response = bot.get_chatgpt_response(message.content)
        message.reply(response)

Getting Started

  1. Clone the repository:

    git clone https://github.com/AutumnWhj/ChatGPT-wechat-bot.git
    cd ChatGPT-wechat-bot
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Configure the bot:

    • Copy config.yaml.example to config.yaml
    • Edit config.yaml with your API keys and settings
  4. Run the bot:

    python main.py
    
  5. Scan the QR code with your WeChat account to log in.

Competitor Comparisons

🤖一个基于 WeChaty 结合 OpenAi ChatGPT / Kimi / 讯飞等Ai服务实现的微信机器人 ,可以用来帮助你自动回复微信消息,或者管理微信群/好友,检测僵尸粉等...

Pros of wechat-bot

  • More comprehensive documentation, including detailed setup instructions and usage examples
  • Supports multiple AI models (ChatGPT, Claude, Stable Diffusion) for diverse functionality
  • Includes features like image generation and voice message processing

Cons of wechat-bot

  • More complex setup process due to additional dependencies and configurations
  • Potentially higher resource usage due to multiple AI model integrations
  • Less focused on a single use case (ChatGPT integration) compared to ChatGPT-wechat-bot

Code Comparison

ChatGPT-wechat-bot:

const { WechatyBuilder } = require('wechaty');
const qrcodeTerminal = require('qrcode-terminal');
const ChatGPTBot = require('./bot');

wechat-bot:

import { WechatyBuilder } from 'wechaty';
import { FileBox } from 'file-box';
import { ChatGPTBot } from './bot.js';
import { config } from './config.js';

Both projects use Wechaty for WeChat integration, but wechat-bot imports additional modules for enhanced functionality. ChatGPT-wechat-bot uses CommonJS module syntax, while wechat-bot uses ES6 import statements.

Use ChatGPT On Wechat via wechaty

Pros of wechat-chatgpt

  • More active development with frequent updates and contributions
  • Supports multiple AI models including ChatGPT, GPT-3.5-turbo, and Claude
  • Offers Docker support for easier deployment

Cons of wechat-chatgpt

  • More complex setup process with additional dependencies
  • Lacks some features like customizable welcome messages and multi-user support
  • May have higher resource requirements due to additional functionalities

Code Comparison

ChatGPT-wechat-bot:

const { WechatyBuilder } = require('wechaty');
const qrcodeTerminal = require('qrcode-terminal');
const ChatGPTBot = require('./bot');

const bot = new ChatGPTBot();

wechat-chatgpt:

import { WechatyBuilder } from 'wechaty';
import { ChatGPTBot } from './chatgpt';
import { Config } from './config';

const chatGPTBot = new ChatGPTBot();

Both projects use Wechaty for WeChat integration, but wechat-chatgpt employs TypeScript and has a more modular structure. ChatGPT-wechat-bot uses JavaScript and has a simpler implementation.

While ChatGPT-wechat-bot focuses solely on ChatGPT integration, wechat-chatgpt offers more flexibility with multiple AI model support. However, this comes at the cost of increased complexity in setup and configuration.

ChatGPT-wechat-bot may be more suitable for users seeking a straightforward ChatGPT integration, while wechat-chatgpt caters to those requiring advanced features and multiple AI model options.

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT4.0/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。

Pros of chatgpt-on-wechat

  • More comprehensive documentation, including detailed setup instructions and configuration options
  • Supports multiple AI platforms (OpenAI, Azure, Claude) and chat modes (e.g., continuous dialogue, image generation)
  • Active development with frequent updates and a larger community (3.7k+ stars)

Cons of chatgpt-on-wechat

  • More complex setup process due to additional features and dependencies
  • Potentially higher resource usage and slower response times in some scenarios
  • Steeper learning curve for users unfamiliar with Python and AI integrations

Code Comparison

ChatGPT-wechat-bot (main.py):

@itchat.msg_register(itchat.content.TEXT)
def reply_text(msg):
    message = msg['Text']
    response = chatgpt.get_chat_response(message)
    return response

chatgpt-on-wechat (channel/wechat/wechat_channel.py):

def handle_text(self, msg):
    context = Context(channel_type=ChannelType.WECHAT)
    context.message = msg.content
    context.ctype = ContextType.TEXT
    reply = super().build_reply_content(context)
    return reply

The chatgpt-on-wechat code demonstrates a more modular approach with better separation of concerns, while ChatGPT-wechat-bot offers a simpler implementation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ChatGPT-wechat-bot🤖

Version License: ISC

几步即可获得一个基于 ChatGPT 的微信机器人 🤖。 English | 中文文档

Support

  • 支持上下文语境的对话。
  • 支持重置上下文语境,通过关键词(reset)重置对话上下文语境。
  • 支持在群聊@你的机器人 🤖,@机器人即可收到回复。
  • 支持通过关键词唤醒你的机器人,如当在群组中发送“@机器人 hello xxxx”时才会收到回复。
  • 其他

合作

默认配置

{
  // 填入你的OPENAI_API_KEY
  OPENAI_API_KEY: "",
  // 反向代理地址,简单说就是你的在国外服务器地址,如何获取看README
  reverseProxyUrl: "",
  // 在群组中设置唤醒微信机器人的关键词
  groupKey: "",
  // 在私聊中设置唤醒微信机器人的关键词
  privateKey: "",
  // 重置上下文的关键词,如可设置为reset
  resetKey: "reset",
  // 是否在群聊中带上提问的问题
  groupReplyMode: true,
  // 是否在私聊中带上提问的问题
  privateReplyMode: false,
}

开始设置机器人 🤖

  1. 首先,需要按照以下步骤获你的 ChatGPT 的 OPENAI_API_KEY.

获取你的 OPENAI_API_KEY:

image.png image.png

  1. 把 OPENAI_API_KEY 填入目录src/config.ts下的 OPENAI_API_KEY 中

  2. 把 reverseProxyUrl 填入目录src/config.ts下的 reverseProxyUrl 中,如何设置可看下面介绍。

当然也可以选择白嫖山月老师的代理地址:https://ai.devtool.tech/proxy/v1/chat/completions,可以关注他的项目

  1. 然后在终端运行以下命令。如有需要,请在src/config.ts中配置其它配置变量。
  // 安装依赖
  npm i
  npm run dev

  // 也可以使用pnpm
  npm i -g pnpm
  pnpm i
  pnpm run dev

  1. 执行完之后,可以看到终端控制台输出一下信息,扫码登录即可. image.png

  2. 登录成功,用另外一个微信往你扫码登录的微信发消息,你将会收到来自 ChatGPT 的回复。 image.pngimage.png

设置反向代理地址

ChatGPT API 代理https://hub.docker.com/r/mirrors2/chatgpt-api-proxy

chatgpt api 代理,已验证 OpenCat,AssisChat,AMA(问天),chathub

可配置好 OPENAI_API_KEY 分享代理地址给他人用.

快速开始

docker run -d -p 80:80 --name chatgpt-api-proxy mirrors2/chatgpt-api-proxy

# 可选 -e OPENAI_API_KEY={nide_api_key}

docker 跑起来之后你的代理地址就生效了:

官方的:https://api.openai.com/v1/chat/completions

你的: 你的域名/v1/chat/completions 或者 你的服务器ip和端口/v1/chat/completions

QA

  1. 微信无法取消登录问题 可以直接删除WechatEveryDay.memory-card文件,重新跑程序

  2. 支持的 node 版本: Node.js >= 16.8

  3. 因为 ChatGPT 的长度限制,如果回复消息不完整,可以对它说"请继续" 或者 "请继续写完"。

image
  1. Error: Failed to launch the browser process puppeteer refer to https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
# ubuntu
sudo apt-get install chromium-browser
sudo apt-get install  ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils

👏🏻 欢迎一起共建

欢迎贡献你的代码以及想法 🍵。