Skip to content

Commit

Permalink
Extended Room API
Browse files Browse the repository at this point in the history
  • Loading branch information
Konloch committed Dec 16, 2023
1 parent 935cf89 commit c83dca2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/main/java/com/konloch/ircbot/server/Room.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.konloch.ircbot.server;

import com.konloch.ircbot.listener.IRCJoin;
import com.konloch.ircbot.listener.IRCLeave;
import com.konloch.ircbot.listener.IRCPrivateMessage;
import com.konloch.ircbot.listener.IRCRoomMessage;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
Expand Down Expand Up @@ -130,6 +135,42 @@ public void send(String message)
messageQueue.add(message);
}

public void onJoin(IRCJoin join)
{
//filter listener events to only call for this server
server.getBot().getListeners().onJoin(event ->
{
if(event.getRoom() != this)
return;

join.join(event);
});
}

public void onLeave(IRCLeave leave)
{
//filter listener events to only call for this server
server.getBot().getListeners().onLeave(event ->
{
if(event.getRoom() != this)
return;

leave.leave(event);
});
}

public void onMessage(IRCRoomMessage roomMessage)
{
//filter listener events to only call for this server
server.getBot().getListeners().onRoomMessage(event ->
{
if(event.getRoom() != this)
return;

roomMessage.message(event);
});
}

public Server getServer()
{
return server;
Expand Down

0 comments on commit c83dca2

Please sign in to comment.