I solve a similar problem by putting the users in the same group. If you don’‘t want the users to see the bot, you could automatically add them to a group that’'s visible to the bot (exclusively? - put the bot in his own group, make the new one visible only to that).
The users will see that they are in a group though, I guess. All the other users will appear as part of a group to them.
Here’'s some of my plugins code:
/**
- Adds user to given group.
*/
public void addUserToGroup(String userName, String groupName) {
if (userName == null || groupName == null || “”.equals(userName)
|| “”.equals(groupName)) return;
try {
Group group = groupManager.getGroup(groupName);
group.getMembers().add(XMPPServer.getInstance().createJID(userName, null));
}
catch (GroupNotFoundException e) {
Log.error(e);
}
}
/**
*/
public void removeUserFromGroup(String userName, String groupName) {
if (userName == null || “”.equals(userName)) return;
try {
if (groupName != null) {
Group group = groupManager.getGroup(groupName);
group.getMembers().remove(XMPPServer.getInstance().createJID(
userName, null));
} else
for (Group group : groupManager.getGroups()) {
group.getMembers().remove(XMPPServer.getInstance().createJID(
userName, null));
}
}
catch (GroupNotFoundException e) {
Log.error(e);
}
}
/**
-
@param groupName name of group to create, required
-
@param description description of group, may be empty
-
@param displayName name to display, required
-
@param showType type of sharing, may be empty, “nobody”, “everybody”, “onlyGroup”
-
@param groupNames comma separated list of groups in which this group is visible, may be empty
-
@return whether successful
*/
public boolean createSharedGroup(String groupName, String description,
String displayName, String showType, String groupNames) {
if (groupName == null || “”.equals(groupName)) {
Log.warn(“no group name, nothing to do”);
return false;
}
if (displayName == null || “”.equals(displayName)) {
Log.error(“display name required for shared group”);
return false;
}
try {
Group newGroup = groupManager.createGroup(groupName);
if (description != null) newGroup.setDescription(description);
if ((!"".equals(showType)) && (showType != null)) {
newGroup.getProperties().put(“sharedRoster.showInRoster”, showType);
}
else {
newGroup.getProperties().put(“sharedRoster.showInRoster”, “nobody”);
}
if (displayName != null) {
newGroup.getProperties().put(“sharedRoster.displayName”, displayName);
}
if (groupNames != null) {
newGroup.getProperties().put(“sharedRoster.groupList”, groupNames);
}
}
catch (GroupAlreadyExistsException e) {
Log.error(e);
return false;
}
return true;
}