refactored everything and moved the project into a Maven project, that can be built easily, and removed a json call that was deprecated
This commit is contained in:
parent
b0e6f33b87
commit
a3f4c5688a
30
.gitignore
vendored
30
.gitignore
vendored
@ -1,27 +1,3 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/twitter_techsupportgore_bot/nbproject/private/
|
||||
/twitter_techsupportgore_bot/build/
|
||||
/twitter_techsupportgore_bot/dist/
|
||||
*.sqlite
|
||||
*.iml
|
||||
.idea/
|
||||
target/
|
@ -1,18 +1,20 @@
|
||||
################################################################################
|
||||
# REDDIT SETTINGS #
|
||||
################################################################################
|
||||
subreddit=techsupportgore
|
||||
delay=30
|
||||
sqlite_db_name=techsupportgore_twitterbot
|
||||
clear_database=N
|
||||
reddit_posts_limit=1
|
||||
reddit_posts_sorting_order=new
|
||||
# What comes after /r/ (ex: softwaregore)
|
||||
subreddit=
|
||||
# delay (in seconds) between two scans. (ex: 60)
|
||||
delay=
|
||||
sqlite_db_name=
|
||||
clear_database=
|
||||
reddit_posts_limit=
|
||||
reddit_posts_sorting_order=
|
||||
|
||||
################################################################################
|
||||
# MISCELLANEOUS SETTINGS #
|
||||
################################################################################
|
||||
working_directory=data
|
||||
max_text_length=280
|
||||
working_directory=
|
||||
max_text_length=
|
||||
|
||||
################################################################################
|
||||
# TWITTER API SETTINGS #
|
68
pom.xml
Normal file
68
pom.xml
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>RedditReposterBot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- Build an executable JAR -->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<mainClass>xyz.vallat.louis.RedditReposterBot</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<!-- bind to the packaging phase -->
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.twitter4j</groupId>
|
||||
<artifactId>twitter4j-core</artifactId>
|
||||
<version>4.0.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.30.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,73 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="RedditReposterBot" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project RedditReposterBot.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar: JAR building
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="RedditReposterBot-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
@ -1,4 +0,0 @@
|
||||
#Tue, 06 Aug 2019 11:12:49 +0200
|
||||
|
||||
|
||||
C\:\\Users\\louis\\Documents\\GitHub\\twitter_techsupportgore_bot\\reddit_reposter_bot=
|
32
reddit_reposter_bot/dist/README.TXT
vendored
32
reddit_reposter_bot/dist/README.TXT
vendored
@ -1,32 +0,0 @@
|
||||
========================
|
||||
BUILD OUTPUT DESCRIPTION
|
||||
========================
|
||||
|
||||
When you build an Java application project that has a main class, the IDE
|
||||
automatically copies all of the JAR
|
||||
files on the projects classpath to your projects dist/lib folder. The IDE
|
||||
also adds each of the JAR files to the Class-Path element in the application
|
||||
JAR files manifest file (MANIFEST.MF).
|
||||
|
||||
To run the project from the command line, go to the dist folder and
|
||||
type the following:
|
||||
|
||||
java -jar "RedditReposterBot.jar"
|
||||
|
||||
To distribute this project, zip up the dist folder (including the lib folder)
|
||||
and distribute the ZIP file.
|
||||
|
||||
Notes:
|
||||
|
||||
* If two JAR files on the project classpath have the same name, only the first
|
||||
JAR file is copied to the lib folder.
|
||||
* Only JAR files are copied to the lib folder.
|
||||
If the classpath contains other types of files or folders, these files (folders)
|
||||
are not copied.
|
||||
* If a library on the projects classpath also has a Class-Path element
|
||||
specified in the manifest,the content of the Class-Path element has to be on
|
||||
the projects runtime path.
|
||||
* To set a main class in a standard Java project, right-click the project node
|
||||
in the Projects window and choose Properties. Then click Run and enter the
|
||||
class name in the Main Class field. Alternatively, you can manually type the
|
||||
class name in the manifest Main-Class element.
|
@ -1,3 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
X-COMMENT: Main-Class will be added automatically by build
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
||||
build.xml.data.CRC32=9dc9f11e
|
||||
build.xml.script.CRC32=293f3476
|
||||
build.xml.stylesheet.CRC32=8064a381@1.80.1.48
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=9dc9f11e
|
||||
nbproject/build-impl.xml.script.CRC32=69003ede
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
|
@ -1,9 +0,0 @@
|
||||
application.args=helo
|
||||
#
|
||||
#Mon Apr 22 18:09:19 CEST 2019
|
||||
javac.debug=true
|
||||
javadoc.preview=true
|
||||
do.depend=false
|
||||
do.jar=true
|
||||
compile.on.save=false
|
||||
user.properties.file=C\:\\Users\\louis\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
</open-files>
|
||||
</project-private>
|
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||
<properties>
|
||||
<comment/>
|
||||
<entry key="ACTIVATED_FEATURES">#org.netbeans.modules.profiler.v2.features.MonitorFeature@#org.netbeans.modules.profiler.v2.features.ThreadsFeature@#org.netbeans.modules.profiler.v2.features.SQLFeature@</entry>
|
||||
<entry key="SINGLE_FEATURE">false</entry>
|
||||
</properties>
|
@ -1,85 +0,0 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=RedditReposterBot
|
||||
application.vendor=louis
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
build.generated.sources.dir=${build.dir}/generated-sources
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
# Uncomment to specify the preferred debugger connection transport:
|
||||
#debug.transport=dt_socket
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# Files in build.classes.dir which should be excluded from distribution jar
|
||||
dist.archive.excludes=
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/RedditReposterBot.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.gson-2.8.5.jar=C:\\Users\\louis\\Documents\\libraries\\Java\\gson-2.8.5.jar
|
||||
file.reference.kotlin-runtime.jar=nulllib\\kotlin-runtime.jar
|
||||
file.reference.sqlite-jdbc-3.23.1.jar=C:\\Users\\louis\\Documents\\libraries\\Java\\sqlite-jdbc-3.23.1.jar
|
||||
file.reference.twitter4j-core-4.0.7.jar=C:\\Users\\louis\\Documents\\libraries\\Java\\twitter4j-core-4.0.7.jar
|
||||
includes=**
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.gson-2.8.5.jar}:\
|
||||
${file.reference.twitter4j-core-4.0.7.jar}:\
|
||||
${file.reference.sqlite-jdbc-3.23.1.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=-Xlint:unchecked
|
||||
javac.deprecation=false
|
||||
javac.external.vm=true
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.8
|
||||
javac.target=1.8
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
kotlinc.classpath=${file.reference.kotlin-runtime.jar}
|
||||
main.class=RedditReposterBot.RedditReposterBot
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
platform.active=default_platform
|
||||
project.license=gpl30
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project.
|
||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
||||
# To set system properties for unit tests define test-sys-prop.name=value:
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
source.encoding=UTF-8
|
||||
src.dir=src
|
||||
test.src.dir=test
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>RedditReposterBot</name>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
10
reddit_reposter_bot/src/RedditReposterBot/ConfigFileReader.java → src/main/java/xyz.vallat.louis/ConfigFileReader.java
Normal file → Executable file
10
reddit_reposter_bot/src/RedditReposterBot/ConfigFileReader.java → src/main/java/xyz.vallat.louis/ConfigFileReader.java
Normal file → Executable file
@ -14,11 +14,11 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot;
|
||||
package xyz.vallat.louis;
|
||||
|
||||
import RedditReposterBot.exceptions.NoSuchFile;
|
||||
import RedditReposterBot.exceptions.NotSufficientRights;
|
||||
import RedditReposterBot.exceptions.NoSuchProperty;
|
||||
import xyz.vallat.louis.exceptions.NoSuchFile;
|
||||
import xyz.vallat.louis.exceptions.NotSufficientRights;
|
||||
import xyz.vallat.louis.exceptions.NoSuchProperty;
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
import java.io.FileInputStream;
|
||||
@ -34,7 +34,7 @@ public final class ConfigFileReader {
|
||||
/**
|
||||
* The config file name.
|
||||
*/
|
||||
private static String CONFIGFILE = "settings.conf";
|
||||
private static String CONFIGFILE = "data/settings.conf";
|
||||
|
||||
/**
|
||||
* The properties object.
|
38
reddit_reposter_bot/src/RedditReposterBot/Hypervisor.java → src/main/java/xyz.vallat.louis/Hypervisor.java
Normal file → Executable file
38
reddit_reposter_bot/src/RedditReposterBot/Hypervisor.java → src/main/java/xyz.vallat.louis/Hypervisor.java
Normal file → Executable file
@ -14,15 +14,15 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot;
|
||||
package xyz.vallat.louis;
|
||||
|
||||
import RedditReposterBot.socialMediaHandler.SocialMediaPoster;
|
||||
import RedditReposterBot.redditHandler.RedditExtractor;
|
||||
import RedditReposterBot.exceptions.NoSuchFile;
|
||||
import RedditReposterBot.exceptions.NoSuchOrder;
|
||||
import RedditReposterBot.exceptions.NotSufficientRights;
|
||||
import RedditReposterBot.exceptions.NoSuchProperty;
|
||||
import RedditReposterBot.redditHandler.RedditPost;
|
||||
import xyz.vallat.louis.socialMediaHandler.SocialMediaPoster;
|
||||
import xyz.vallat.louis.redditHandler.RedditExtractor;
|
||||
import xyz.vallat.louis.exceptions.NoSuchFile;
|
||||
import xyz.vallat.louis.exceptions.NoSuchOrder;
|
||||
import xyz.vallat.louis.exceptions.NotSufficientRights;
|
||||
import xyz.vallat.louis.exceptions.NoSuchProperty;
|
||||
import xyz.vallat.louis.redditHandler.RedditPost;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -128,13 +128,13 @@ public class Hypervisor {
|
||||
*
|
||||
* @return the instance.
|
||||
*
|
||||
* @throws java.lang.ClassNotFoundException
|
||||
* @throws RedditReposterBot.exceptions.NotSufficientRights
|
||||
* @throws java.sql.SQLException
|
||||
* @throws java.io.IOException
|
||||
* @throws RedditReposterBot.exceptions.NoSuchFile
|
||||
* @throws RedditReposterBot.exceptions.NoSuchProperty
|
||||
* @throws RedditReposterBot.exceptions.NoSuchOrder
|
||||
* @throws ClassNotFoundException
|
||||
* @throws NotSufficientRights
|
||||
* @throws SQLException
|
||||
* @throws IOException
|
||||
* @throws NoSuchFile
|
||||
* @throws NoSuchProperty
|
||||
* @throws NoSuchOrder
|
||||
*/
|
||||
public static Hypervisor getSingleton()
|
||||
throws ClassNotFoundException, NotSufficientRights,
|
||||
@ -148,9 +148,9 @@ public class Hypervisor {
|
||||
/**
|
||||
* Main loop for the program. This is where everything happens.
|
||||
*
|
||||
* @throws java.lang.ClassNotFoundException
|
||||
* @throws java.sql.SQLException
|
||||
* @throws java.lang.InterruptedException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws SQLException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void run()
|
||||
throws ClassNotFoundException, SQLException,
|
||||
@ -399,7 +399,7 @@ public class Hypervisor {
|
||||
* Set working directory.
|
||||
*
|
||||
* @param tempDir the path to the working directory.
|
||||
* @throws RedditReposterBot.exceptions.NotSufficientRights
|
||||
* @throws NotSufficientRights
|
||||
*/
|
||||
public void setWorkDir(String tempDir) throws NotSufficientRights {
|
||||
this.workingDirectory = tempDir;
|
12
reddit_reposter_bot/src/RedditReposterBot/RedditReposterBot.java → src/main/java/xyz.vallat.louis/RedditReposterBot.java
Normal file → Executable file
12
reddit_reposter_bot/src/RedditReposterBot/RedditReposterBot.java → src/main/java/xyz.vallat.louis/RedditReposterBot.java
Normal file → Executable file
@ -14,13 +14,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot;
|
||||
package xyz.vallat.louis;
|
||||
|
||||
import RedditReposterBot.socialMediaHandler.TwitterBot;
|
||||
import RedditReposterBot.exceptions.NoSuchFile;
|
||||
import RedditReposterBot.exceptions.NoSuchOrder;
|
||||
import RedditReposterBot.exceptions.NoSuchProperty;
|
||||
import RedditReposterBot.exceptions.NotSufficientRights;
|
||||
import xyz.vallat.louis.socialMediaHandler.TwitterBot;
|
||||
import xyz.vallat.louis.exceptions.NoSuchFile;
|
||||
import xyz.vallat.louis.exceptions.NoSuchOrder;
|
||||
import xyz.vallat.louis.exceptions.NoSuchProperty;
|
||||
import xyz.vallat.louis.exceptions.NotSufficientRights;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
2
reddit_reposter_bot/src/RedditReposterBot/exceptions/NoSuchFile.java → src/main/java/xyz.vallat.louis/exceptions/NoSuchFile.java
Normal file → Executable file
2
reddit_reposter_bot/src/RedditReposterBot/exceptions/NoSuchFile.java → src/main/java/xyz.vallat.louis/exceptions/NoSuchFile.java
Normal file → Executable file
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.exceptions;
|
||||
package xyz.vallat.louis.exceptions;
|
||||
|
||||
/**
|
||||
* Exception throwable when there are no file at a given path.
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.exceptions;
|
||||
package xyz.vallat.louis.exceptions;
|
||||
|
||||
/**
|
||||
* Exception throwable when a sort order isn't a correct one.
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.exceptions;
|
||||
package xyz.vallat.louis.exceptions;
|
||||
|
||||
/**
|
||||
* Exception throwable when there are no property in the config file for a given
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.exceptions;
|
||||
package xyz.vallat.louis.exceptions;
|
||||
|
||||
/**
|
||||
* Exception throwable when the rights on a folder or a file aren't sufficient.
|
@ -14,16 +14,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.redditHandler;
|
||||
package xyz.vallat.louis.redditHandler;
|
||||
|
||||
import com.google.gson.*;
|
||||
import xyz.vallat.louis.exceptions.NoSuchFile;
|
||||
import xyz.vallat.louis.exceptions.NoSuchOrder;
|
||||
import xyz.vallat.louis.exceptions.NoSuchProperty;
|
||||
import xyz.vallat.louis.exceptions.NotSufficientRights;
|
||||
|
||||
import RedditReposterBot.exceptions.NoSuchFile;
|
||||
import RedditReposterBot.exceptions.NoSuchOrder;
|
||||
import RedditReposterBot.exceptions.NoSuchProperty;
|
||||
import RedditReposterBot.exceptions.NotSufficientRights;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -50,9 +48,9 @@ public final class RedditExtractor {
|
||||
* @param subreddit Subreddit name. Just after /r/
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RedditReposterBot.exceptions.NoSuchProperty
|
||||
* @throws RedditReposterBot.exceptions.NoSuchFile
|
||||
* @throws RedditReposterBot.exceptions.NotSufficientRights
|
||||
* @throws NoSuchProperty
|
||||
* @throws NoSuchFile
|
||||
* @throws NotSufficientRights
|
||||
* @throws NoSuchOrder
|
||||
*/
|
||||
public RedditExtractor(String subreddit)
|
||||
@ -75,11 +73,10 @@ public final class RedditExtractor {
|
||||
public boolean doesSubredditExists(String subredditName) {
|
||||
System.out.println("[*] Checking if subreddit /r/" + subredditName
|
||||
+ " exists.");
|
||||
return ((new JsonParser()
|
||||
.parse(getJsonFromURL(""
|
||||
return ((JsonParser.parseString(getJsonFromURL(""
|
||||
+ "https://www.reddit.com/api/search_reddit_names.json"
|
||||
+ "?query=" + subredditName + "&exact=true"))
|
||||
.getAsJsonObject().get("names").getAsJsonArray()
|
||||
+ "?query=" + subredditName + "&exact=true")).getAsJsonObject()
|
||||
.get("names").getAsJsonArray()
|
||||
.size()) >= 1);
|
||||
}
|
||||
|
||||
@ -138,17 +135,17 @@ public final class RedditExtractor {
|
||||
try {
|
||||
HashSet<RedditPost> set = new HashSet<>();
|
||||
String jsonResponse = getSubredditJson();
|
||||
JsonObject objet = new JsonParser().parse(jsonResponse)
|
||||
JsonObject objet = JsonParser.parseString(jsonResponse)
|
||||
.getAsJsonObject();
|
||||
JsonObject data = new JsonParser().parse(objet.get("data")
|
||||
JsonObject data = JsonParser.parseString(objet.get("data")
|
||||
.toString()).getAsJsonObject();
|
||||
JsonArray children = new JsonParser().parse(data.get("children")
|
||||
JsonArray children = JsonParser.parseString(data.get("children")
|
||||
.toString()).getAsJsonArray();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
try {
|
||||
JsonObject child = new JsonParser().parse(children.get(i)
|
||||
JsonObject child = JsonParser.parseString(children.get(i)
|
||||
.toString()).getAsJsonObject();
|
||||
JsonObject childData = new JsonParser().parse(child.get("data")
|
||||
JsonObject childData = JsonParser.parseString(child.get("data")
|
||||
.toString()).getAsJsonObject();
|
||||
if (childData.get("id").toString() != null
|
||||
&& !childData.get("quarantine").getAsBoolean()
|
||||
@ -178,13 +175,13 @@ public final class RedditExtractor {
|
||||
boolean over18 = childData.get("over_18").getAsBoolean();
|
||||
String url;
|
||||
try {
|
||||
JsonObject preview = new JsonParser().parse(childData
|
||||
JsonObject preview = JsonParser.parseString(childData
|
||||
.get("preview").toString()).getAsJsonObject();
|
||||
JsonArray previewImages = new JsonParser().parse(preview
|
||||
JsonArray previewImages = JsonParser.parseString(preview
|
||||
.get("images").toString()).getAsJsonArray();
|
||||
JsonObject source = new JsonParser().parse(previewImages
|
||||
JsonObject source = JsonParser.parseString(previewImages
|
||||
.get(0).toString()).getAsJsonObject();
|
||||
JsonObject urlSrc = new JsonParser().parse(source
|
||||
JsonObject urlSrc = JsonParser.parseString(source
|
||||
.get("source").toString()).getAsJsonObject();
|
||||
url = urlSrc.get("url").toString().replace("&", "&")
|
||||
.replace("\"", "");
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.redditHandler;
|
||||
package xyz.vallat.louis.redditHandler;
|
||||
|
||||
/**
|
||||
* This is an abstract class to define all RedditPosts.
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.redditHandler;
|
||||
package xyz.vallat.louis.redditHandler;
|
||||
|
||||
/**
|
||||
* Reddit image post object representation.
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.redditHandler;
|
||||
package xyz.vallat.louis.redditHandler;
|
||||
|
||||
/**
|
||||
* Reddit link post object representation.
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.redditHandler;
|
||||
package xyz.vallat.louis.redditHandler;
|
||||
|
||||
/**
|
||||
* Reddit text post object representation.
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.redditHandler;
|
||||
package xyz.vallat.louis.redditHandler;
|
||||
|
||||
/**
|
||||
* Reddit video post object representation.
|
20
reddit_reposter_bot/src/RedditReposterBot/redditHandler/SubReddit.java → src/main/java/xyz.vallat.louis/redditHandler/SubReddit.java
Normal file → Executable file
20
reddit_reposter_bot/src/RedditReposterBot/redditHandler/SubReddit.java → src/main/java/xyz.vallat.louis/redditHandler/SubReddit.java
Normal file → Executable file
@ -14,13 +14,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.redditHandler;
|
||||
package xyz.vallat.louis.redditHandler;
|
||||
|
||||
import RedditReposterBot.ConfigFileReader;
|
||||
import RedditReposterBot.exceptions.NoSuchFile;
|
||||
import RedditReposterBot.exceptions.NoSuchOrder;
|
||||
import RedditReposterBot.exceptions.NoSuchProperty;
|
||||
import RedditReposterBot.exceptions.NotSufficientRights;
|
||||
import xyz.vallat.louis.ConfigFileReader;
|
||||
import xyz.vallat.louis.exceptions.NoSuchFile;
|
||||
import xyz.vallat.louis.exceptions.NoSuchOrder;
|
||||
import xyz.vallat.louis.exceptions.NoSuchProperty;
|
||||
import xyz.vallat.louis.exceptions.NotSufficientRights;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -60,10 +60,10 @@ public final class SubReddit {
|
||||
*
|
||||
* @param name subreddit's name
|
||||
*
|
||||
* @throws RedditReposterBot.exceptions.NoSuchProperty
|
||||
* @throws RedditReposterBot.exceptions.NoSuchFile
|
||||
* @throws RedditReposterBot.exceptions.NotSufficientRights
|
||||
* @throws RedditReposterBot.exceptions.NoSuchOrder
|
||||
* @throws NoSuchProperty
|
||||
* @throws NoSuchFile
|
||||
* @throws NotSufficientRights
|
||||
* @throws NoSuchOrder
|
||||
*/
|
||||
public SubReddit(String name) throws NoSuchProperty, NoSuchFile,
|
||||
NotSufficientRights, NoSuchOrder {
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.socialMediaHandler;
|
||||
package xyz.vallat.louis.socialMediaHandler;
|
||||
|
||||
/**
|
||||
* Interface to specify what methods should social media posters implement.
|
@ -14,12 +14,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package RedditReposterBot.socialMediaHandler;
|
||||
package xyz.vallat.louis.socialMediaHandler;
|
||||
|
||||
import RedditReposterBot.exceptions.NotSufficientRights;
|
||||
import RedditReposterBot.exceptions.NoSuchProperty;
|
||||
import RedditReposterBot.ConfigFileReader;
|
||||
import RedditReposterBot.exceptions.NoSuchFile;
|
||||
import xyz.vallat.louis.exceptions.NotSufficientRights;
|
||||
import xyz.vallat.louis.exceptions.NoSuchProperty;
|
||||
import xyz.vallat.louis.ConfigFileReader;
|
||||
import xyz.vallat.louis.exceptions.NoSuchFile;
|
||||
import java.io.File;
|
||||
import twitter4j.StatusUpdate;
|
||||
import twitter4j.Twitter;
|
Loading…
Reference in New Issue
Block a user