Skip to content

Commit

Permalink
Refactor MessageList to use getter/setters
Browse files Browse the repository at this point in the history
  • Loading branch information
bglasber committed Oct 19, 2013
1 parent 29035dc commit 0d77d2f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
28 changes: 27 additions & 1 deletion Skypebot/src/main/java/skypebot/engine/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Engine {
private static ExecutorService executor;
private static Logger logger = Logger.getLogger( Engine.class.getCanonicalName() );
private static DbManager dbManager;
public static MessageList messageList;
private static MessageList messageList;

public Engine() {
dbManager = createDbManager();
Expand Down Expand Up @@ -154,4 +154,30 @@ private int getNumberOfCores() {
return cores;
}

public static void AddToMessageList( ChatMessage m ) {
messageList.Put( m );
}

public static void AddToMessageList(
String person,
String message
) {
messageList.Put(
person,
message
);
}

public static String GetQuotableMessage(
String person,
String textToMatch,
int numMessages
) {
return messageList.GetMessageToQuote(
person,
textToMatch,
numMessages
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void handle( ChatMessage m ) {
name
);
logger.debug( "Found Real Name: " + realName );
String message = Engine.messageList.GetMessageToQuote(
String message = Engine.GetQuotableMessage(
realName,
text,
Integer.parseInt( num )
Expand Down
4 changes: 2 additions & 2 deletions Skypebot/src/main/java/skypebot/handlers/ResponseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ else if( m.getContent().contains( "bucket, what was that" ) ) {
return;
}
logger.trace( "Putting the message into the message list" );
Engine.messageList.Put( m );
Engine.AddToMessageList( m );

//Gives us a number between 0.0 and 1.0, this should give us 35% chance of not responding
boolean referencedOverride = m.getContent().contains( "bucket" ) || m.getContent().contains( "Bucket" );
Expand Down Expand Up @@ -98,7 +98,7 @@ else if( m.getContent().contains( "bucket, what was that" ) ) {
m.getChat(),
response[ 1 ]
);
Engine.messageList.Put(
Engine.AddToMessageList(
"Bucket",
messageResponse
);
Expand Down

0 comments on commit 0d77d2f

Please sign in to comment.