forked from simple-xmpp/node-simple-xmpp
-
Notifications
You must be signed in to change notification settings - Fork 4
/
send-msg.js
48 lines (38 loc) · 1.22 KB
/
send-msg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(function (process, console) {
"use strict";
process.on('uncaughtException', function (err) {
console.error(err.stack || err);
});
var util = require("util");
if (process.argv.length < 5) {
console.log("please pass jid, password, and the destination address as command line params");
process.exit(1);
}
var simpler = require('../index'),
jid = process.argv[2],
password = process.argv[3],
to = process.argv[4],
client = simpler({
jid:jid,
password:password,
host:'talk.google.com'
}),
connection;
client.on('online', function () {
console.log('online!');
});
client.on('chat', function (from, message) {
console.log("from %s: ", from, message);
});
client.on('roster', function (roster) {
console.log("roster", roster);
});
client.on('presence', function (from, presence, presences) {
console.log("presence", from, presence);
});
client.on('error', function (err) {
console.error(err);
});
client.addBuddy(to);
client.send(to, "this is a message from the send-msg script at " + new Date());
})(process, console);