Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first commit to User.Java #19

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/nyc/c4q/ramonaharrison/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import nyc.c4q.ramonaharrison.network.*;
import nyc.c4q.ramonaharrison.network.response.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* Created by Ramona Harrison
Expand All @@ -16,6 +18,8 @@
public class Bot {
// TODO: implement your bot logic!

ArrayList<String> inspirationQuotes = new ArrayList<>();

public Bot() {

}
Expand Down Expand Up @@ -82,6 +86,7 @@ public void sendMessageToBotsChannel(String text) {
} else {
System.err.print("Error sending message: " + sendMessageResponse.getError());
}

}

/**
Expand All @@ -98,4 +103,61 @@ public void deleteMessageInBotsChannel(String messageTs) {
System.err.print("Error sending message: " + deleteMessageResponse.getError());
}
}

public String randomQuote() {
inspirationQuotes.add("If you have the opportunity to play this game of life \n " +
"you need to appreciate every moment. \n" +
"A lot of people don't appreciate the moment until it's passed.\n" +
"-Kanye West");
inspirationQuotes.add("Do not dwell in the past, do not dream of the future.\n" +
"Concentrate the mind on the present moment\n" +
"-Buddha");
inspirationQuotes.add("Try to be a rainbow in someone's cloud\n -Maya Angelou");
inspirationQuotes.add("Sometimes when you innovate, you make mistakes.\n" +
"It is best to admit them quickly, and get on with improving your other innovations\n" +
"-Steve Jobs");
inspirationQuotes.add("People say nothing is impossible, but I do nothing everyday.\n" +
"-A.A. Milne");
inspirationQuotes.add("A diamond is merely a lump of coal that did well under pressure\n" +
"-Unknown");
inspirationQuotes.add("No one can make you feel inferior without your consent\n" +
"-Eleanor Roosevelt");
inspirationQuotes.add("Believe you can and you're halfway there\n" +
"-T. Roosevelt");
inspirationQuotes.add("Don't sweat the petty things and don't pet the sweaty things.\n" +
"-George Carlin");
inspirationQuotes.add("There isn't a way things should be. There's just what happens and what we do.\n" +
"-Terry Pratchett");
inspirationQuotes.add("More fuck yeah, less fuck that.\n" +
"-Unknown");
inspirationQuotes.add("Turn your wounds into wisdom\n" +
"-Oprah");
inspirationQuotes.add("Hope is a waking dream\n" +
"-Aristotle");
inspirationQuotes.add("Life is trying things to see if they work\n" +
"-Ray Bradbury");
inspirationQuotes.add("The obstacle is the path\n" +
"-Unknown");
inspirationQuotes.add("We become what we think about\n" +
"-Earl Nightingale");
inspirationQuotes.add("It does not matter how slowly you go as long as you do not stop\n" +
"-Confucius");
inspirationQuotes.add("A jug fills drop by drop\n" +
"-Buddha");
inspirationQuotes.add("Don't regret the past, just learn from it\n" +
"-Ben Ipock");
inspirationQuotes.add("Action is the foundational key to all success\n" +
"-Pablo Picasso");
inspirationQuotes.add("Whatever you are, be a good one\n" +
"-Abraham Lincoln");


Random r= new Random();


String quote= inspirationQuotes.get(r.nextInt(inspirationQuotes.size()));
return quote;
}


}
11 changes: 9 additions & 2 deletions src/nyc/c4q/ramonaharrison/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@

import nyc.c4q.ramonaharrison.network.Slack;



public class Main {

public static void main(String[] args) {

Bot myBot = new Bot();

myBot.testApi();

myBot.listChannels();


myBot.listMessages(Slack.BOTS_CHANNEL_ID);

myBot.sendMessageToBotsChannel(myBot.randomQuote());
myBot.sendMessageToBotsChannel("Yum yum!");
myBot.sendMessageToBotsChannel("So does this one: <http://www.foo.com|www.foo.com>");


// Post "Hello, world!" to the #bots channel
//myBot.sendMessage("Hello, world!");
myBot.sendMessageToBotsChannel("Testing, Testing");

// Post a pineapple photo to the #bots channel
//myBot.sendMessage("http://weknowyourdreams.com/images/pineapple/pineapple-07.jpg");
Expand Down
155 changes: 129 additions & 26 deletions src/nyc/c4q/ramonaharrison/model/Attachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,132 @@
*
*/

public class Attachment {

// TODO: implement private fields for each of the following attachment JSON keys:
// "fallback"
// "color"
// "pretext"
// "author_name"
// "author_link"
// "author_icon"
// "title"
// "title_link"
// "text"
// "fields"
// "image_url"
// "thumb_url"
// "footer"
// "footer_icon"
// "ts"

public Attachment(JSONObject json) {
// TODO: parse an attachment from the incoming json
}

// TODO add getters to access private fields

}
public class Attachment {
// TODO: implement private fields for each of the following attachment JSON keys:
// “fallback”
private String fallback;
// “color”
private String color;
// “pretext”
private String pretext;
// “author_name”
private String author_name;
// “author_link”
private String author_link;
// “author_icon”
private String author_icon;
// “title”
private String title;
// “title_link”
private String title_link;
// “text”
private String text;
// “fields”
private String fields;
// “image_url”
private String image_url;
// “thumb_url”
private String thumb_url;
// “footer”
private String footer;
// “footer_icon”
private String footer_icon;
// “ts”
private String ts;

public Attachment(JSONObject json) {
// TODO: parse an attachment from the incoming json
if (json.get("fallback") != null) {
this.fallback = (String) json.get("fallback");
}
if (json.get("color") !=null) {
this.color = (String) json.get("color");
}
if (json.get("pretext") != null) {
this.pretext = (String) json.get("pretext");
}
if (json.get("author name")!=null){
this.author_name = (String) json.get("author name");
}
if (json.get("author link")!=null){
this.author_link = (String) json.get("author link");
}
if (json.get("author icon")!=null){
this.author_icon =(String) json.get("author icon");
}
if (json.get("title")!=null){
this.title = (String) json.get ("title");
}
if (json.get("title link")!=null){
this.title_link = (String) json.get ("title link");
}
if (json.get("text")!=null){
this.text = (String) json.get ("text");
}
if (json.get("fields")!=null){
this.fields = (String) json.get ("fields");
}
if (json.get("image url")!=null){
this.image_url = (String) json.get ("image url");
}
if (json.get("thumb url")!=null){
this.thumb_url = (String) json.get ("thumb url");
}
if (json.get("footer")!=null){
this.footer= (String) json.get ("footer");
}
if (json.get("ts")!=null){
this.ts = (String) json.get ("ts");
}
}
// TODO add getters to access private fields
public String getFallback() {
return fallback;
}
public String getColor() {
return color;
}
public String getPretext() {
return pretext;
}
public String getAuthor_name() {
return author_name;
}
public String getAuthor_link() {
return author_link;
}
public String getAuthor_icon() {
return author_icon;
}
public String getTitle() {
return title;
}
public String getTitle_link() {
return title_link;
}
public String getText() {
return text;
}
public String getFields() {
return fields;
}
public String getImage_url() {
return image_url;
}
public String getThumb_url() {
return thumb_url;
}
public String getFooter() {
return footer;
}
public String getFooter_icon() {
return footer_icon;
}
public String getTs() {
return ts;
}
}




Loading