def main(debug_mode=False): try: if not os.path.exists("pybot.yaml"): shutil.copyfile('pybot.template.yaml', 'pybot.yaml') print( "pybot.yaml config file not found. Its template was created but you probably want to edit it before next run." ) sys.exit(0) except Exception as e: print(f'Cannot create config file: {e}') sys.exit(1) try: config = yaml.load(open("pybot.yaml"), Loader=yaml.Loader) except Exception as e: print(f'Cannot read config file: {e}') sys.exit(6) try: utils.ensure_config_is_ok(config, assert_unknown_keys=True) except utils.config_error as e: print(f'Invalid config file: {e}') sys.exit(3) configure_logger(config) bot = pybot(config, debug_mode) try: bot.start() except KeyboardInterrupt: bot.die('Interrupted by owner') try: sys.exit(0) except SystemExit: os._exit(0)
def do_hello(): input_text = request.forms['input_text'] input_image = request.files.input_image output_text = pybot(input_text, input_image) return template('pybot_template', input_text=input_text, output_text=output_text)
def do_hello(): #値を取り出す input_text = request.forms.input_text #pybot()を実行 output_text = pybot(input_text) #値を渡す return template('pybot_template', input_text=input_text, output_text=output_text)
def main(): try: config = yaml.load(open("pybot.yaml"), Loader=yaml.Loader) except Exception as e: print(f'Cannot read config file: {e}') sys.exit(6) try: utils.ensure_config_is_ok(config, assert_unknown_keys=True) except utils.config_error as e: print(f'Invalid config file: {e}') sys.exit(3) configure_logger(config) bot = pybot(config) bot.start()
def main(): configure_logger() logger = logging.getLogger(__name__) if len(sys.argv) != 4: logger.critical('not enough args given (%s)' % (len(sys.argv) - 1)) print("Usage: pybot <server[:port]> <channel> <nickname[:password]>") sys.exit(1) s = sys.argv[1].split(":", 1) server = s[0] if len(s) == 2: try: port = int(s[1]) except ValueError: print("Error: Erroneous port.") logger.critical('erroneous port given') sys.exit(1) else: port = 6667 channel = sys.argv[2] if sys.argv[2].startswith('#') else '#' + sys.argv[2] n = sys.argv[3].split(':') nickname = n[0] password = n[1] if len(n) > 1 else '' logger.debug('channel: %s' % server) logger.debug('port: %d' % port) logger.debug('server: %s' % channel) logger.debug('nickname: %s' % nickname) logger.debug('password: %s' % ''.join(['*' for _ in range(0, len(password))])) bot = pybot(channel, nickname, server, port, password) bot.start()
def do_hello(): input_text = request.forms.input_text output_text = pybot(input_text) return template('pybot_template', input_text=input_text, output_text=output_text)
def do_hello(): input_text = request.forms.input_text output_text = pybot(input_text) return template("index.html", input_text=input_text, output_text=output_text)