# -*- coding: utf-8 -*- import time import re import logging import wxpy logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') TEXT_RE = re.compile(r'^[^第]+第(\d)个领取.+$') def start(): bot = wxpy.Bot(cache_path=True, qr_path='qr_code.jpg', console_qr=True) hahaha = bot.friends().search('L')[0] def forward_packet(msg, receiver=hahaha): text = msg.text match = TEXT_RE.match(text) if match: logging.info('Catch a bonus sharing') num = int(match.groups()[0]) if num <= 5: msg.forward(receiver, prefix='From %s:' % msg.sender.name) logging.info('Forward a bonus') bot.register(wxpy.Group, 'Sharing')(forward_packet) logging.info('Starting bot') time.sleep(365*24*60*60) if __name__ == '__main__': start()