test.py 835 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. #
  4. from wxbot import *
  5. #MyWXBot继承WXBot类
  6. class MyWXBot(WXBot):
  7. def handle_msg_all(self, msg):
  8. if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:
  9. self.send_msg_by_uid(u'hi', msg['user']['id'])
  10. #self.send_img_msg_by_uid("img/1.png", msg['user']['id'])
  11. #self.send_file_msg_by_uid("img/1.png", msg['user']['id'])
  12. '''
  13. def schedule(self):
  14. self.send_msg(u'张三', u'测试')
  15. time.sleep(1)
  16. '''
  17. def main():
  18. bot = MyWXBot()
  19. bot.DEBUG = True
  20. bot.conf['qr'] = 'png'
  21. bot.is_big_contact = False #如果确定通讯录过大,无法获取,可以直接配置,跳过检查。假如不是过大的话,这个方法可能无法获取所有的联系人
  22. bot.run()
  23. if __name__ == '__main__':
  24. main()