Skip to main content

Sync your IM group chat to Slack.

Project description

Chatroom-Syncer

pdm-managed License

Chatroom-Syncer is a project to sync IM Chat Room to the public domain like IRC in the old days, so that the information, context and history of communication could be discoverred, learnt from and referenced by others, anyware, anytime.

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

Components and Flow

There are two processes in the system:

  • Chatroom Syncer, current code base in Python as the WeChaty Client and the bot
  • WeChaty Gateway, which leverages the Wechaty with UOS Wechat Client(also named as a puppet) to be called by the Chatroom Syncer due to WebChaty is not a native Python library, and the Wechaty Gateway is a gRPC server to manipulate and watch WeChat the puppet.

Thus, we need to start the WeChaty Gateway before the Chatroom Syncer.

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

Run

Before running, we need follow prerequisites:

  • Configure WeChat Group Names and Slack Channel Names in config.yaml, they should exist in both WeChat and Slack.
  • Configure Slack API Token in .env.

Run with Docker

Run it in background:

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

Check both containers are Up:

docker-compose ps

In case there are any Exit 0 containers, give another try of starting up:

docker-compose up -d

Scan the QR code with your WeChat App, and you are ready to go!

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

Stop it:

docker-compose down

Run from host

Run Webchaty gateway first:

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

Run Chatroom-Syncer:

python3 -m pip install chatroom-syncer
cp config-example.yaml config.yaml
export SLACK_TOKEN="xoxb-1234567890-1234567890-1234567890-1234567890"
python3 -m chatroom_syncer

Configuration

WeChat

Copy the config-example.yaml to config.yaml

cp config-example.yaml config.yaml

And fill in the following fields in the table:

Field Description
group_channel_mapping A mapping from WeChat group name to Slack channel name
enable_avatar Whether to enable generate random emoji based avatar

Contribute

Build from host

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

If dependencies are updated, run pdm sync to update the lock manifest.

pdm sync

Build from 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 wechat-room-syncer_chatroom-syncer_1 2>/dev/null | grep -v Wechaty

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chatroom-syncer-0.1.4.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chatroom_syncer-0.1.4-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file chatroom-syncer-0.1.4.tar.gz.

File metadata

  • Download URL: chatroom-syncer-0.1.4.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.3.3 CPython/3.8.10

File hashes

Hashes for chatroom-syncer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cae62d394e168ea0e40ca2efebf996a920a436fd9c453863a5ad63a8813baa40
MD5 7d525590b1334beb836d852e3ceb8452
BLAKE2b-256 e5b03e6b649e235a2051d8dd766278839446bb9cdd756995d01d710d63e08504

See more details on using hashes here.

File details

Details for the file chatroom_syncer-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for chatroom_syncer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b799c0549d00653d97f66ee68ec2942251f326e8e061a870273c5b85eb6529e9
MD5 f2c119ec02d15aa90b00249b1cef1316
BLAKE2b-256 bf127476b4a947aef7337519ba6bebc702ce1a9dcd05291792046177a0c149f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page