Last active
November 3, 2017 20:57
-
-
Save gregkare/85615fa2855bd3e42649f80b8bed0d5e to your computer and use it in GitHub Desktop.
Hubot XMPP plugin test
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 () { | |
var Stanza; | |
({Stanza} = require('node-xmpp-client')); | |
"use strict"; | |
const xmpp_rooms = ["test3@muc.5apps.com"]; | |
module.exports = function(robot) { | |
if (robot.adapterName == "xmpp") { | |
for (var room of xmpp_rooms) { | |
console.log("Joining room from the plugin: " + room); | |
robot.adapter.joinRoom({jid: room}); | |
} | |
} | |
var client = robot.adapter.client; | |
var presence = new Stanza('presence', {to: room}); | |
var x = presence.c('x', {xmlns: 'http://jabber.org/protocol/muc'}); | |
client.send(x); | |
// Set the config | |
var config_iq = new Stanza('iq', {id: 'create2', to: room, type: 'set'}) | |
.c('query', {xmlns: 'http://jabber.org/protocol/muc#owner' }) | |
.c('x', {xmlns: 'jabber:x:data', type: 'submit'}) | |
.c('field', {var: 'FORM_TYPE'}) | |
.c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up() | |
.c('field', {var: 'muc#roomconfig_roomdesc'}) | |
.c('value').t('This is a test desc').up().up() | |
.c('field', {var: 'muc#roomconfig_persistentroom'}) | |
.c('value').t(true).up().up() | |
.c('field', {var: 'muc#roomconfig_whois'}) | |
.c('value').t('moderators'); | |
// console.log(config_iq.tree().toString()); | |
client.send(config_iq.tree()); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment