added main skeleton for RedditHandler

This commit is contained in:
Louis Vallat 2019-04-23 11:45:31 +02:00
parent 520a2ee598
commit 769c9d5793
6 changed files with 228 additions and 0 deletions

View File

@ -26,6 +26,8 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import twitter_techsupportgore_bot.reddit_handler.RedditPost;
import twitter_techsupportgore_bot.reddit_handler.RedditPostLink;
/**
* This is where everything begins.
@ -40,12 +42,15 @@ public class Twitter_techsupportgore_bot {
* Launch the bot.
*
* @param args the command line arguments
* @throws java.net.MalformedURLException
* @throws java.net.ProtocolException
*/
public static void main(String[] args) throws MalformedURLException,
ProtocolException, IOException {
String url = "https://www.reddit.com/r/techsupportgore/new.json?limit=75";
/*
try {
URL myurl = new URL(url);
@ -95,5 +100,7 @@ public class Twitter_techsupportgore_bot {
con.disconnect();
}
*/
}
}

View File

@ -0,0 +1,121 @@
/*
* Copyright (C) 2019 louis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 twitter_techsupportgore_bot.reddit_handler;
/**
* This is an abstract class to define all RedditPosts.
*
* @author louis
*/
public abstract class RedditPost {
/**
* Post's title.
*/
protected String title;
/**
* Is the post in quarantine?
*/
protected boolean quarantine;
/**
* Post's score.
*/
protected double score;
/**
* Post's hint.
*/
protected String postHint;
/**
* Is this post crosspostable?
*/
protected boolean crosspostable;
/**
* Is this post NSFW?
*/
protected boolean over18;
/**
* Post's author.
*/
protected String author;
/**
* Post's permalink.
*/
protected String permalink;
/**
* Is this post a spoiler?
*/
protected boolean spoiler;
public RedditPost(String title, boolean quarantine, double score, String postHint, boolean crosspostable, boolean over18, String author, String permalink, boolean spoiler) {
this.title = title;
this.quarantine = quarantine;
this.score = score;
this.postHint = postHint;
this.crosspostable = crosspostable;
this.over18 = over18;
this.author = author;
this.permalink = permalink;
this.spoiler = spoiler;
}
public String getTitle() {
return title;
}
public boolean isQuarantine() {
return quarantine;
}
public double getScore() {
return score;
}
public String getPostHint() {
return postHint;
}
public boolean isCrosspostable() {
return crosspostable;
}
public boolean isOver18() {
return over18;
}
public String getAuthor() {
return author;
}
public String getPermalink() {
return permalink;
}
public boolean isSpoiler() {
return spoiler;
}
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C) 2019 louis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 twitter_techsupportgore_bot.reddit_handler;
/**
*
* @author louis
*/
public class RedditPostImage extends RedditPost {
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C) 2019 louis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 twitter_techsupportgore_bot.reddit_handler;
/**
*
* @author louis
*/
public class RedditPostLink extends RedditPost {
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C) 2019 louis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 twitter_techsupportgore_bot.reddit_handler;
/**
*
* @author louis
*/
public class RedditPostText extends RedditPost {
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C) 2019 louis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 twitter_techsupportgore_bot.reddit_handler;
/**
*
* @author louis
*/
public class RedditPostVideo extends RedditPost{
}