vecan.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf-8 -*-
  2. from demeter.core import *
  3. class Vecan(object):
  4. def init(self):
  5. print('''
  6. ********************************************************
  7. * vecan-robot - 神算终端机器人 *
  8. * (c) 201(c) 2019 rabin <rabin@dever.cc> *
  9. * https://github.com/shemic/vecan.git *
  10. ********************************************************
  11. 如需退出,可以按 Ctrl-4 组合键。
  12. ''')
  13. Demeter.initConfig()
  14. self.config()
  15. self.robot = Demeter.service('robot')
  16. self.robot.init(profiling=Demeter.option['profiling'], logout=Demeter.option['logout'])
  17. #self.robot.say('亲爱的,我是神算终端机器人vecan,很高兴为你服务', True, completed=lambda: self.robot.wait())
  18. #self.robot.say('亲爱的,我是神算终端机器人vecan,很高兴为你服务', True)
  19. self.robot.wait()
  20. Demeter.dog = WatchDog.init()
  21. def config(self):
  22. if 'vecan' not in Demeter.config:
  23. Demeter.config['vecan'] = {}
  24. if 'data' not in Demeter.config['vecan']:
  25. Demeter.config['vecan']['data'] = File.runtime('data')
  26. if 'temp' not in Demeter.config['vecan']:
  27. Demeter.config['vecan']['temp'] = File.runtime('temp')
  28. if 'outname' not in Demeter.config['vecan']:
  29. Demeter.config['vecan']['outname'] = 'output'
  30. self.opt()
  31. def opt(self):
  32. param = {}
  33. param['profiling'] = 'p'
  34. param['logout'] = 'l'
  35. Demeter.getopt(param)
  36. if 'profiling' not in Demeter.option:
  37. Demeter.option['profiling'] = False
  38. if 'logout' not in Demeter.option:
  39. Demeter.option['logout'] = True
  40. def run(self):
  41. self.init()
  42. signal.signal(signal.SIGINT, self.robot.sleep)
  43. #Demeter.webInit('front')
  44. if __name__ == '__main__':
  45. vecan = Vecan()
  46. vecan.run()