How to Build a Multi‑Group Live‑Streaming WeChat Bot with Python

This article explains how to create a Python‑based WeChat robot that forwards messages from a main lecture group to up to 24 large groups in real time, covering background, design, configuration, core code, testing steps, encountered issues, and practical deployment tips.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Build a Multi‑Group Live‑Streaming WeChat Bot with Python

Background

In July 2019, WeChat Web introduced a dynamic security policy that blocked many accounts from logging in, but some older accounts still work. The author previously wrote four articles on WeChat bots and now presents the fifth part: synchronizing text and image live streams across multiple groups.

Feature Design

The solution uses a two‑level forwarding mechanism:

Create a main lecture group.

Add three bots and the lecturer to that group.

When the lecturer sends a message, the bots automatically forward it to all target groups.

After forwarding, the bots reply in the lecture group to indicate completion.

The lecturer continues speaking.

Key elements are the lecture group, lecturer, forwarding groups, bots, and bot administrators.

Implementation

1. Load Live Information

Configuration data (lecture group name, lecturer name, forwarding groups) is stored in a file. When the bot starts, it loads this configuration, verifies the lecture group and lecturer, and retrieves the list of forwarding groups.

def load_live(bot):
    """Load groups needed for live streaming"""
    bot.is_live_mode = config.is_live_mode
    if not bot.is_live_mode:
        return '
Live mode not enabled. Set is_live_mode=True in config.py.'
    live_status_detail = ''
    # Load lecture group
    live_group = bot.groups().search(config.live_group)
    if len(live_group) < 1:
        bot.live_group = None
        bot.is_live_mode = False
        return f'
Lecture group not found: {config.live_group}
Live mode failed.'
    elif len(live_group) > 1:
        bot.live_group = live_group[0]
        live_status_detail += f'
Multiple groups matched "{config.live_group}"; using first.'
    else:
        bot.live_group = live_group[0]
    # Load lecturer
    for member in bot.live_group.members:
        if member.name == config.live_speaker:
            bot.live_speaker = config.live_speaker
            live_status_detail += f'
Lecturer: {config.live_speaker}'
            break
    else:
        live_status_detail += f'
Lecturer "{config.live_speaker}" not found.'
        bot.is_live_mode = False
        return live_status_detail
    # Load forwarding groups
    forward_groups = search_groups(bot, config.forward_groups)
    bot.forward_groups = forward_groups
    live_status_detail += f'
Forward groups: {forward_groups} (total {len(forward_groups)})'
    return live_status_detail

2. Forward Messages

When a message arrives in the lecture group, the bot checks three conditions: live mode is on, the message comes from the lecture group, and the sender is the lecturer. If all are true, the message is forwarded to each target group with a short random pause to avoid rate limits.

def remote_forward(msg):
    """Forward a message to all target groups"""
    forward_groups = []
    for group in msg.bot.forward_groups:
        msg.forward(group, suffix='')
        forward_groups.append(group.name)
        time.sleep(random.random())
    return forward_groups

Testing

The testing workflow creates one lecture group and 24 test groups, adds the bots, starts live mode, and simulates a real lecture while monitoring message delivery. The author also experimented with using a single bot for 24 groups (which hit rate‑limit errors) and three bots each handling eight groups, which proved reliable.

Issues Encountered

Maximum number of forwarding groups per bot (WeTools limits to 9); using three bots solves this.

Message‑frequency limits; random short sleeps mitigate the problem.

Sometimes groups are not loaded; sending any message in the group and re‑enabling live mode resolves it.

Occasional bot disconnections during live sessions; re‑login fixes the issue.

Some accounts cannot log into WeChat Web due to the 2019 security policy.

Conclusion

Although the project is small, it demonstrates problem‑solving skills and showcases how a simple Python bot can enable large‑scale synchronized live streaming across dozens of WeChat groups, turning a repetitive manual task into an automated, scalable solution.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Pythonlive streamingWeChat botwxpymulti-group forwarding
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.