Date: 2021/04/28 03:21:57 UTC-07:00
Type: Diff Report
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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 <server.has_flag[tag_parser_bot_running]>:
- - 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 !<yaml.list.contains[tag_parser_temp]>:
- debug error "Load failed."
- stop
- flag server tag_parser_logpath:<yaml[tag_parser_temp].read[bot.discord.log_path]>
- flag server tag_parser_validchannels:!
- flag server tag_parser_validchannels:|:<yaml[tag_parser_temp].read[bot.discord.valid_channels]>
- flag server tag_parser_barredchannels:!
- flag server tag_parser_barredchannels:|:<yaml[tag_parser_temp].read[bot.discord.barred_channels]>
- flag server tag_parser_barredchannelmessages:!
- flag server tag_parser_barredchannelmessages:|:<yaml[tag_parser_temp].read[bot.discord.barred_channel_messages]>
- flag server tag_parser_link:<yaml[tag_parser_temp].read[script.link]>
+ - yaml unload id:tag_parser_temp
- define samples <script.data_key[samples].with[link].as[<server.flag[tag_parser_link]>].with[version].as[<server.version>].with[denizen_version].as[<server.denizen_version>]>
- flag server tag_parser_samples:<[samples]>
- - discord id:tag_parser connect code:<yaml[tag_parser_temp].read[bot.discord.token]>
+ - ~discordconnect id:tag_parser tokenfile:data/tagparser_token.txt
- - yaml unload id:tag_parser_temp
- flag server tag_parser_bot_running
process_tag:
- log "<util.time_now.format> [<[name]>] in [<[origin]>] wants to process tag <[tag]>" file:<server.flag[tag_parser_logpath]>
- flag server tag_parser_result_temp:!
- - ~run tag_run_task def:<[tag]>
- - define result <server.flag[tag_parser_result_temp]||FAILED=FLAG_MISSING;>
- - define recorded <server.flag[tag_parser_record_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.
+ - define should_record false
+ - ~run tag_run_task def:<list_single[<[tag]>].include[<[should_record]>]>
+ - define result <server.flag[tag_parser_result_temp].if_null[<map.with[failed].as[FAILED=FLAG_MISSING]>]>
- flag server tag_parser_result_temp:!
- - flag server tag_parser_record_temp:!
+ - log "<util.time_now.format> [<[name]>] in [<[origin]>] got result <[result]>" file:<server.flag[tag_parser_logpath]>
- - log "<util.time_now.format> [<[name]>] in [<[origin]>] recorded to <[recorded]> got result <[result]>" file:<server.flag[tag_parser_logpath]>
crunch_result:
- define final_result <empty>
- - foreach <[result].split[;]>:
- - if <[value].starts_with[VALID=]>:
- - define final_result <[final_result]><[value].after[VALID=].replace_text[&sc].with[;]><n>
- - foreach <[result].split[;]>:
- - if <[value].starts_with[FAILED=ERROR/]>:
- - define final_result "<[final_result]>Had error: <[value].after[FAILED=ERROR/].replace_text[&sc].with[;]><n>"
- - else if <[value].starts_with[FAILED=EXCEPTION/]>:
- - define final_result "<[final_result]>Had internal exception: <[value].after[FAILED=EXCEPTION/].replace_text[&sc].with[;]><n>"
+ - if <[result].contains[valid]>:
+ - define final_result <[result].get[valid]><n>
+ - if <[result].contains[failed]>:
+ - foreach <[result].get[failed]>:
+ - if <[value].starts_with[Error=]>:
+ - define final_result "<[final_result]>Had error: <[value].after[Error=]><n>"
+ - else if <[value].starts_with[Exception=]>:
+ - define final_result "<[final_result]>Had internal exception: <[value].after[Exception=]><n>"
- 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.<n>"
- else:
- define final_result "<[final_result]>Got failure '<[fail_reason]>'.<n>"
- if <[final_result].trim.length> == 0:
- define final_result <empty>
- 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[<n>]].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/<context.message.escaped.replace_text[;].with[&sc]>;<server.flag[tag_parser_result_temp]||>
+ - flag server tag_parser_result_temp.failed:|:Error=<context.message.strip_color>
on server generates exception:
- - flag server tag_parser_result_temp:FAILED=EXCEPTION/<context.type.escaped.replace_text[;].with[&sc]>-<context.message.escaped.replace_text[;].with[&sc]>;<server.flag[tag_parser_result_temp]||>
+ - flag server tag_parser_result_temp.failed:|:Exception=<context.type>-<context.message>
on discord message received for:tag_parser:
- flag server tag_parser_bot_running
- - if <yaml.list.contains_text[tag_parser_temp]>:
- - yaml unload id:tag_parser_temp
+ - define name <context.new_message.author.id>/<context.new_message.author.name>
+ - define origin <context.group>/<context.channel>/<context.group.name>/<context.channel.name>
- - define name <context.new_message.author.id>/<context.new_message.author.name.escaped>
- - define origin <context.group>/<context.channel>/<context.group.name.escaped>/<context.channel.name.escaped>
- announce to_console "Discord chatter! [<[name]>] in [<[origin]>] saying <context.new_message.text> and mentioning <context.new_message.mentioned_users>"
- if !<context.new_message.mentioned_users.parse[id].contains[<context.bot.self_user.id>]>:
- stop
- if !<server.flag[tag_parser_validchannels].contains[<context.channel.id>]>:
- define found <server.flag[tag_parser_barredchannels].find[<context.channel.id>]>
- if <[found]> > 0:
- - discord id:tag_parser message channel:<context.channel> "Cannot parse that in this channel! <server.flag[tag_parser_barredchannelmessages].get[<[found]>]>"
+ - ~discordmessage id:tag_parser channel:<context.channel> "Cannot parse that in this channel! <server.flag[tag_parser_barredchannelmessages].get[<[found]>]>"
- stop
- - if <context.new_message.text_no_mentions.trim.escaped> == link:
- - discord id:tag_parser message channel:<context.channel> "The source script for **dTagParser** can be found at <<><server.flag[tag_parser_samples].as_map.get[link]><>>"
+ - if <context.new_message.text_no_mentions.trim> == link:
+ - ~discordmessage id:tag_parser channel:<context.channel> "The source script for **dTagParser** can be found at <<><server.flag[tag_parser_samples].as_map.get[link]><>>"
- stop
- waituntil rate:1s !<server.has_flag[tag_parser_bot_processing_now]>
- flag server tag_parser_bot_processing_now duration:1m
- - define tag <context.new_message.text_no_mentions.replace_text[<n>].with[<&sp>].trim.escaped>
- - inject locally script_paths.process_tag player:<server.players.get[1]> npc:<server.npcs.get[1]>
- - inject locally script_paths.crunch_result
- - discord id:tag_parser message channel:<context.channel> "Tag parse results for `<[tag].unescaped.replace_text[`].with[']>`<&co> <[recorded]><n>```<n><[final_result].unescaped.replace_text[`].with[']>```"
+ - define tag <context.new_message.text_no_mentions.replace_text[<n>].with[<&sp>].trim>
+ - inject tag_parser_bot.script_paths.process_tag player:<server.players.get[1]> npc:<server.npcs.get[1]>
+ - inject tag_parser_bot.script_paths.crunch_result
+ - ~discordmessage id:tag_parser channel:<context.channel> "Tag parse results for `<[tag].replace_text[`].with[']>`<&co> <[result].get[recording].if_null[]><n>```<n><[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 <server.flag[tag_parser_samples].as_map.with[sample_player].as[<player>].with[sample_npc].as[<npc>]>
- 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]>;<server.flag[tag_parser_result_temp]||>
+ - 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 <entry[recorded].submitted||null>
- - flag server tag_parser_result_temp:VALID=<[result]>;<server.flag[tag_parser_result_temp]||>
- #- 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 !<entry[recorded].submitted.exists>:
+ # - define record_url "(Submit Failed)"
+ # - else:
+ # - define record_url <<><entry[recorded].submitted><>>
+ # - 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>
+
+