将您的即时通讯群聊同步到像旧时代的IRC这样的公共领域。
项目描述
聊天室同步器
聊天室同步器是一个项目,旨在将即时通讯聊天室同步到像旧时代的IRC这样的公共领域,以便信息、上下文和通信历史可以被其他人发现、学习和参考,随时随地。
https://user-images.githubusercontent.com/1651790/207810877-b86943fa-24b3-479c-ac25-d602a6c5d53c.mp4
支持的输出
- Slack
- GitHub
- IRC
- Telegram
- Discord
组件和流程
| 组件 | Docker镜像 | 
|---|---|
| wechaty-gateway | |
| 聊天室同步器 | 
系统中有两个进程
- 聊天室同步器,当前的代码库使用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 查看哈希值)
      
    
    
       关闭
    
      
        
    
    
  
chatroom-syncer-0.1.9.tar.gz的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 1d50bb95683ac3fe9e93f13a8e1fc82e1d6b8a8ce6d27a1b93a768dcbbf1fa54 | |
| MD5 | f38ebdbb32dece353a49cf9db1485ceb | |
| BLAKE2b-256 | 5da0586c5ffb8db37cb08c2cf7044ea367847c812ce7507a763c09fe744dad72 | 
    
       关闭
    
      
        
    
    
  
chatroom_syncer-0.1.9-py3-none-any.whl的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 8c030c6da5afcb6f57f78ce07dc34fe177cc49af1b23f4ce0108a81ad551b280 | |
| MD5 | fdda805304bf0d9759ea77e118875569 | |
| BLAKE2b-256 | ca7a7569ef0d94f47dc43c2ff0c77e47145cef6dd97ef70b3c8140684760b42a |