hangouts-bot icon indicating copy to clipboard operation
hangouts-bot copied to clipboard

send message

Open amrsobhy opened this issue 10 years ago • 9 comments

I couldn't figure out sending messages. I tried the following

var hangoutsBot = require("hangouts-bot"); var bot = new hangoutsBot("xxxxx", "xxxx");

bot.on('online', function() { console.log('online'); bot.sendMessage("[email protected]","testing from nodejs");

});

bot.on('message', function(from, message) { console.log(from + ">> " + message); });

amrsobhy avatar Jan 20 '15 15:01 amrsobhy

Can you receive messages in the console if you send a message to the bot while its connected?

On Tue, Jan 20, 2015, 10:06 AM amrsobhy [email protected] wrote:

I couldn't figure out sending messages. I tried the following

var hangoutsBot = require("hangouts-bot"); var bot = new hangoutsBot("xxxxx", "xxxx");

bot.on('online', function() { console.log('online'); bot.sendMessage("[email protected]","testing from nodejs");

});

bot.on('message', function(from, message) { console.log(from + ">> " + message); });

— Reply to this email directly or view it on GitHub https://github.com/jaxbot/hangouts-bot/issues/1.

jaxbot avatar Jan 20 '15 15:01 jaxbot

Yes. and also if someone else sends me while the bot is connected, it's well received.

amrsobhy avatar Jan 20 '15 15:01 amrsobhy

Is the username you're sending to friends with the bot, I.e. if you log in as the bot can you message that address?

jaxbot avatar Jan 20 '15 15:01 jaxbot

Yup. I checked this too, I am friends with the person I am trying to send.

amrsobhy avatar Jan 20 '15 15:01 amrsobhy

That's strange. It works on my machine™, so I'll have to debug this when I get home from work

jaxbot avatar Jan 20 '15 17:01 jaxbot

Just played with it some more. Works for me when I put in my gmail address in the [email protected] format. Not really sure what to think. Any errors coming up?

Can you put a console.log statement in node_modules/hangouts-bot/index.js in here:

      this.sendMessage = function(to, message) {
                var stanza = new xmpp.Element('message',
                        {
                                to: to,
                                type: 'chat'
                        })
                        .c('body')
                        .t(message);

                this.connection.send(stanza);
        }

to verify it is getting to that piece?

jaxbot avatar Jan 20 '15 18:01 jaxbot

Any news about it?

rodrigoadachi avatar Sep 07 '16 18:09 rodrigoadachi

Hi, same happening to me...any progress on this??

jaitor1 avatar Oct 17 '16 19:10 jaitor1

Hi, sendMessage does'nt work for me with my email. But i've log in message callback the from variable :

image

i've got somethink like [email protected]/xxxxxxxxxx

If i use this "email" sendMessage work fine 👍

AurelienLoyer avatar Jan 30 '17 21:01 AurelienLoyer