test.py 1005 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. from wxbot import *
  4. class MyWXBot(WXBot):
  5. def handle_msg_all(self, msg):
  6. if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:
  7. self.send_msg_by_uid(u'hi', msg['user']['id'])
  8. # self.send_img_msg_by_uid("img/1.png", msg['user']['id'])
  9. # self.send_file_msg_by_uid("img/1.png", msg['user']['id'])
  10. # def schedule(self):
  11. # self.send_msg(u'刘龙飞', u'测试')
  12. # self.send_img_msg_by_uid("temp/wxqr.png", self.get_user_id(u'刘龙飞'))
  13. # time.sleep(1)
  14. def main():
  15. logging.basicConfig(level=logging.INFO)
  16. logging.getLogger("requests").setLevel(logging.WARNING)
  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()