tag_parser_bot: type: world debug: false samples: link: (UNSET) sample_bool: true sample_0: 0 sample_1: 1 sample_10: 10 sample_0p5: 0.5 sample_text: Hello, world! help: try typing 'help' to the bot! script_paths: stop_bot: - if : - discord id:tag_parser disconnect - flag server tag_parser_bot_running:! start_bot: - inject locally script_paths.stop_bot - yaml load:data/tag_parser.yml id:tag_parser_temp - if !: - debug error "Load failed." - stop - flag server tag_parser_logpath: - flag server tag_parser_validchannels:! - flag server tag_parser_validchannels:|: - flag server tag_parser_barredchannels:! - flag server tag_parser_barredchannels:|: - flag server tag_parser_barredchannelmessages:! - flag server tag_parser_barredchannelmessages:|: - flag server tag_parser_link: - define samples ].with[version].as[].with[denizen_version].as[]> - flag server tag_parser_samples:<[samples]> - discord id:tag_parser connect code: - yaml unload id:tag_parser_temp - flag server tag_parser_bot_running process_tag: - log " [<[name]>] in [<[origin]>] wants to process tag <[tag]>" file: - flag server tag_parser_result_temp:! - ~run tag_run_task def:<[tag]> - define result - define recorded - flag server tag_parser_result_temp:! - flag server tag_parser_record_temp:! - log " [<[name]>] in [<[origin]>] recorded to <[recorded]> got result <[result]>" file: crunch_result: - define final_result - foreach <[result].split[;]>: - if <[value].starts_with[VALID=]>: - define final_result <[final_result]><[value].after[VALID=].replace_text[&sc].with[;]> - foreach <[result].split[;]>: - if <[value].starts_with[FAILED=ERROR/]>: - define final_result "<[final_result]>Had error: <[value].after[FAILED=ERROR/].replace_text[&sc].with[;]>" - else if <[value].starts_with[FAILED=EXCEPTION/]>: - define final_result "<[final_result]>Had internal exception: <[value].after[FAILED=EXCEPTION/].replace_text[&sc].with[;]>" - else if <[value].starts_with[FAILED=]>: - define fail_reason <[value].after[FAILED=]> - if <[fail_reason]> == FLAG_MISSING: - define final_result "<[final_result]>Got no result value." - else: - define final_result "<[final_result]>Got failure '<[fail_reason]>'." - if <[final_result].trim.length> == 0: - define final_result - if <[final_result].length> > 1000 || <[tag].length.add[<[final_result].length>]> > 1500: - define tag (Spam) - define final_result "Input too long, refused." - if <[final_result].to_list.filter[is[==].to[]].size> > 10: - define final_result "Newline spam, refused." events: on server start: - wait 5s - flag server tag_parser_bot_running:! - inject locally script_paths.start_bot on script generates error: - flag server tag_parser_result_temp:FAILED=ERROR/; on server generates exception: - flag server tag_parser_result_temp:FAILED=EXCEPTION/-; on discord message received for:tag_parser: - flag server tag_parser_bot_running - if : - yaml unload id:tag_parser_temp - define name / - define origin /// - announce to_console "Discord chatter! [<[name]>] in [<[origin]>] saying and mentioning " - if !]>: - stop - if !]>: - define found ]> - if <[found]> > 0: - discord id:tag_parser message channel: "Cannot parse that in this channel! ]>" - stop - if == link: - discord id:tag_parser message channel: "The source script for **dTagParser** can be found at <<><>>" - stop - waituntil rate:1s ! - flag server tag_parser_bot_processing_now duration:1m - define tag ].with[<&sp>].trim.escaped> - inject locally script_paths.process_tag player: npc: - inject locally script_paths.crunch_result - discord id:tag_parser message channel: "Tag parse results for `<[tag].unescaped.replace_text[`].with[']>`<&co> <[recorded]>```<[final_result].unescaped.replace_text[`].with[']>```" - flag server tag_parser_bot_processing_now:! tag_run_task: type: task definitions: tag debug: false script: - define samples ].with[sample_npc].as[]> - foreach <[samples].keys> as:key: - define <[key]> <[samples].get[<[key]>]> - define help "Tell me any valid Denizen (Bukkit) tags, like <<>player.name<>> and I'll parse them for you! Alternately, tell me a valid definition name (like 'samples') and I'll tell you its contents." - if !<[tag].unescaped.contains_text[<<>]> && <[<[tag].unescaped>]||null> != null: - flag server tag_parser_result_temp:VALID=<[<[tag].unescaped>].escaped.replace_text[;].with[&sc]>; - else: # don't uncomment these or i'll punch you #- debug record start - inject tag_parser_task #- ~debug record submit save:recorded #- define record_url - flag server tag_parser_result_temp:VALID=<[result]>; #- if <[record_url]> == null: # - define record_url "(Submit Failed)" #- else: # - define record_url <<><[record_url]><>> #- flag server tag_parser_record_temp:<[record_url]> tag_parser_task: type: task definitions: tag script: - define result <[tag].unescaped.parsed.escaped.replace_text[;].with[&sc]>