Mercurial > isshouni
comparison isshouni.js @ 6:377a9b42226a default tip
Add logging fonctions and don’t listen to messages from the room itself.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 23 Feb 2012 23:51:31 +0100 |
parents | 4a063df30be9 |
children |
comparison
equal
deleted
inserted
replaced
5:4a063df30be9 | 6:377a9b42226a |
---|---|
71 //console.log(text); | 71 //console.log(text); |
72 mplayer.stdin.write(text + '\n'); | 72 mplayer.stdin.write(text + '\n'); |
73 }; | 73 }; |
74 | 74 |
75 cl.on('stanza', function(stanza) { | 75 cl.on('stanza', function(stanza) { |
76 //console.log(stanza.toString()); | 76 console.log(stanza.toString()); |
77 | 77 |
78 var type = stanza.attrs['type']; | 78 var type = stanza.attrs['type']; |
79 var from = new JID(stanza.attrs['from']); | 79 var from = new JID(stanza.attrs['from']); |
80 var id = stanza.attrs['id'] || ''; | 80 var id = stanza.attrs['id'] || ''; |
81 | 81 |
95 if (stanza.is('message')) | 95 if (stanza.is('message')) |
96 return on_message(from, stanza); | 96 return on_message(from, stanza); |
97 }); | 97 }); |
98 | 98 |
99 var on_message = function(from, stanza) { | 99 var on_message = function(from, stanza) { |
100 if (from.resource === config.nick) | 100 if (from.resource && from.resource === config.nick) |
101 return; | 101 return; |
102 | 102 |
103 var message = stanza.getChild('body'); | 103 var message = stanza.getChild('body'); |
104 if (message) | 104 if (message) |
105 message = message.getText(); | 105 message = message.getText(); |
108 | 108 |
109 var payload = stanza.getChild(null, 'urn:linkmauve:player'); | 109 var payload = stanza.getChild(null, 'urn:linkmauve:player'); |
110 if (!payload) | 110 if (!payload) |
111 return; | 111 return; |
112 | 112 |
113 //send_command('osd_show_text "' + from.resource + ' did ' + payload.name + '"'); | 113 send_command('osd_show_text "' + from.resource + ' did ' + payload.name + '"'); |
114 | 114 |
115 if (payload.name === 'pause') { | 115 if (payload.name === 'pause') { |
116 send_command('pause'); | 116 send_command('pause'); |
117 paused = !paused; | 117 paused = !paused; |
118 } else if (payload.name === 'seek') | 118 } else if (payload.name === 'seek') |