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

Sabug3 #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
187 changes: 160 additions & 27 deletions src/nyc/c4q/ramonaharrison/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import nyc.c4q.ramonaharrison.model.Message;
import nyc.c4q.ramonaharrison.network.*;
import nyc.c4q.ramonaharrison.network.response.*;
import nyc.c4q.ramonaharrison.util.Images;

import java.util.List;
import java.util.Scanner;

/**
* Created by Ramona Harrison
Expand All @@ -14,23 +16,9 @@
*/

public class Bot {
// TODO: implement your bot logic!

public Bot() {

}

/**
* Sample method: tests the Slack API. Prints a message indicating success or failure.
*/
public void testApi() {
Response apiTest = Slack.testApi();
System.out.println("API OK: " +apiTest.isOk() + "\n");
}

/**
* Sample method: prints all public AccessCode3-3 channel names and ids. Prints an error message on failure.
*/
// TODO: implement your bot logic!
public void listChannels() {
ListChannelsResponse listChannelsResponse = Slack.listChannels();

Expand All @@ -45,13 +33,6 @@ public void listChannels() {
System.err.print("Error listing channels: " + listChannelsResponse.getError());
}
}

/**
* Sample method: prints up to the last 100 messages from a given channel. Prints an error message on failure.
* or failure.
*
* @param channelId id of the given channel.
*/
public void listMessages(String channelId) {
ListMessagesResponse listMessagesResponse = Slack.listMessages(channelId);

Expand All @@ -63,17 +44,13 @@ public void listMessages(String channelId) {
System.out.println();
System.out.println("Timestamp: " + message.getTs());
System.out.println("Message: " + message.getText());
System.out.println("User: " +message.getUser());
}
} else {
System.err.print("Error listing messages: " + listMessagesResponse.getError());
}
}

/**
* Sample method: sends a plain text message to the #bots channel. Prints a message indicating success or failure.
*
* @param text message text.
*/
public void sendMessageToBotsChannel(String text) {
SendMessageResponse sendMessageResponse = Slack.sendMessage(text);

Expand All @@ -83,6 +60,162 @@ public void sendMessageToBotsChannel(String text) {
System.err.print("Error sending message: " + sendMessageResponse.getError());
}
}
// public void quiz() {
// Slack.sendMessage("Yo bot channel 'bout to be lit g! You goody?");
//
// while (true) {
//
//
// ListMessagesResponse listMessagesResponse = Slack.listMessages(Slack.BOTS_CHANNEL_ID);
// List<Message> messages = listMessagesResponse.getMessages();
// String firstResponse = messages.get(0).getText();
// String secondResponse = null;
// String thirdResponse = null;
// String fourthResponse = null;
//
// if (firstResponse.toLowerCase().contains("yes") || firstResponse.toLowerCase().contains("y")) {
// sendMessageToBotsChannel("Aight fam, it's gonna go like this- I give you a word, you tell me what it means. You feel me? "
// + "Pick a, b, or c, aight? "
// + "\n1st question: The word is Situationship. As in \"Sounds like you in a situationship\"."
// + "\na)A situation b)Playing at being in a relationship without actually being in one c)A committed relationship");
// ListMessagesResponse listMessagesResponse1 = Slack.listMessages(Slack.BOTS_CHANNEL_ID);
// messages = listMessagesResponse.getMessages();
// secondResponse = messages.get(0).getText();
// }
//
// else {
// break;
// }
//
// if (secondResponse.equalsIgnoreCase("b")) {
// sendMessageToBotsChannel("You got it. Next word, gucci- as in \"What's gucci?\"" +
// "\na)Good b)Bad c)A designer");
// ListMessagesResponse listMessagesResponse2 = Slack.listMessages(Slack.BOTS_CHANNEL_ID);
// messages = listMessagesResponse.getMessages();
// thirdResponse = messages.get(0).getText();
// } else {
// break;
// }
// if (thirdResponse.equalsIgnoreCase("a")) {
// sendMessageToBotsChannel("Another right answer, that's a good look. Aight how 'bout deuces?"
// + "\n a)A fancy way to say the number 2 b)Another way to say peace c)Another way to let someone know IDFWY");
// //answer for deuces
// ListMessagesResponse listMessagesResponse3 = Slack.listMessages(Slack.BOTS_CHANNEL_ID);
// messages = listMessagesResponse.getMessages();
// String fourthResponse = messages.get(0).getText();
// if (fourthResponse.equalsIgnoreCase("b") || fourthResponse.equalsIgnoreCase("c")) {
// sendMessageToBotsChannel("I see you " + "this.getName()" + ". You obviously out in these streets, I'ma make sure I put some respek on your name.");
// sendMessageToBotsChannel(Images.makeImages(4));
// break;
// } else if (fourthResponse.equalsIgnoreCase("a")) {
// sendMessageToBotsChannel("b or c son, it's up to you.");
// sendMessageToBotsChannel(Images.makeImages(3));
// break;
// }
// } else if (thirdResponse.equalsIgnoreCase("b") || thirdResponse.equalsIgnoreCase("c")) {
// sendMessageToBotsChannel("Wrong answer, that's not a good look. It was a.");
// sendMessageToBotsChannel(Images.makeImages(2));
// break;
// } else {
// sendMessageToBotsChannel("Yo, a, b or c only homie.");
// //played yourself gif
// sendMessageToBotsChannel(Images.makeImages(0));
// break;
//
// }
// } else if (secondResponse.equalsIgnoreCase("a") || secondResponse.equalsIgnoreCase("c")) {
// sendMessageToBotsChannel("Good for you, obviously you ain't neva been in one-the answer was b.");
// sendMessageToBotsChannel(Images.makeImages(1));
// break;
// //2nd question
// } else {
// sendMessageToBotsChannel("Yo, a, b or c only homie.");
// sendMessageToBotsChannel(Images.makeImages(0));
// break;
// //post this image: http://giphy.com/gifs/zNXvBiNNcrjDW
// }
//
// } else {
// sendMessageToBotsChannel("Nah son, you 'bout to play so get ready.");
// }
// }
// }








