-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the newMessage to a different class.
- Loading branch information
1 parent
1cc173e
commit 35e58ff
Showing
3 changed files
with
30 additions
and
17 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/in/bhargavrao/stackoverflow/natty/services/NewMessageHandlerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package in.bhargavrao.stackoverflow.natty.services; | ||
|
||
import org.sobotics.chatexchange.chat.Room; | ||
import org.sobotics.chatexchange.chat.event.MessagePostedEvent; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class NewMessageHandlerService { | ||
|
||
public Consumer<MessagePostedEvent> getMessagePostedEventConsumer(Room finalChatroom) { | ||
return event-> newMessage(finalChatroom, event, false); | ||
} | ||
|
||
|
||
private static void newMessage(Room room, MessagePostedEvent event, boolean b) { | ||
String message = event.getMessage().getPlainContent(); | ||
int cp = Character.codePointAt(message, 0); | ||
if(message.trim().startsWith("@bots alive")){ | ||
room.send("Whadya think?"); | ||
} | ||
else if (cp == 128642 || (cp>=128644 && cp<=128650)){ | ||
room.send("\uD83D\uDE83"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters