Skip to content

Commit

Permalink
improve MUC chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
deleolajide committed Dec 27, 2023
1 parent e5c2c59 commit 2627ae5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/java/org/ifsoft/llama/openfire/LLaMAConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ public void systemShutdown() {

@Override
public void deliver(Packet packet) throws UnauthorizedException {
// auto accept presence subscriptions
final String llamaUser = JiveGlobals.getProperty("llama.username", "llama");
final String alias = JiveGlobals.getProperty("llama.alias", "LLaMA");

if (packet instanceof Presence) {
Presence presence = (Presence) packet;
Expand Down Expand Up @@ -249,22 +250,21 @@ public void deliver(Packet packet) throws UnauthorizedException {
Log.debug("Auto-accept MUC invitation " + muc);

Presence presence = new Presence();
presence.setTo(muc + "/" + username);
presence.setTo(muc + "/" + alias);
presence.setFrom(username + "@" + domain + "/" + remoteAddr);
presence.addChildElement("x", "http://jabber.org/protocol/muc");
XMPPServer.getInstance().getPresenceRouter().route(presence);
}
else {
Log.debug("Incoming Message " + packet.getFrom() + "\n" + message.getBody());
String from = packet.getFrom().getNode();
String nick = packet.getFrom().getResource();
String msg = message.getBody();

if (!isNull(msg) && !isNull(from) /*&& SessionManager.getInstance().getSessions(from).size() > 0*/)
{
if (!isNull(msg) && !isNull(from) && nick != null && !nick.equals(alias)) {
JID requestor = packet.getFrom();

if (message.getType() == Message.Type.groupchat) {
final String llamaUser = JiveGlobals.getProperty("llama.username", "llama");

if (msg.toLowerCase().startsWith(llamaUser.toLowerCase())) {
requestor = new JID(packet.getFrom().toBareJID());
Expand Down

0 comments on commit 2627ae5

Please sign in to comment.