comparison isshouni.js @ 3:0082e861cf16

Fix text message handling and new participant.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 23 Feb 2012 20:44:12 +0100
parents 88eb49491a1e
children e6f5077c2ea9
comparison
equal deleted inserted replaced
2:88eb49491a1e 3:0082e861cf16
81 81
82 if (from.bare !== config.muc) 82 if (from.bare !== config.muc)
83 return; 83 return;
84 84
85 if (stanza.is('presence') && type !== 'unavailable') 85 if (stanza.is('presence') && type !== 'unavailable')
86 return on_presence(stanza); 86 return on_presence(from, stanza);
87 87
88 if (stanza.is('message')) 88 if (stanza.is('message'))
89 return on_message(stanza); 89 return on_message(from, stanza);
90 }); 90 });
91 91
92 var on_message = function(from, stanza) { 92 var on_message = function(from, stanza) {
93 if (from.resource === config.nick) 93 if (from.resource === config.nick)
94 return; 94 return;
95 95
96 var message = stanza.getChild('body'); 96 var message = stanza.getChild('body');
97 if (message) 97 if (message)
98 send_command('osd_show_text "' + from.resource + ': ' + message.getText() + '"'); 98 message = message.getText();
99 if (message)
100 send_command('osd_show_text "' + from.resource + ': ' + message + '"');
99 101
100 var payload = stanza.getChild(null, 'urn:linkmauve:player'); 102 var payload = stanza.getChild(null, 'urn:linkmauve:player');
101 if (!payload) 103 if (!payload)
102 return; 104 return;
103 105
115 var on_presence = function(from, stanza) { 117 var on_presence = function(from, stanza) {
116 if (from.resource === config.nick) { 118 if (from.resource === config.nick) {
117 connected = true; 119 connected = true;
118 return; 120 return;
119 } 121 }
122 if (!connected)
123 return;
124
125 console.log('New participant: ' + from.resource);
126
127 if (paused)
128 send_message('paused', undefined, 'chat');
120 }; 129 };
121 130
122 cl.on('error', function(e) { 131 cl.on('error', function(e) {
123 console.log(e); 132 console.log(e);
124 }); 133 });