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 + - ~discord id:tag_parser disconnect - flag server tag_parser_bot_running:! start_bot: - - inject locally script_paths.stop_bot + - inject tag_parser_bot.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: + - yaml unload id:tag_parser_temp - define samples ].with[version].as[].with[denizen_version].as[]> - flag server tag_parser_samples:<[samples]> - - discord id:tag_parser connect code: + - ~discordconnect id:tag_parser tokenfile:data/tagparser_token.txt - - 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 + # If you ever enable this on your own copy of the bot I will break your knees. Don't do it. Official dTagParser instance only. + - define should_record false + - ~run tag_run_task def:].include[<[should_record]>]> + - define result ]> - flag server tag_parser_result_temp:! - - flag server tag_parser_record_temp:! + - log " [<[name]>] in [<[origin]>] got result <[result]>" file: - - 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[;]>" + - if <[result].contains[valid]>: + - define final_result <[result].get[valid]> + - if <[result].contains[failed]>: + - foreach <[result].get[failed]>: + - if <[value].starts_with[Error=]>: + - define final_result "<[final_result]>Had error: <[value].after[Error=]>" + - else if <[value].starts_with[Exception=]>: + - define final_result "<[final_result]>Had internal exception: <[value].after[Exception=]>" - 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 + - inject tag_parser_bot.script_paths.start_bot on script generates error: - - flag server tag_parser_result_temp:FAILED=ERROR/; + - flag server tag_parser_result_temp.failed:|:Error= on server generates exception: - - flag server tag_parser_result_temp:FAILED=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 /// - - 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! ]>" + - ~discordmessage id:tag_parser 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 <<><>>" + - if == link: + - ~discordmessage id:tag_parser 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[']>```" + - define tag ].with[<&sp>].trim> + - inject tag_parser_bot.script_paths.process_tag player: npc: + - inject tag_parser_bot.script_paths.crunch_result + - ~discordmessage id:tag_parser channel: "Tag parse results for `<[tag].replace_text[`].with[']>`<&co> <[result].get[recording].if_null[]>```<[final_result].replace_text[`].with[']>```" - flag server tag_parser_bot_processing_now:! tag_run_task: type: task - definitions: tag + definitions: tag|record 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]>; + - define help "Tell me any valid Denizen 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].contains_text[<<>]> && <[<[tag]>].exists>: + - flag server tag_parser_result_temp.valid:<[<[tag]>]> - else: - # don't uncomment these or i'll punch you - #- debug record start + #- if <[record]>: + # - 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]> + #- if <[record]>: + # - ~debug record submit save:recorded + # - if !: + # - define record_url "(Submit Failed)" + # - else: + # - define record_url <<><>> + # - flag server tag_parser_result_temp.recording:<[record_url]> + - flag server tag_parser_result_temp.valid:<[result]> tag_parser_task: type: task definitions: tag script: - - define result <[tag].unescaped.parsed.escaped.replace_text[;].with[&sc]> + - define result <[tag].parsed> + +