Skip to content

Instantly share code, notes, and snippets.

@cocoakekeyu
Created January 4, 2018 03:30
Show Gist options
  • Select an option

  • Save cocoakekeyu/42a86b3f55889e3b07af1dfa5d25cfb2 to your computer and use it in GitHub Desktop.

Select an option

Save cocoakekeyu/42a86b3f55889e3b07af1dfa5d25cfb2 to your computer and use it in GitHub Desktop.
外卖红包转发
# -*- 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment