test.py 798 B

123456789101112131415161718192021222324252627282930
  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("img/1.png", self.get_user_id(u"测试群"))
  13. self.send_file_msg_by_uid("img/1.png", self.get_user_id(u"测试群"))
  14. time.sleep(5)
  15. def main():
  16. bot = MyWXBot()
  17. bot.DEBUG = True
  18. bot.SCHEDULE_INTV = 20
  19. bot.conf['qr'] = 'png'
  20. bot.run()
  21. if __name__ == '__main__':
  22. main()