diff --git a/.gitignore b/.gitignore index 40af856..3f9877a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,9 @@ out/ # Twitch Files config/ +# Image Output +ext/out + launch.sh libsentry_agent_windows-x86_64.dll diff --git a/build.gradle b/build.gradle index 82a7099..6c22434 100644 --- a/build.gradle +++ b/build.gradle @@ -62,8 +62,12 @@ dependencies { 'com.google.cloud:google-cloud-storage:1.55.0', 'io.sentry:sentry:1.7.16', - 'io.sentry:sentry-log4j2:1.7.16' + 'io.sentry:sentry-log4j2:1.7.16', + + 'com.github.Samuel-Maddock:StrawPoll-Java-API:1.0.4' ) + + compile files('ext/marvin/framework/marvin_1.5.5.jar') runtime( 'org.glassfish.jersey.media:jersey-media-json-jackson:2.27' diff --git a/ext/marvin/ASK_AN_EXPERT.html b/ext/marvin/ASK_AN_EXPERT.html new file mode 100644 index 0000000..ce4a074 --- /dev/null +++ b/ext/marvin/ASK_AN_EXPERT.html @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/ext/marvin/Discussion_Group.html b/ext/marvin/Discussion_Group.html new file mode 100644 index 0000000..4f638cc --- /dev/null +++ b/ext/marvin/Discussion_Group.html @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/ext/marvin/LICENSE b/ext/marvin/LICENSE new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/ext/marvin/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/ext/marvin/READ-ME.html b/ext/marvin/READ-ME.html new file mode 100644 index 0000000..a8dbeb9 --- /dev/null +++ b/ext/marvin/READ-ME.html @@ -0,0 +1,80 @@ + + + READ-ME | Marvin Framework + + + +

Marvin Framework 1.5.5

+ +
+ 1. Support Marvin
+ 2. Using Marvin in your a application
+ 3. Compiling and running (command-line)
+ 4. Resources
+ 5. Discussion Group
+ 6. Subscribe
+ 7. Ask an Expert
+ 8. License
+
+ + +

1. Support Marvin

+ +Suport us sharing the project with your friends and colleagues. Have you successfully used Marvin in a project? +Post a review. Visit our site and share it using the social media +panel on the top of the page. The more people we reach, more contributors we get! + + +

2. Using Marvin in your a application

+ +
  • copy this folder 'marvin' to your project folder and add marvin_1.5.5.jar into your project + library list
  • + +
  • the folder organization, including subfolders 'framework' and 'plugins', must be preserved.
  • + +
  • DO NOT add plug-ins .jar to your library list. They are loaded dynamically.
  • + + +
    + +

    3. Compiling and running (command-line)

    + +Compiling: javac -cp .;./marvin/framework/marvin_1.5.5.jar YourApplication.java

    + +Running: java -cp .;./marvin/framework/marvin_1.5.5.jar YourApplication + + +

    + +

    4. Resources

    + +
  • Tutorials
  • +
  • Examples
  • +
  • Plug-ins
  • +
  • Downloads (Samples and Project source code)
  • +
  • Youtube Channel
  • + +

    + + +

    5. Discussion Group

    +Get involved in discussion! Marvin Discussion Group + +

    + +

    6. Subscribe

    + +Get informed about new releases subscribing our Freecode page! + +

    + + +

    7. Ask an Expert

    +Are you looking for an image processing expert to help your project? Post your question on this form. + +

    +
    +

    8. License

    + +Marvin is released under LGPL license. Basically it can be distributed by any means. Its +binary might be used for commercial purposes. \ No newline at end of file diff --git a/ext/marvin/README.md b/ext/marvin/README.md new file mode 100644 index 0000000..7889eae --- /dev/null +++ b/ext/marvin/README.md @@ -0,0 +1,17 @@ +# Marvin Image Processing Framework + +**Java Image Processing Framework** + +Pure Java cross-platform image processing framework that provides features for image and video frame processing, multi-threading image processing, GUI integration, extensibility via plug-ins, unit text automation among other things. + +**WEBSITE:**
    +http://marvinproject.sourceforge.net/ + +**DISCUSSION GROUP:**
    +https://groups.google.com/forum/#!forum/marvin-project + +# Javascript Version: +**Site:** https://www.marvinj.org + +**Git:** https://github.com/gabrielarchanjo/marvinj + diff --git a/ext/marvin/framework/marvin_1.5.5.jar b/ext/marvin/framework/marvin_1.5.5.jar new file mode 100644 index 0000000..b98b63d Binary files /dev/null and b/ext/marvin/framework/marvin_1.5.5.jar differ diff --git a/ext/marvin/lib/junit-4.7.jar b/ext/marvin/lib/junit-4.7.jar new file mode 100644 index 0000000..700ad69 Binary files /dev/null and b/ext/marvin/lib/junit-4.7.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.artistic.mosaic.jar b/ext/marvin/plugins/image/org.marvinproject.image.artistic.mosaic.jar new file mode 100644 index 0000000..0dc4c7e Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.artistic.mosaic.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.artistic.television.jar b/ext/marvin/plugins/image/org.marvinproject.image.artistic.television.jar new file mode 100644 index 0000000..bad8cc5 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.artistic.television.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.background.determineFixedCameraBackground.jar b/ext/marvin/plugins/image/org.marvinproject.image.background.determineFixedCameraBackground.jar new file mode 100644 index 0000000..9dce87f Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.background.determineFixedCameraBackground.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.background.determineSceneBackground.jar b/ext/marvin/plugins/image/org.marvinproject.image.background.determineSceneBackground.jar new file mode 100644 index 0000000..a51fb09 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.background.determineSceneBackground.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.blur.gaussianBlur.jar b/ext/marvin/plugins/image/org.marvinproject.image.blur.gaussianBlur.jar new file mode 100644 index 0000000..a385e9b Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.blur.gaussianBlur.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.blur.pixelize.jar b/ext/marvin/plugins/image/org.marvinproject.image.blur.pixelize.jar new file mode 100644 index 0000000..ec0bf27 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.blur.pixelize.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.alphaBoundary.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.alphaBoundary.jar new file mode 100644 index 0000000..954f7ae Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.alphaBoundary.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.blackAndWhite.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.blackAndWhite.jar new file mode 100644 index 0000000..fded99d Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.blackAndWhite.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.brightnessAndContrast.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.brightnessAndContrast.jar new file mode 100644 index 0000000..09737ff Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.brightnessAndContrast.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.colorChannel.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.colorChannel.jar new file mode 100644 index 0000000..2146373 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.colorChannel.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.emboss.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.emboss.jar new file mode 100644 index 0000000..040db78 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.emboss.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.grayScale.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.grayScale.jar new file mode 100644 index 0000000..a5f6774 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.grayScale.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.invert.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.invert.jar new file mode 100644 index 0000000..605c581 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.invert.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.sepia.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.sepia.jar new file mode 100644 index 0000000..22bb3e0 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.sepia.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.skinColorDetection.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.skinColorDetection.jar new file mode 100644 index 0000000..0639b08 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.skinColorDetection.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.thresholding.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.thresholding.jar new file mode 100644 index 0000000..62bcff3 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.thresholding.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.color.thresholdingNeighborhood.jar b/ext/marvin/plugins/image/org.marvinproject.image.color.thresholdingNeighborhood.jar new file mode 100644 index 0000000..9c0dbe2 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.color.thresholdingNeighborhood.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.combine.combineByMask.jar b/ext/marvin/plugins/image/org.marvinproject.image.combine.combineByMask.jar new file mode 100644 index 0000000..817297c Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.combine.combineByMask.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.combine.combineByTransparency.jar b/ext/marvin/plugins/image/org.marvinproject.image.combine.combineByTransparency.jar new file mode 100644 index 0000000..1b6d2c3 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.combine.combineByTransparency.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.combine.mergePhotos.jar b/ext/marvin/plugins/image/org.marvinproject.image.combine.mergePhotos.jar new file mode 100644 index 0000000..24235cb Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.combine.mergePhotos.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.convolution.jar b/ext/marvin/plugins/image/org.marvinproject.image.convolution.jar new file mode 100644 index 0000000..3bd7250 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.convolution.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.corner.harris.jar b/ext/marvin/plugins/image/org.marvinproject.image.corner.harris.jar new file mode 100644 index 0000000..0180e38 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.corner.harris.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.corner.moravec.jar b/ext/marvin/plugins/image/org.marvinproject.image.corner.moravec.jar new file mode 100644 index 0000000..c6a9ef1 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.corner.moravec.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.corner.susan.jar b/ext/marvin/plugins/image/org.marvinproject.image.corner.susan.jar new file mode 100644 index 0000000..4f77778 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.corner.susan.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.difference.differenceColor.jar b/ext/marvin/plugins/image/org.marvinproject.image.difference.differenceColor.jar new file mode 100644 index 0000000..969d023 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.difference.differenceColor.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.difference.differenceGray.jar b/ext/marvin/plugins/image/org.marvinproject.image.difference.differenceGray.jar new file mode 100644 index 0000000..79c834a Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.difference.differenceGray.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.difference.differentRegions.jar b/ext/marvin/plugins/image/org.marvinproject.image.difference.differentRegions.jar new file mode 100644 index 0000000..74c0caa Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.difference.differentRegions.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.edge.edgeDetector.jar b/ext/marvin/plugins/image/org.marvinproject.image.edge.edgeDetector.jar new file mode 100644 index 0000000..c29526e Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.edge.edgeDetector.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.edge.prewitt.jar b/ext/marvin/plugins/image/org.marvinproject.image.edge.prewitt.jar new file mode 100644 index 0000000..59e68ed Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.edge.prewitt.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.edge.roberts.jar b/ext/marvin/plugins/image/org.marvinproject.image.edge.roberts.jar new file mode 100644 index 0000000..f506570 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.edge.roberts.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.edge.sobel.jar b/ext/marvin/plugins/image/org.marvinproject.image.edge.sobel.jar new file mode 100644 index 0000000..9780a63 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.edge.sobel.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.equalization.histogramEqualization.jar b/ext/marvin/plugins/image/org.marvinproject.image.equalization.histogramEqualization.jar new file mode 100644 index 0000000..8faf166 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.equalization.histogramEqualization.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.fill.boundaryFill.jar b/ext/marvin/plugins/image/org.marvinproject.image.fill.boundaryFill.jar new file mode 100644 index 0000000..426b5bb Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.fill.boundaryFill.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.halftone.circles.jar b/ext/marvin/plugins/image/org.marvinproject.image.halftone.circles.jar new file mode 100644 index 0000000..3000cc3 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.halftone.circles.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.halftone.dithering.jar b/ext/marvin/plugins/image/org.marvinproject.image.halftone.dithering.jar new file mode 100644 index 0000000..09ebd47 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.halftone.dithering.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.halftone.errorDiffusion.jar b/ext/marvin/plugins/image/org.marvinproject.image.halftone.errorDiffusion.jar new file mode 100644 index 0000000..81d5ab0 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.halftone.errorDiffusion.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.halftone.rylanders.jar b/ext/marvin/plugins/image/org.marvinproject.image.halftone.rylanders.jar new file mode 100644 index 0000000..c209e93 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.halftone.rylanders.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.histogram.colorHistogram.jar b/ext/marvin/plugins/image/org.marvinproject.image.histogram.colorHistogram.jar new file mode 100644 index 0000000..91ee401 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.histogram.colorHistogram.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.histogram.grayHistogram.jar b/ext/marvin/plugins/image/org.marvinproject.image.histogram.grayHistogram.jar new file mode 100644 index 0000000..6e59c5d Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.histogram.grayHistogram.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.interfaceTest.jar b/ext/marvin/plugins/image/org.marvinproject.image.interfaceTest.jar new file mode 100644 index 0000000..60e0ed6 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.interfaceTest.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.morphological.boundary.jar b/ext/marvin/plugins/image/org.marvinproject.image.morphological.boundary.jar new file mode 100644 index 0000000..6882aca Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.morphological.boundary.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.morphological.closing.jar b/ext/marvin/plugins/image/org.marvinproject.image.morphological.closing.jar new file mode 100644 index 0000000..680ef40 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.morphological.closing.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.morphological.dilation.jar b/ext/marvin/plugins/image/org.marvinproject.image.morphological.dilation.jar new file mode 100644 index 0000000..ad104e4 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.morphological.dilation.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.morphological.erosion.jar b/ext/marvin/plugins/image/org.marvinproject.image.morphological.erosion.jar new file mode 100644 index 0000000..2ce6d97 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.morphological.erosion.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.morphological.opening.jar b/ext/marvin/plugins/image/org.marvinproject.image.morphological.opening.jar new file mode 100644 index 0000000..0679e16 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.morphological.opening.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.pattern.correlation.jar b/ext/marvin/plugins/image/org.marvinproject.image.pattern.correlation.jar new file mode 100644 index 0000000..d90b58d Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.pattern.correlation.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.pattern.findColorPattern.jar b/ext/marvin/plugins/image/org.marvinproject.image.pattern.findColorPattern.jar new file mode 100644 index 0000000..662f4ee Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.pattern.findColorPattern.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.pattern.findSubimage.jar b/ext/marvin/plugins/image/org.marvinproject.image.pattern.findSubimage.jar new file mode 100644 index 0000000..ceed1ff Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.pattern.findSubimage.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.pattern.findTextRegions.jar b/ext/marvin/plugins/image/org.marvinproject.image.pattern.findTextRegions.jar new file mode 100644 index 0000000..78e858a Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.pattern.findTextRegions.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.pattern.harrisPlessey.jar b/ext/marvin/plugins/image/org.marvinproject.image.pattern.harrisPlessey.jar new file mode 100644 index 0000000..15c8b0b Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.pattern.harrisPlessey.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.pattern.patternRecognition.jar b/ext/marvin/plugins/image/org.marvinproject.image.pattern.patternRecognition.jar new file mode 100644 index 0000000..8d403ec Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.pattern.patternRecognition.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.quantization.colorQuantization.jar b/ext/marvin/plugins/image/org.marvinproject.image.quantization.colorQuantization.jar new file mode 100644 index 0000000..6758bb4 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.quantization.colorQuantization.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.quantization.grayScaleQuantization.jar b/ext/marvin/plugins/image/org.marvinproject.image.quantization.grayScaleQuantization.jar new file mode 100644 index 0000000..af7f531 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.quantization.grayScaleQuantization.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.render.grayGradient.jar b/ext/marvin/plugins/image/org.marvinproject.image.render.grayGradient.jar new file mode 100644 index 0000000..397ce83 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.render.grayGradient.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.render.iteratedFunctionSystem.jar b/ext/marvin/plugins/image/org.marvinproject.image.render.iteratedFunctionSystem.jar new file mode 100644 index 0000000..9768a44 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.render.iteratedFunctionSystem.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.render.juliaSet.jar b/ext/marvin/plugins/image/org.marvinproject.image.render.juliaSet.jar new file mode 100644 index 0000000..618ceba Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.render.juliaSet.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.render.lindenmayer.jar b/ext/marvin/plugins/image/org.marvinproject.image.render.lindenmayer.jar new file mode 100644 index 0000000..63c0f5a Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.render.lindenmayer.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.render.mandelbrot.jar b/ext/marvin/plugins/image/org.marvinproject.image.render.mandelbrot.jar new file mode 100644 index 0000000..0809cf0 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.render.mandelbrot.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.render.text.jar b/ext/marvin/plugins/image/org.marvinproject.image.render.text.jar new file mode 100644 index 0000000..cd2a577 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.render.text.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.restoration.noiseReduction.jar b/ext/marvin/plugins/image/org.marvinproject.image.restoration.noiseReduction.jar new file mode 100644 index 0000000..6a45cd9 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.restoration.noiseReduction.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.segmentation.crop.jar b/ext/marvin/plugins/image/org.marvinproject.image.segmentation.crop.jar new file mode 100644 index 0000000..15cf0ae Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.segmentation.crop.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.segmentation.floodfillSegmentation.jar b/ext/marvin/plugins/image/org.marvinproject.image.segmentation.floodfillSegmentation.jar new file mode 100644 index 0000000..a199a31 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.segmentation.floodfillSegmentation.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.segmentation.imageSlicer.jar b/ext/marvin/plugins/image/org.marvinproject.image.segmentation.imageSlicer.jar new file mode 100644 index 0000000..bdb9964 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.segmentation.imageSlicer.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.statistical.maximum.jar b/ext/marvin/plugins/image/org.marvinproject.image.statistical.maximum.jar new file mode 100644 index 0000000..c11bc8d Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.statistical.maximum.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.statistical.median.jar b/ext/marvin/plugins/image/org.marvinproject.image.statistical.median.jar new file mode 100644 index 0000000..fca64a5 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.statistical.median.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.statistical.minimum.jar b/ext/marvin/plugins/image/org.marvinproject.image.statistical.minimum.jar new file mode 100644 index 0000000..1f9f0cf Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.statistical.minimum.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.statistical.mode.jar b/ext/marvin/plugins/image/org.marvinproject.image.statistical.mode.jar new file mode 100644 index 0000000..1b80da9 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.statistical.mode.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.steganography.jar b/ext/marvin/plugins/image/org.marvinproject.image.steganography.jar new file mode 100644 index 0000000..a8c702d Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.steganography.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.subtract.jar b/ext/marvin/plugins/image/org.marvinproject.image.subtract.jar new file mode 100644 index 0000000..9b3a9a0 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.subtract.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.texture.tileTexture.jar b/ext/marvin/plugins/image/org.marvinproject.image.texture.tileTexture.jar new file mode 100644 index 0000000..09a6d52 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.texture.tileTexture.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.transform.flip.jar b/ext/marvin/plugins/image/org.marvinproject.image.transform.flip.jar new file mode 100644 index 0000000..a2be3d6 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.transform.flip.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.transform.rotate.jar b/ext/marvin/plugins/image/org.marvinproject.image.transform.rotate.jar new file mode 100644 index 0000000..0bc69b6 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.transform.rotate.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.transform.scale.jar b/ext/marvin/plugins/image/org.marvinproject.image.transform.scale.jar new file mode 100644 index 0000000..fd4a422 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.transform.scale.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.transform.skew.jar b/ext/marvin/plugins/image/org.marvinproject.image.transform.skew.jar new file mode 100644 index 0000000..517d35b Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.transform.skew.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.image.transform.watershed.jar b/ext/marvin/plugins/image/org.marvinproject.image.transform.watershed.jar new file mode 100644 index 0000000..d95f204 Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.image.transform.watershed.jar differ diff --git a/ext/marvin/plugins/image/org.marvinproject.ml.kmeans.jar b/ext/marvin/plugins/image/org.marvinproject.ml.kmeans.jar new file mode 100644 index 0000000..4e5ac8a Binary files /dev/null and b/ext/marvin/plugins/image/org.marvinproject.ml.kmeans.jar differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 29953ea..457aad0 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e0b3fb8..75b8c7c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index cccdd3d..af6708f 100755 --- a/gradlew +++ b/gradlew @@ -28,7 +28,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" diff --git a/gradlew.bat b/gradlew.bat index f955316..6d57edc 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/src/main/java/com/mazawrath/beanbot/Main.java b/src/main/java/com/mazawrath/beanbot/Main.java index d6946b0..0938b50 100644 --- a/src/main/java/com/mazawrath/beanbot/Main.java +++ b/src/main/java/com/mazawrath/beanbot/Main.java @@ -8,6 +8,9 @@ import com.mazawrath.beanbot.commands.beancoin.*; import com.mazawrath.beanbot.commands.copypasta.*; import com.mazawrath.beanbot.commands.googlevision.AnalyzeCommand; +import com.mazawrath.beanbot.commands.image.*; +import com.mazawrath.beanbot.commands.poll.PollCommand; +import com.mazawrath.beanbot.commands.poll.StrawPollCommand; import com.mazawrath.beanbot.utilities.*; import com.mazawrath.beanbot.commands.admin.*; import com.mazawrath.beanbot.utilities.jersey.RestServer; @@ -16,6 +19,7 @@ import de.btobastian.sdcf4j.handler.JavacordHandler; //import org.apache.log4j.BasicConfigurator; import io.sentry.Sentry; +import marvin.MarvinDefinitions; import org.javacord.api.DiscordApi; import org.javacord.api.DiscordApiBuilder; import org.javacord.api.util.logging.FallbackLoggerConfiguration; @@ -26,12 +30,13 @@ public class Main { private static DiscordApi api; public static void main(String[] args) { - Sentry.init(); System.setProperty("log4j2.loggerContextFactory", "org.apache.logging.log4j.core.impl.Log4jContextFactory"); FallbackLoggerConfiguration.setDebug(false); + System.setProperty("http.agent", "Chrome"); + Connection conn = r.connection().hostname("localhost").port(28015).connect(); Points points = new Points(conn); @@ -47,6 +52,8 @@ public static void main(String[] args) { Main.api = api; Twitch.setApi(api); + MarvinDefinitions.setImagePluginPath("./ext/marvin/plugins/image/"); + // Instantiate command handler CommandHandler cmdHandler = new JavacordHandler(api); @@ -75,8 +82,21 @@ public static void main(String[] args) { cmdHandler.registerCommand(new BeanInvestCommand(points, stockMarket)); // Bean Lottery Commands cmdHandler.registerCommand(new BeanLotteryCommand(points, lottery)); + // Image Manipulation Commands + cmdHandler.registerCommand(new DeepFryCommand(points)); + //cmdHandler.registerCommand(new EdgeCommand(points)); + cmdHandler.registerCommand(new EmbossCommand(points)); + cmdHandler.registerCommand(new InvertCommand(points)); + //cmdHandler.registerCommand(new MergeCommand(points)); + cmdHandler.registerCommand(new DiffuseCommand(points)); + cmdHandler.registerCommand(new MosaicCommand(points)); + cmdHandler.registerCommand(new SepiaCommand(points)); + cmdHandler.registerCommand(new HistogramCommand(points)); // Google Vision Commands cmdHandler.registerCommand(new AnalyzeCommand(points)); + // Poll Commands + cmdHandler.registerCommand(new PollCommand(points)); + cmdHandler.registerCommand(new StrawPollCommand(points)); // Admin commands cmdHandler.registerCommand(new AdminPostChangeLogCommand()); cmdHandler.registerCommand(new AdminDeleteMessageCommand()); diff --git a/src/main/java/com/mazawrath/beanbot/commands/HelpCommand.java b/src/main/java/com/mazawrath/beanbot/commands/HelpCommand.java index 82d9d0e..b3c95ba 100644 --- a/src/main/java/com/mazawrath/beanbot/commands/HelpCommand.java +++ b/src/main/java/com/mazawrath/beanbot/commands/HelpCommand.java @@ -27,6 +27,7 @@ public HelpCommand(CommandHandler commandHandler) { async = true, showInHelpPage = true ) + public void onCommand(String[] args, ServerTextChannel channel, User author, Server server) { SentryLog.addContext(args, author, server); diff --git a/src/main/java/com/mazawrath/beanbot/commands/admin/AdminPostChangeLogCommand.java b/src/main/java/com/mazawrath/beanbot/commands/admin/AdminPostChangeLogCommand.java index 5061a91..0f02b5f 100644 --- a/src/main/java/com/mazawrath/beanbot/commands/admin/AdminPostChangeLogCommand.java +++ b/src/main/java/com/mazawrath/beanbot/commands/admin/AdminPostChangeLogCommand.java @@ -40,19 +40,26 @@ public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTex private String getRecentChangeLog() { return "**New beanBOT update released.**\n" + - "Release can be found on https://github.com/Mazawrath/beanBOT/releases/tag/v3.4.0\n" + - "Detailed changelog can be found on https://github.com/Mazawrath/beanBOT/compare/v3.3.0...v3.4.0\n" + + "Release can be found on https://github.com/Mazawrath/beanBOT/releases/tag/v3.5.0\n" + + "Detailed changelog can be found on https://github.com/Mazawrath/beanBOT/compare/v3.4.0...v3.5.0\n" + "\n" + - "**v3.4.0**\n" + + "**v3.5.0**\n" + "**New**\n" + - "\t- Added `.minesweeper`.\n" + + "\t- Added photo manipulation.\n" + + "\t\t- Added `.deepfry`.\n" + + "\t\t- Added `.emboss`.\n" + + "\t\t- Added `.invert`.\n" + + "\t\t- Added `.diffuse`.\n" + + "\t\t- Added `.mosaic`.\n" + + "\t\t- Added `.sepia`.\n" + + "\t- Added polling.\n" + + "\t\t- Added `.poll`.\n" + + "\t\t- Added `.strawpoll`.\n" + "**Changes**\n" + - "\t- Set limit to how many lottery tickets can be bought in a single drawing to 200.\n" + - "\t- Set max lottery number to be drawn from 40 to 20.\n" + - "\t- Removed minimum amount required for automatic bean lottery drawings.\n" + - "\t- Bean coin from `.beanbet` will only go to the bot when the bet loses.\n" + + "\t- Changed limit to how many lottery tickets can be bought at the start of a new drawing from 200 to 100.\n" + + "\t\t- After every drawing without a winner users will be able to buy up to 50 more tickets.\n" + "**Bug Fixes**\n" + - "\t- Fixed outdated info with `.beanlottery draw`.\n" + - "\t- Fixed an issue with integer checks with `.beanlottery`."; + "\t- Fixed a file reading issue with `.analyze`.\n" + + "\t- Fixed a issue with records getting added to the lottery database when they did not buy a ticket."; } } \ No newline at end of file diff --git a/src/main/java/com/mazawrath/beanbot/commands/beanlottery/BeanLotteryCommand.java b/src/main/java/com/mazawrath/beanbot/commands/beanlottery/BeanLotteryCommand.java index c112f7a..e4d4981 100644 --- a/src/main/java/com/mazawrath/beanbot/commands/beanlottery/BeanLotteryCommand.java +++ b/src/main/java/com/mazawrath/beanbot/commands/beanlottery/BeanLotteryCommand.java @@ -12,10 +12,12 @@ import org.javacord.api.entity.message.MessageBuilder; import org.javacord.api.entity.server.Server; import org.javacord.api.entity.user.User; +import org.javacord.api.util.NonThrowingAutoCloseable; import java.math.BigDecimal; import java.util.ArrayList; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; public class BeanLotteryCommand implements CommandExecutor { private Points points; @@ -37,94 +39,105 @@ public BeanLotteryCommand(Points points, Lottery lottery) { public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server) { SentryLog.addContext(args, author, server); - if (args.length == 1) { - if (args[0].equalsIgnoreCase("start")) { - if (!author.isBotOwner() && !server.isOwner(author)) { - try { - serverTextChannel.sendMessage("Only " + api.getOwner().get().getDiscriminatedName() + " or " + server.getOwner().getDisplayName(server) + " can use this command."); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); + try { // Thanks a lot Jeff + if (args.length == 1) { + if (args[0].equalsIgnoreCase("start")) { + if (!author.isBotOwner() && !server.isOwner(author)) { + try { + serverTextChannel.sendMessage("Only " + api.getOwner().get().getDiscriminatedName() + " or " + server.getOwner().getDisplayName(server) + " can use this command."); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + return; + } else { + serverTextChannel.sendMessage("Automatic drawings now active. Drawing will happen at this time every 3 days."); + lottery.scheduleWeeklyDrawing(points, server, api, serverTextChannel); + return; } - return; - } else { - serverTextChannel.sendMessage("Automatic drawings now active. Drawing will happen at this time every 3 days."); - lottery.scheduleWeeklyDrawing(points, server, api, serverTextChannel); - return; - } - } //else if (args[0].equalsIgnoreCase("draw")) { + } //else if (args[0].equalsIgnoreCase("draw")) { // if (points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.LOTTERY_DRAWING_COST)) { // lottery.drawNumbers(points, server, api, serverTextChannel); // } else // serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); // return; // } - if (Integer.parseInt(args[0]) > 200) { - serverTextChannel.sendMessage("You can only buy 200 tickets at a time."); - return; - } - - if (Integer.parseInt(args[0]) < 1) { - serverTextChannel.sendMessage("You cannot buy less than 1 ticket."); - return; - } - - if (!lottery.canBuyTickets(author.getIdAsString(), server.getIdAsString(), Integer.parseInt(args[0]))) { - serverTextChannel.sendMessage("You can only buy " + Lottery.MAX_TICKETS + " tickets at a time for a bean lottery drawing. You have bought " + lottery.getTicketCount(author.getIdAsString(), server.getIdAsString()) + " tickets."); - return; - } - - if (points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.LOTTERY_TICKET_COST.multiply(new BigDecimal(Integer.parseInt(args[0]))))) { - - ArrayList> numbers = lottery.addEntry(author.getIdAsString(), server.getIdAsString(), Integer.parseInt(args[0])); - - serverTextChannel.sendMessage(args[0] + " tickets bought.\n" + - "The numbers generated have been sent to you in a private message."); - author.sendMessage(args[0] + " tickets bought.\n" + - "Your numbers are:"); - MessageBuilder message = new MessageBuilder(); - - for (int i = 0; i < numbers.size(); i++) { - for (int j = 0; j < Lottery.AMOUNT_DRAWN; j++) - message.append(numbers.get(i).get(j) + " "); - message.append("\n"); + if (Integer.parseInt(args[0]) > 200) { + serverTextChannel.sendMessage("You can only buy 200 tickets at a time."); + return; } - message.send(author); - } else - serverTextChannel.sendMessage("You don't have enough beanCoin to buy that many tickets."); - } else if (args.length >= Lottery.AMOUNT_DRAWN) { - if (!StringUtils.isNumeric(args[0])) { - serverTextChannel.sendMessage("Invalid amount."); - return; - } - - if (!lottery.canBuyTickets(author.getIdAsString(), server.getIdAsString(), 1)) { - serverTextChannel.sendMessage("You can only buy " + Lottery.MAX_TICKETS + " tickets at a time for a bean lottery drawing. You have bought " + lottery.getTicketCount(author.getIdAsString(), server.getIdAsString()) + " tickets."); - return; - } - - int[] numbers = new int[Lottery.AMOUNT_DRAWN]; - - for (int i = 0; i < Lottery.AMOUNT_DRAWN; i++) { - if (Integer.parseInt(args[i]) >= Lottery.MIN_NUMBER && Integer.parseInt(args[i]) <= Lottery.MAX_NUMBER) - numbers[i] = Integer.parseInt(args[i]); - else { - serverTextChannel.sendMessage(args[i] + " is an invalid number. Numbers must be greater than or equal to " + Lottery.MIN_NUMBER + " and less than or equal to " + Lottery.MAX_NUMBER); + + if (Integer.parseInt(args[0]) < 1) { + serverTextChannel.sendMessage("You cannot buy less than 1 ticket."); + return; + } + + if (points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.LOTTERY_TICKET_COST.multiply(new BigDecimal(Integer.parseInt(args[0]))))) { + if (!lottery.canBuyTickets(author.getIdAsString(), server.getIdAsString(), Integer.parseInt(args[0]))) { + serverTextChannel.sendMessage("You can only buy " + lottery.getMaxTickets(server.getIdAsString()) + " tickets at a time for a bean lottery drawing. You have bought " + lottery.getTicketCount(author.getIdAsString(), server.getIdAsString()) + " tickets."); + return; + } + + ArrayList> numbers; + + try (NonThrowingAutoCloseable typingIndicator = serverTextChannel.typeContinuouslyAfter(1, TimeUnit.SECONDS)) { + numbers = lottery.addEntry(author.getIdAsString(), server.getIdAsString(), Integer.parseInt(args[0])); + + serverTextChannel.sendMessage(args[0] + " tickets bought.\n" + + "The numbers generated have been sent to you in a private message."); + } + author.sendMessage(args[0] + " tickets bought.\n" + + "Your numbers are:"); + MessageBuilder message = new MessageBuilder(); + + for (int i = 0; i < numbers.size(); i++) { + for (int j = 0; j < Lottery.AMOUNT_DRAWN; j++) + message.append(numbers.get(i).get(j) + " "); + message.append("\n"); + } + message.send(author); + } else + serverTextChannel.sendMessage("You don't have enough beanCoin to buy that many tickets."); + } else if (args.length >= Lottery.AMOUNT_DRAWN) { + if (!lottery.canBuyTickets(author.getIdAsString(), server.getIdAsString(), Integer.parseInt(args[0]))) { + serverTextChannel.sendMessage("You can only buy " + lottery.getMaxTickets(server.getIdAsString()) + " tickets at a time for a bean lottery drawing. You have bought " + lottery.getTicketCount(author.getIdAsString(), server.getIdAsString()) + " tickets."); return; } - } - if (points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.LOTTERY_TICKET_COST)) { - lottery.addEntry(author.getIdAsString(), server.getIdAsString(), numbers); - - serverTextChannel.sendMessage("1 ticket bought.\n" + - "Your numbers have been sent to you in a private message."); - author.sendMessage("1 ticket bought.\n" + - "Your numbers are:\n"); - author.sendMessage(args[0] + " " + args[1] + " " + args[2]); - } else - serverTextChannel.sendMessage("You do not have enough beanCoin to buy a ticket."); - } else - serverTextChannel.sendMessage("You must have 1 number with how many tickets you want to buy, " + Lottery.AMOUNT_DRAWN + " numbers >= " + Lottery.MIN_NUMBER + " and <= " + Lottery.MAX_NUMBER + ", or the word `draw` to have your own drawing."); + if (!StringUtils.isNumeric(args[0])) { + serverTextChannel.sendMessage("Invalid amount."); + return; + } + + if (!lottery.canBuyTickets(author.getIdAsString(), server.getIdAsString(), 1)) { + serverTextChannel.sendMessage("You can only buy " + lottery.getMaxTickets(server.getIdAsString()) + " tickets at the moment. After every drawing you will be able to buy " + Lottery.ADD_AFTER_DRAWING + " more tickets. You have bought " + lottery.getTicketCount(author.getIdAsString(), server.getIdAsString()) + " tickets."); + return; + } + + int[] numbers = new int[Lottery.AMOUNT_DRAWN]; + + for (int i = 0; i < Lottery.AMOUNT_DRAWN; i++) { + if (Integer.parseInt(args[i]) >= Lottery.MIN_NUMBER && Integer.parseInt(args[i]) <= Lottery.MAX_NUMBER) + numbers[i] = Integer.parseInt(args[i]); + else { + serverTextChannel.sendMessage(args[i] + " is an invalid number. Numbers must be greater than or equal to " + Lottery.MIN_NUMBER + " and less than or equal to " + Lottery.MAX_NUMBER); + return; + } + } + if (points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.LOTTERY_TICKET_COST)) { + lottery.addEntry(author.getIdAsString(), server.getIdAsString(), numbers); + + serverTextChannel.sendMessage("1 ticket bought.\n" + + "Your numbers have been sent to you in a private message."); + author.sendMessage("1 ticket bought.\n" + + "Your numbers are:\n"); + author.sendMessage(args[0] + " " + args[1] + " " + args[2]); + } else + serverTextChannel.sendMessage("You do not have enough beanCoin to buy a ticket."); + } else + serverTextChannel.sendMessage("You must have 1 number with how many tickets you want to buy, " + Lottery.AMOUNT_DRAWN + " numbers >= " + Lottery.MIN_NUMBER + " and <= " + Lottery.MAX_NUMBER + ", or the word `draw` to have your own drawing."); + } catch (NumberFormatException e) { + serverTextChannel.sendMessage("Invalid number(s)."); + } Sentry.clearContext(); } } diff --git a/src/main/java/com/mazawrath/beanbot/commands/googlevision/AnalyzeCommand.java b/src/main/java/com/mazawrath/beanbot/commands/googlevision/AnalyzeCommand.java index ef6ca69..b23e04d 100644 --- a/src/main/java/com/mazawrath/beanbot/commands/googlevision/AnalyzeCommand.java +++ b/src/main/java/com/mazawrath/beanbot/commands/googlevision/AnalyzeCommand.java @@ -11,11 +11,13 @@ import org.javacord.api.entity.message.Message; import org.javacord.api.entity.server.Server; import org.javacord.api.entity.user.User; +import org.javacord.api.util.NonThrowingAutoCloseable; -import javax.activation.MimetypesFileTypeMap; -import java.io.File; +import javax.swing.*; +import java.awt.*; import java.net.MalformedURLException; import java.net.URL; +import java.util.concurrent.TimeUnit; public class AnalyzeCommand implements CommandExecutor { private Points points; @@ -41,7 +43,6 @@ else if (args.length > 0) { try { url = new URL(args[0]); } catch (MalformedURLException e) { - e.printStackTrace(); serverTextChannel.sendMessage("URL is not valid."); return; } @@ -55,32 +56,31 @@ else if (args.length > 0) { return; } - serverTextChannel.sendMessage("Analyzing image..."); - ImageRequest imageRequest; + try (NonThrowingAutoCloseable typingIndicator = serverTextChannel.typeContinuouslyAfter(5, TimeUnit.MICROSECONDS)) { - if (urlContainsImage(url)) { - try { - imageRequest = new ImageRequest(url); - } catch (Exception e) { - e.printStackTrace(); - serverTextChannel.sendMessage("Something went wrong."); + + if (urlContainsImage(url)) { + try { + imageRequest = new ImageRequest(url); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } else { + serverTextChannel.sendMessage("URL must be an image."); return; } - } else { - serverTextChannel.sendMessage("URL must be an image."); - return; } - serverTextChannel.sendMessage(imageRequest.buildEmbed()); + serverTextChannel.sendMessage(imageRequest.buildEmbed()); Sentry.clearContext(); } private boolean urlContainsImage(URL url) { - File f = new File(url.toString()); - String mimetype = new MimetypesFileTypeMap().getContentType(f); - String type = mimetype.split("/")[0]; - return type.equals("image"); + Image image = new ImageIcon(url).getImage(); + return image.getWidth(null) != -1; } } diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/DeepFryCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/DeepFryCommand.java new file mode 100644 index 0000000..ea06c5b --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/DeepFryCommand.java @@ -0,0 +1,83 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.swing.*; +import java.awt.*; +import java.net.URL; + +public class DeepFryCommand implements CommandExecutor { + private Points points; + + public DeepFryCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"deepfry"}, + usage = "deepfry [url] [[brightness] [contrast]]", + description = "Creates a deep fried image with custom options to decide the brightness and contrast.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getDeepFry()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/DiffuseCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/DiffuseCommand.java new file mode 100644 index 0000000..c5c91ad --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/DiffuseCommand.java @@ -0,0 +1,82 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.swing.*; +import java.net.URL; + +public class DiffuseCommand implements CommandExecutor { + private Points points; + + public DiffuseCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"diffuse"}, + usage = "diffuse [url]", + description = "Creates a deep fried image with custom options to decide the brightness and contrast.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getErrorDiffusion()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/EdgeCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/EdgeCommand.java new file mode 100644 index 0000000..ba36ac3 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/EdgeCommand.java @@ -0,0 +1,86 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.activation.MimetypesFileTypeMap; +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; + +public class EdgeCommand implements CommandExecutor { + private Points points; + + public EdgeCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"edge"}, + usage = "edge [url]", + description = "Creates a deep fried image with custom options to decide the brightness and contrast.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getEdges()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/EmbossCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/EmbossCommand.java new file mode 100644 index 0000000..5dba59d --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/EmbossCommand.java @@ -0,0 +1,86 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.activation.MimetypesFileTypeMap; +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; + +public class EmbossCommand implements CommandExecutor { + private Points points; + + public EmbossCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"emboss"}, + usage = "emboss [url]", + description = "Creates a deep fried image with custom options to decide the brightness and contrast.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getEmboss()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/HistogramCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/HistogramCommand.java new file mode 100644 index 0000000..c2afe19 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/HistogramCommand.java @@ -0,0 +1,82 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.swing.*; +import java.net.URL; + +public class HistogramCommand implements CommandExecutor { + private Points points; + + public HistogramCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"histogram"}, + usage = "histogram [url]", + description = "Creates a histogram image.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getHistogram()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/InvertCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/InvertCommand.java new file mode 100644 index 0000000..f4d4270 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/InvertCommand.java @@ -0,0 +1,84 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.swing.*; +import java.awt.*; +import java.net.MalformedURLException; +import java.net.URL; + +public class InvertCommand implements CommandExecutor { + private Points points; + + public InvertCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"invert"}, + usage = "invert [url]", + description = "Inverts the colors of an image", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getInvert()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/MergeCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/MergeCommand.java new file mode 100644 index 0000000..f080133 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/MergeCommand.java @@ -0,0 +1,80 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MergeRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.activation.MimetypesFileTypeMap; +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; + +public class MergeCommand implements CommandExecutor { + private Points points; + + public MergeCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"merge"}, + usage = "merge [urls]", + description = "Merges multiple images into one.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL[] urls = new URL[args.length]; + if (args.length > 1) { + for (int i = 0; i < args.length; i++) { + try { + urls[i] = new URL(args[i]); + if (!urlContainsImage(urls[i])) { + serverTextChannel.sendMessage(urls[i] + " is not a valid image."); + return; + } + } catch (MalformedURLException e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Invalid URL."); + return; + } + } + } else { + serverTextChannel.sendMessage("You must either have at least 2 URL's in your message."); + return; + } + + try { + MergeRequest request = new MergeRequest(urls); + serverTextChannel.sendMessage(request.getMerge()); + } catch (IOException e) { + e.printStackTrace(); + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/MosaicCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/MosaicCommand.java new file mode 100644 index 0000000..c6cb7e1 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/MosaicCommand.java @@ -0,0 +1,82 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.swing.*; +import java.net.URL; + +public class MosaicCommand implements CommandExecutor { + private Points points; + + public MosaicCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"mosaic"}, + usage = "mosaic [url]", + description = "Creates a deep fried image with custom options to decide the brightness and contrast.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getMosaic()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/image/SepiaCommand.java b/src/main/java/com/mazawrath/beanbot/commands/image/SepiaCommand.java new file mode 100644 index 0000000..edf851c --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/image/SepiaCommand.java @@ -0,0 +1,82 @@ +package com.mazawrath.beanbot.commands.image; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.mazawrath.beanbot.utilities.photo.MarvinRequest; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.message.MessageSet; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import javax.swing.*; +import java.net.URL; + +public class SepiaCommand implements CommandExecutor { + private Points points; + + public SepiaCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"sepia"}, + usage = "sepia [url]", + description = "Creates a sepia image.", + privateMessages = false + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server, Message message) { + SentryLog.addContext(args, author, server); + + if (!points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.COMMAND_COST)) { + serverTextChannel.sendMessage("You do not have enough beanCoin for this command"); + return; + } + + serverTextChannel.type(); + + URL url = null; + if (message.getAttachments().size() != 0) + url = message.getAttachments().get(0).getUrl(); + else { + MessageSet previousMessages = message.getMessagesBefore(20).join(); + + for (Message previousMessage: previousMessages.descendingSet()) { + URL urlTest; + if (previousMessage.getAttachments().size() != 0) { + urlTest = previousMessage.getAttachments().get(0).getUrl(); + if (urlContainsImage(urlTest)) { + url = urlTest; + break; + } + } + } + } + if (url == null) { + serverTextChannel.sendMessage("You must either have a URL in your message or an attachment."); + return; + } + + if (urlContainsImage(url)) { + try { + MarvinRequest request = new MarvinRequest(url); + serverTextChannel.sendMessage(request.getSepia()); + } catch (Exception e) { + e.printStackTrace(); + serverTextChannel.sendMessage("Something went wrong."); + return; + } + } + + Sentry.clearContext(); + } + + private boolean urlContainsImage(URL url) { + return new ImageIcon(url).getImage().getWidth(null) != -1; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/poll/PollCommand.java b/src/main/java/com/mazawrath/beanbot/commands/poll/PollCommand.java new file mode 100644 index 0000000..2753245 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/poll/PollCommand.java @@ -0,0 +1,36 @@ +package com.mazawrath.beanbot.commands.poll; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.vdurmont.emoji.EmojiParser; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.message.Message; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +public class PollCommand implements CommandExecutor { + private Points points; + + public PollCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"poll"}, + usage = "poll [question]", + description = "Adds a thumbs up and thumbs down emoji to the message.", + privateMessages = false + ) + + public void onCommand(DiscordApi api, ServerTextChannel serverTextChannel, Message message, User author, Server server) { + SentryLog.addContext(null, author, server); + + message.addReactions(EmojiParser.parseToUnicode(":thumbsup:"), EmojiParser.parseToUnicode(":thumbsdown:"), EmojiParser.parseToUnicode(":shrug:")); + + Sentry.clearContext(); + } +} diff --git a/src/main/java/com/mazawrath/beanbot/commands/poll/StrawPollCommand.java b/src/main/java/com/mazawrath/beanbot/commands/poll/StrawPollCommand.java new file mode 100644 index 0000000..2f3ed73 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/commands/poll/StrawPollCommand.java @@ -0,0 +1,113 @@ +package com.mazawrath.beanbot.commands.poll; + +import com.mazawrath.beanbot.utilities.Points; +import com.mazawrath.beanbot.utilities.SentryLog; +import com.samuelmaddock.strawpollwrapper.StrawPoll; +import de.btobastian.sdcf4j.Command; +import de.btobastian.sdcf4j.CommandExecutor; +import io.sentry.Sentry; +import org.javacord.api.DiscordApi; +import org.javacord.api.entity.channel.ServerTextChannel; +import org.javacord.api.entity.server.Server; +import org.javacord.api.entity.user.User; + +import java.util.ArrayList; +import java.util.List; + +public class StrawPollCommand implements CommandExecutor { + private Points points; + + public StrawPollCommand(Points points) { + this.points = points; + } + + @Command( + aliases = {"strawpoll"}, + usage = "strawpoll", + privateMessages = false, + async = true + ) + + public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server) { + SentryLog.addContext(args, author, server); + + StringBuilder question = new StringBuilder(); + List options = new ArrayList<>(); + boolean isMulti = false; + int i = 0; + + if (args[i].toLowerCase().equals("m")) { + isMulti = true; + i++; + } + + for (; i < args.length; i++) { + if (args[i].equals("|")) { + i++; + break; + } + if (args[i].startsWith("|") && args[i].endsWith("|")) { + break; + } if (args[i].startsWith("|")) { + break; + } + if (args[i].endsWith("|")) { + question.append(args[i], 0, args[i].length() - 1).append(" "); + i++; + break; + } + question.append(args[i]).append(" "); + } + + int k = i; + while (k < args.length) { + StringBuilder option = new StringBuilder(); + while (k < args.length) { + if (args[k].equals("|")) { + k++; + break; + } else if (args[k].startsWith("|") && args[k].endsWith("|")) { + if (option.toString().isEmpty()) { + option.append(args[k], 1, args[k].length() - 1).append(" "); + k++; + break; + } else + break; + } else if (args[k].startsWith("|")) + if (option.toString().isEmpty()) { + option.append(args[k], 1, args[k].length()).append(" "); + } else + break; + else if (args[k].endsWith("|")) { + option.append(args[k], 0, args[k].length() - 1).append(" "); + k++; + break; + } else + option.append(args[k]).append(" "); + k++; + } + System.out.println(option.toString()); + options.add(option.toString()); + } + + if (options.size() < 2) { + serverTextChannel.sendMessage("You must have at least two options. Options are separated by `|`\n" + + "`.strawpoll Question | Option 1 | Option 2 | Option 3`\n" + + "If you would like to be able to select multiple options, put a `m` before your question\n" + + "`.strawpoll m Question | Option 1 | Option 2 | Option 3`"); + return; + } + if (options.size() > 30) { + serverTextChannel.sendMessage("There is a maximum of 30 options for one poll."); + return; + } + + StrawPoll strawPoll = new StrawPoll(question.toString(), options) + .setIsMulti(isMulti); + strawPoll.create(); + + serverTextChannel.sendMessage("Strawpoll created: " + strawPoll.getPollURL()); + + Sentry.clearContext(); + } +} diff --git a/src/main/java/com/mazawrath/beanbot/utilities/GoogleCloudVision.java b/src/main/java/com/mazawrath/beanbot/utilities/GoogleCloudVision.java index 5608656..95e3421 100644 --- a/src/main/java/com/mazawrath/beanbot/utilities/GoogleCloudVision.java +++ b/src/main/java/com/mazawrath/beanbot/utilities/GoogleCloudVision.java @@ -13,12 +13,7 @@ import java.util.List; import java.util.Objects; -public class GoogleCloudVision { - - public GoogleCloudVision() { - System.setProperty("http.agent", "Chrome"); - } - +class GoogleCloudVision { List getLabelDetection(URL image) { try (ImageAnnotatorClient vision = ImageAnnotatorClient.create()) { diff --git a/src/main/java/com/mazawrath/beanbot/utilities/Lottery.java b/src/main/java/com/mazawrath/beanbot/utilities/Lottery.java index d3f16f7..af3bfae 100644 --- a/src/main/java/com/mazawrath/beanbot/utilities/Lottery.java +++ b/src/main/java/com/mazawrath/beanbot/utilities/Lottery.java @@ -20,8 +20,10 @@ public class Lottery { public static final int AMOUNT_DRAWN = 3; public static final int MIN_NUMBER = 1; public static final int MAX_NUMBER = 20; - public static final int MAX_TICKETS = 200; + public static final int STARTING_TICKET_AMOUNT = 100; + public static final int ADD_AFTER_DRAWING = 50; private static final String DB_NAME = "beanBotLottery"; + private static final String MAX_TICKETS_TABLE = "maxTickets"; private Connection conn; @@ -35,13 +37,18 @@ private void checkTable(Connection conn) { if (r.dbList().contains(DB_NAME).run(conn)) { } else { r.dbCreate(DB_NAME).run(conn); + r.db(DB_NAME).tableCreate(MAX_TICKETS_TABLE).run(conn); } } private void checkServer(String serverId) { if (r.db(DB_NAME).tableList().contains(serverId).run(conn)) { - } else + } else { r.db(DB_NAME).tableCreate(serverId).run(conn); + r.db(DB_NAME).table(MAX_TICKETS_TABLE).insert(r.array( + r.hashMap("id", serverId) + .with("MaxTickets", STARTING_TICKET_AMOUNT))).run(conn); + } } private void checkUser(String userId, String serverId) { @@ -54,10 +61,14 @@ private void checkUser(String userId, String serverId) { .with("TicketCount", 0))).run(conn); } + public long getMaxTickets(String serverId) { + return r.db(DB_NAME).table(MAX_TICKETS_TABLE).get(serverId).getField("MaxTickets").run(conn); + } + public boolean canBuyTickets(String userId, String serverId, int amount) { checkUser(userId, serverId); - return getTicketCount(userId, serverId) + amount <= 200; + return getTicketCount(userId, serverId) + amount <= getMaxTickets(serverId); } public long getTicketCount(String userId, String serverId) { @@ -66,8 +77,9 @@ public long getTicketCount(String userId, String serverId) { return r.db(DB_NAME).table(serverId).get(userId).getField("TicketCount").run(conn); } - public void clearTickets(String serverId) { - r.db(DB_NAME).table(serverId).delete().run(conn); + private void clearTickets(String serverId) { + r.db(DB_NAME).tableDrop(serverId).delete().run(conn); + r.db(DB_NAME).table(MAX_TICKETS_TABLE).get(serverId).delete().run(conn); } public ArrayList> addEntry(String userId, String serverId, int amount) { @@ -102,6 +114,8 @@ public void addEntry(String userId, String serverId, int[] numbers) { } public ArrayList getWinner(String serverId, int[] winningNumbers) { + checkServer(serverId); + ArrayList ticket = new ArrayList<>(); for (int i = 0; i < winningNumbers.length; i++) @@ -152,6 +166,8 @@ public void run() { } public void drawNumbers(Points points, Server server, DiscordApi api, ServerTextChannel serverTextChannel) { + checkServer(server.getIdAsString()); + int[] winningNumbers = generateNumbers(); ArrayList winners = getWinner(server.getIdAsString(), winningNumbers); @@ -161,9 +177,10 @@ public void drawNumbers(Points points, Server server, DiscordApi api, ServerText for (int i = 0; i < winningNumbers.length; i++) message.append(winningNumbers[i] + " "); message.append("\n"); - if (winners.size() == 0) - message.append("No one has won. All bean lottery tickets have been saved until the next drawing."); - else { + if (winners.size() == 0) { + message.append("No one has won. Everyone can now buy " + ADD_AFTER_DRAWING + " more tickets. All bean lottery tickets have been saved until the next drawing."); + r.db(DB_NAME).table(MAX_TICKETS_TABLE).get(server.getIdAsString()).update(r.hashMap("MaxTickets", getMaxTickets(server.getIdAsString()) + ADD_AFTER_DRAWING)).run(conn); + } else { BigDecimal prizePool = points.getBalance(api.getYourself().getIdAsString(), server.getIdAsString()); BigDecimal amountWon = prizePool.divide(new BigDecimal(winners.size())).setScale(Points.SCALE, Points.ROUNDING_MODE); points.removePoints(api.getYourself().getIdAsString(), null, server.getIdAsString(), points.getBalance(api.getYourself().getIdAsString(), server.getIdAsString())); diff --git a/src/main/java/com/mazawrath/beanbot/utilities/photo/MarvinRequest.java b/src/main/java/com/mazawrath/beanbot/utilities/photo/MarvinRequest.java new file mode 100644 index 0000000..f2fdfc0 --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/utilities/photo/MarvinRequest.java @@ -0,0 +1,115 @@ +package com.mazawrath.beanbot.utilities.photo; + +import marvin.MarvinPluginCollection; +import marvin.image.MarvinImage; +import marvin.image.MarvinImageMask; +import org.apache.commons.io.IOUtils; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; + +public class MarvinRequest { + private MarvinImage image; + + public MarvinRequest(URL url) throws IOException { + image = new MarvinImage(ImageIO.read(new ByteArrayInputStream(downloadFile(url)))); + } + + public File getDeepFry() throws IOException { + int pixelValue = image.getHeight() * image.getWidth() ; + MarvinPluginCollection.pixelize(image, image, 1); + MarvinPluginCollection.brightnessAndContrast(image, 0, 140); + MarvinPluginCollection.colorChannel(image, 100, 10, 10); + image.update(); + + File output = new File(".\\ext\\out\\deepfry.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + public File getEmboss() throws IOException { + MarvinPluginCollection.emboss(image, image); + image.update(); + + File output = new File(".\\ext\\out\\emboss.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + public File getInvert() throws IOException { + MarvinPluginCollection.invertColors(image); + image.update(); + + File output = new File(".\\ext\\out\\invert.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + public File getEdges() throws IOException { + MarvinPluginCollection.sobel(image,image); + image.update(); + + File output = new File(".\\ext\\out\\edge.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + public File getErrorDiffusion() throws IOException { + MarvinPluginCollection.halftoneErrorDiffusion(image,image); + image.update(); + + File output = new File(".\\ext\\out\\errorTone.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + public File getMosaic() throws IOException { + MarvinPluginCollection.mosaic(image,image, "triangles", 10, true); + image.update(); + + File output = new File(".\\ext\\out\\mosaic.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + public File getSepia() throws IOException { + MarvinPluginCollection.sepia(image, 100); + image.update(); + + File output = new File(".\\ext\\out\\sepia.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + public File getHistogram() throws IOException { + MarvinPluginCollection.histogramEqualization(image, image); + image.update(); + + File output = new File(".\\ext\\out\\histogram.png"); + ImageIO.write(image.getBufferedImage(), "png", output); + return output; + } + + private static byte[] downloadFile(URL url) { + try { + URLConnection conn = url.openConnection(); + conn.setConnectTimeout(5000); + conn.setReadTimeout(5000); + conn.connect(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + IOUtils.copy(conn.getInputStream(), baos); + + return baos.toByteArray(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/main/java/com/mazawrath/beanbot/utilities/photo/MergeRequest.java b/src/main/java/com/mazawrath/beanbot/utilities/photo/MergeRequest.java new file mode 100644 index 0000000..784b71f --- /dev/null +++ b/src/main/java/com/mazawrath/beanbot/utilities/photo/MergeRequest.java @@ -0,0 +1,54 @@ +package com.mazawrath.beanbot.utilities.photo; + +import marvin.MarvinPluginCollection; +import marvin.image.MarvinImage; +import marvin.plugin.MarvinImagePlugin; +import marvin.util.MarvinPluginLoader; +import org.apache.commons.io.IOUtils; + +import javax.imageio.ImageIO; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; + +public class MergeRequest { + private List images = new ArrayList<>(); + + public MergeRequest(URL[] url) throws IOException { + for (URL url1 : url) + images.add(new MarvinImage(ImageIO.read(new ByteArrayInputStream(downloadFile(url1))))); + } + + public File getMerge() throws IOException { + MarvinImage marvinOutput = new MarvinImage(); + MarvinPluginCollection.mergePhotos(images, marvinOutput, 38); + + marvinOutput.update(); + File output = new File("merge.png"); + ImageIO.write(marvinOutput.getBufferedImage(), "png", output); + return output; + } + + private static byte[] downloadFile(URL url) { + try { + URLConnection conn = url.openConnection(); + conn.addRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0"); + conn.setConnectTimeout(5000); + conn.setReadTimeout(5000); + conn.connect(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + IOUtils.copy(conn.getInputStream(), baos); + + return baos.toByteArray(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } +}