File tree Expand file tree Collapse file tree
src/main/java/io/github/techstreet/dfscript/script/action Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,6 +118,31 @@ public enum ScriptActionType {
118118 ctx .variable ("Variable" ).name (),
119119 ctx .value ("Value" )
120120 ))),
121+
122+ GET_REQUEST (builder -> builder .name ("Get Webrequest" )
123+ .description ("Makes a get request to the internet." )
124+ .icon (Items .GRASS_BLOCK )
125+ .arg ("Result" , ScriptActionArgumentType .VARIABLE )
126+ .arg ("Url" , ScriptActionArgumentType .TEXT )
127+ .category (ScriptActionCategory .VARIABLES )
128+ .action (ctx -> {
129+ try {
130+ StringBuilder result = new StringBuilder ();
131+ URL url = new URL (ctx .value ("Url" ).asText ());
132+ HttpURLConnection conn = (HttpURLConnection ) url .openConnection ();
133+ conn .setRequestMethod ("GET" );
134+ try (BufferedReader reader = new BufferedReader (new InputStreamReader (conn .getInputStream ()))) {
135+ for (String line ; (line = reader .readLine ()) != null ; ) {
136+ result .append (line );
137+ }
138+ }
139+ ctx .task ().context ().setVariable (ctx .variable ("Result" ).name (), new ScriptTextValue (result .toString ()));
140+ }catch (MalformedURLException ex ){
141+
142+ }catch (IOException ex ){
143+
144+ }
145+ })),
121146
122147 INCREMENT (builder -> builder .name ("Increment" )
123148 .description ("Increments a variable by a value." )
You can’t perform that action at this time.
0 commit comments