// public Bot() {
//
//
// }

/**
* Sample method: tests the Slack API. Prints a message indicating success or failure.
*/
public void testApi() {
Response apiTest = Slack.testApi();
System.out.println("API OK: " +apiTest.isOk() + "\n");
}

/**
* Sample method: prints all public AccessCode3-3 channel names and ids. Prints an error message on failure.
*/
// public void listChannels() {
// ListChannelsResponse listChannelsResponse = Slack.listChannels();
//
// if (listChannelsResponse.isOk()) {
// List<Channel> channels = listChannelsResponse.getChannels();
//
// System.out.println("\nChannels: ");
// for (Channel channel : channels) {
// System.out.println("name: " + channel.getName() + ", id:" + channel.getId());
// }
// } else {
// System.err.print("Error listing channels: " + listChannelsResponse.getError());
// }
// }

/**
* Sample method: prints up to the last 100 messages from a given channel. Prints an error message on failure.
* or failure.
*
* @param channelId id of the given channel.
*/
// public void listMessages(String channelId) {
// ListMessagesResponse listMessagesResponse = Slack.listMessages(channelId);
//
// if (listMessagesResponse.isOk()) {
// List<Message> messages = listMessagesResponse.getMessages();
//
// System.out.println("\nMessages: ");
// for (Message message : messages) {
// System.out.println();
// System.out.println("Timestamp: " + message.getTs());
// System.out.println("Message: " + message.getText());
// }
// } else {
// System.err.print("Error listing messages: " + listMessagesResponse.getError());
// }
// }

/**
* Sample method: sends a plain text message to the #bots channel. Prints a message indicating success or failure.
*
* @param text message text.
*/
// public void sendMessageToBotsChannel(String text) {
// SendMessageResponse sendMessageResponse = Slack.sendMessage(text);
//
// if (sendMessageResponse.isOk()) {
// System.out.println("Message sent successfully!");
// } else {
// System.err.print("Error sending message: " + sendMessageResponse.getError());
// }
// }

/**
* Sample method: deletes a message from the #bots channel. Prints a message indicating success or failure.
Expand Down
23 changes: 20 additions & 3 deletions src/nyc/c4q/ramonaharrison/Main.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package nyc.c4q.ramonaharrison;

import nyc.c4q.ramonaharrison.network.Slack;
import nyc.c4q.ramonaharrison.util.Quiz;

public class Main {

public static void main(String[] args) {
public static void main(String[] args) throws InterruptedException {

Bot myBot = new Bot();

Expand All @@ -14,11 +15,27 @@ public static void main(String[] args) {

myBot.listMessages(Slack.BOTS_CHANNEL_ID);

// Post "Hello, world!" to the #bots channel
//myBot.sendMessage("Hello, world!");
// myBot.testMethod(Slack.BOTS_CHANNEL_ID);

Quiz.quiz();

myBot.listMessages(Slack.BOTS_CHANNEL_ID);

// Post "Hello, world!" to the #bots channel
// myBot.sendMessageToBotsChannel(quiz());
// Post a pineapple photo to the #bots channel
//myBot.sendMessage("http://weknowyourdreams.com/images/pineapple/pineapple-07.jpg");
//myBot.deleteMessageInBotsChannel("1474086468.000821");
// myBot.deleteMessageInBotsChannel("1474222673.002704");
// myBot.deleteMessageInBotsChannel("1474222733.002711");
// myBot.deleteMessageInBotsChannel("1474223222.002729");
// myBot.deleteMessageInBotsChannel("1474223316.002735");
// myBot.deleteMessageInBotsChannel("1474223811.002831");
// myBot.deleteMessageInBotsChannel("1474223970.002865");





}
}
Loading