Last active
August 29, 2015 14:14
-
-
Save knixeur/376078bd6b702255a7e7 to your computer and use it in GitHub Desktop.
A simple plugin that let's you open chats or join rooms when converse is initialized
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
function converseAutoJoinChatPlugin( converse ) { | |
var jids = [ '[email protected]' ]; | |
converse.on('ready', function() { | |
var _transform = function (jid) { | |
var chatbox = converse.chatboxes.get(jid); | |
if (!chatbox) { | |
var roster_item = converse.roster.get(jid); | |
if (roster_item === undefined) { | |
// Assume MUC | |
converse.chatboxes.create({ | |
'id': jid, | |
'jid': jid, | |
'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)), | |
'nick': Strophe.unescapeNode(Strophe.getNodeFromJid(converse.jid)), | |
'chatroom': true, | |
'box_id' : b64_sha1(jid) | |
}); | |
} | |
converse.chatboxes.create({ | |
'id': jid, | |
'jid': jid, | |
'fullname': _.isEmpty(roster_item.get('fullname'))? jid: roster_item.get('fullname'), | |
'image_type': roster_item.get('image_type'), | |
'image': roster_item.get('image'), | |
'url': roster_item.get('url') | |
}); | |
} | |
}; | |
if (typeof jids === "string") { | |
_transform(jids); | |
} | |
_.map(jids, _transform); | |
}); | |
}; | |
converse.plugins.add('converseAutoJoinChatPlugin', converseAutoJoinChatPlugin); |
@gbonvehi, thanks for the plugin
I want to develop a plugin for filtering messages using the 'message' event. can you help me with this...thanks in advance
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@rui-wang-codebase
Sorry for the late response, Gist doesn't ping users when they're mentioned here, take a look here conversejs/converse.js#156 (comment) the API was changed a bit.
Cheers,
Guillermo