XMPP Online Status
Presence status text and online mode indicator for the XMPP protocol using my
SmackBot xmpp bot. I apriciate comments suggestions, corrections etc. You can the XMPP Presence indicator in action at my personal SnipSnap
http://senikk.comExample iconset
http://psi.affinix.com/files/common/iconsets/psi_dudes/psi_dudes.pngMacros
| Name | Example | Description |
|---|
| xmpp-status | {xmpp-status:senikk@jabber.org} | This was my first test of using my SmackBot with a macro. It returns the Presence status text for the user jabbber id given. |
| xmpp-indicator | {jabber-indicator:senikk@jabber.org} | Showing a image presence indicator. Its now working but I need to fix the roster handling. |
Todo
- Make it possible to refer to a snip with a {@jabberID} label instead of jid
- Add support for {logins} and {list-of-users} macros
- Add some information in img title attribute like last available, status message etc. I think I have to add a new appendImage() to do this.
- If not in the bot's roster send a subscription request
- Add an add to my roster kind of link/image to add a jabber SnipSnap user to your roster, you need to be a logged in user and have a {@jabberID} label. Maybe this should be a part of rendering of the {@jabberID} label
XMPP Status text
package com.brassforum.snipsnap.macro;import org.radeox.macro.Macro;
import org.radeox.macro.parameter.MacroParameter;import org.snipsnap.notification.xmpp.SmackBot;import java.io.IOException;
import java.io.Writer;public class XMPPStatusMacro extends Macro {
private String[] paramDescription = {"none"}; public String[] getParamDescription() {
return paramDescription;
} public String getName() {
return "xmpp-status";
} public String getDescription() {
return "XMPP online status";
} public void execute(Writer writer, MacroParameter params)
throws IllegalArgumentException, IOException { if (params == null || params.getLength() < 1)
throw new IllegalArgumentException("Number of arguments does not match"); SmackBot smackbot = SmackBot.getInstance();
writer.write(smackbot.onlineStatus(params.get("0"))); return;
}
} XMPP Presence Indicator
package com.brassforum.snipsnap.macro;import org.radeox.macro.Macro;
import org.radeox.macro.parameter.MacroParameter;import org.snipsnap.notification.xmpp.SmackBot;
import org.snipsnap.snip.SnipLink;import java.io.IOException;
import java.io.Writer;public class XMPPIndicatorMacro extends Macro {
private String[] paramDescription = {"none"}; public String[] getParamDescription() {
return paramDescription;
} public String getName() {
return "xmpp-indicator";
} public String getDescription() {
return "xmpp online indicator";
} public void execute(Writer writer, MacroParameter params)
throws IllegalArgumentException, IOException { if (params == null || params.getLength() < 1)
throw new IllegalArgumentException("Number of arguments does not match"); SmackBot smackbot = SmackBot.getInstance();
String status = smackbot.onlineMode(params.get("0")); if(status!=null && status.length()>0) SnipLink.appendImage(writer,"xmpp/"+status+".png",status); return;
}
}