test.py 813 B

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