跳转到主要内容

将您的即时通讯群聊同步到像旧时代的IRC这样的公共领域。

项目描述

聊天室同步器

pdm-managed License PyPI GitHub stars Code size Actions Status Code style: black

聊天室同步器是一个项目,旨在将即时通讯聊天室同步到像旧时代的IRC这样的公共领域,以便信息、上下文和通信历史可以被其他人发现、学习和参考,随时随地。

https://user-images.githubusercontent.com/1651790/207810877-b86943fa-24b3-479c-ac25-d602a6c5d53c.mp4

支持的输出

  • Slack
  • GitHub
  • IRC
  • Telegram
  • Discord

组件和流程

组件 Docker镜像
wechaty-gateway Docker Image docker:wechaty-gateway
聊天室同步器 Docker Image docker:chatroom-syncer

系统中有两个进程

  • 聊天室同步器,当前的代码库使用Python作为WeChaty客户端和机器人
  • WeChaty Gateway,它利用UOS WeChat客户端(也称为puppet)被聊天室同步器调用,因为WebChaty不是一个本地的Python库,而WeChaty Gateway是一个gRPC服务器,用于操作和监控WeChat puppet。

因此,我们需要在聊天室同步器启动之前启动WeChaty Gateway。

┌────────────────────────────┐          ┌────────┐
│                            │          │        │
│ Chatroom Syncer            │          │        │
│                            │          │ GitHub │
│ WebChaty.onMessage()       ├──────────▶ Slack  │
│                            │          │        │
└──────────────▲─────────────┘          │        │
               │                        └────────┘
             gRPC
               │
┌──────────────▼──────────────┐
│                             │
│  Wechaty Gateway            │
│                             │
│┌────────────────────────┐   │
││ Wechaty UOS puppet     │   │
│└────────────────────────┘   │
└─────────────────────────────┘

运行

在运行之前,我们需要遵循以下先决条件

  • config.yaml中配置微信群聊名称和Slack频道名称,它们应在微信和Slack中都存在。
  • .env中配置Slack API令牌。

使用Docker运行

在后台运行

cp config-example.yaml config.yaml
cp env-example .env
docker-compose up -d

检查两个容器都处于运行状态

docker-compose ps

如果存在任何Exit 0容器,请尝试重新启动

docker-compose up -d

使用微信App扫描二维码,您就可以开始使用了!

docker logs chatroom-syncer_chatroom-syncer_1 2>/dev/null | grep -v Wechaty

停止它

docker-compose down

从主机运行

首先运行Webchaty网关

export token="iwonttellyou"
docker run -d \
    --name=wechaty-gateway \
    --net=bridge \
    -p 9009:9009 \
    -e WECHATY_PUPPET_SERVICE_TOKEN="$token" \
    -v /wechaty_data:/wechaty/data \
    --restart=unless-stopped weygu/wechaty-gateway:latest

运行Chatroom-Syncer

# install it
python3 -m pip install chatroom-syncer
# create config.yaml and change it
cp config-example.yaml config.yaml

# put tokens for sink according to your config.yaml
# i.e. if both slack and github discussion sinks were enabled
# we need token to send message to slack and github discussion
# as follow:
export SLACK_BOT_TOKEN="xoxb-1234567890-1234567890-1234567890-1234567890"
export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxx

# run it
python3 -m chatroom_syncer

配置

微信

将config-example.yaml复制到config.yaml

cp config-example.yaml config.yaml

并在表格中填写以下字段

字段 描述
enable_slack Slack汇出开关
group_channel_mapping 将微信群名映射到Slack频道名
enable_avatar 切换为生成基于emoji的Slack汇出头像
enable_github_discussion GitHub讨论汇出开关
group_github_discussion_mapping 将微信群名映射到讨论:owner/repo/category

贡献

从主机构建

git clone https://github.com/wey-gu/chatroom-syncer && cd chatroom-syncer
# install pdm
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
# install chatroom-syncer
pdm install

如果依赖项已更新,运行pdm sync以更新锁清单。

pdm sync

从Docker构建

docker-compose -f docker-compose.dev.yaml build
docker-compose -f docker-compose.dev.yaml up -d

# get QR code to scan
docker logs chatroom-syncer_chatroom-syncer_1 2>/dev/null | grep -v Wechaty

# watch logs of the chatroom syncer
docker logs chatroom-syncer_chatroom-syncer_1 --follow

# stop the chatroom syncer and remove the container
docker-compose -f docker-compose.dev.yaml down

代码风格检查

# install pre-commit
pip install pre-commit

# run pre-commit
pre-commit run --all-files

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解更多关于安装包的信息。

源代码分发

chatroom-syncer-0.1.9.tar.gz (19.0 kB 查看哈希值)

上传时间 源代码

构建分发

chatroom_syncer-0.1.9-py3-none-any.whl (19.0 kB 查看哈希值)

上传时间 Python 3

支持者