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! events: after server start: - wait 5s - flag server tag_parser_bot_running:! - inject tag_parser_start_bot_task on script generates error: - flag server tag_parser_result_temp.failed:|:Error= on server generates exception: - flag server tag_parser_result_temp.failed:|:Exception=- after discord message received for:tag_parser: - flag server tag_parser_bot_running - if !]>: - stop # Ensure it's an actual '@' not just a reply - if !@<>>]> && !@!<>>]>: - stop - definemap args: author: channel: to_parse: reply_to: handle_output: tag_parser_message_reply_task - run tag_parse_core_task defmap:<[args]> on discord slash command name:parsetag: - ~discordinteraction defer interaction: - definemap args: author: channel: to_parse: ]> reply_to: handle_output: tag_parser_interaction_reply_task handle_fail: tag_parser_interaction_fail_task - run tag_parse_core_task defmap:<[args]> tag_parser_stop_bot_task: type: task debug: false script: - if : - ~discord id:tag_parser disconnect - flag server tag_parser_bot_running:! tag_parser_start_bot_task: type: task debug: false script: - inject tag_parser_stop_bot_task - 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]> - ~discordconnect id:tag_parser tokenfile:data/tagparser_token.txt - flag server tag_parser_bot_running tag_parse_core_task: type: task debug: false definitions: author|channel|to_parse|reply_to|handle_output|handle_fail script: - define name <[author].id>/<[author].name> - define origin <[channel].group>/<[channel]>/<[channel].group.name>/<[channel].name> - if !]>: - define found ]> - if <[found]> > 0: - ~run <[handle_output]> def.reply_to:<[reply_to]> "Cannot parse that in this channel! ]>" - else: - if <[handle_fail].exists>: - run <[handle_fail]> def.reply_to:<[reply_to]> - stop - if <[to_parse].trim> == link: - ~run <[handle_output]> def.reply_to:<[reply_to]> "def.message:The source script for **dTagParser** can be found at <<><>>" - stop - waituntil rate:1s ! - flag server tag_parser_bot_processing_now duration:1m - define tag <[to_parse].replace_text[].with[<&sp>].trim> - inject tag_parser_process_tag_task player: npc: - inject tag_parser_crunch_result_task - ~run <[handle_output]> def.reply_to:<[reply_to]> "def.message: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_parser_message_reply_task: type: task debug: false definitions: reply_to|message script: - ~discordmessage id:tag_parser reply:<[reply_to]> <[message]> - wait 1t tag_parser_interaction_reply_task: type: task debug: false definitions: reply_to|message script: - ~discordinteraction reply interaction:<[reply_to]> <[message]> - wait 1t tag_parser_interaction_fail_task: type: task debug: false definitions: reply_to script: - ~discordinteraction delete interaction:<[reply_to]> - wait 1t tag_parser_process_tag_task: type: task debug: false definitions: name|origin|tag|channel script: - log " [<[name]>] in [<[origin]>] wants to process tag <[tag]>" file: - flag server tag_parser_result_temp:! # 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. - if : - inject dtag_determine_shouldrecord - else: - define should_record false - ~run tag_run_task def:].include[<[should_record]>]> - define result ]> - flag server tag_parser_result_temp:! - log " [<[name]>] in [<[origin]>] got result <[result]>" file: tag_run_task: type: task 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 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: - if <[record]>: - inject dtag_record_start - inject tag_parser_task - if <[record]>: - inject dtag_record_finish - flag server tag_parser_result_temp.valid:<[result]> tag_parser_task: type: task definitions: tag script: - define result <[tag].parsed> tag_parser_crunch_result_task: type: task debug: false definitions: tag|result script: - define final_result - 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." # This is enabled via /ex run tag_parser_generate_command # only needs to be ran once ever tag_parser_generate_command: type: task debug: false script: - definemap options: 1: type: string name: tag description: The tag to be parsed. required: true - ~discordcommand id:tag_parser create name:parsetag "description:Parses a Denizen tag insta-magically on Discord." options:<[options]> - narrate "Command registered"