-$sub->psubscribe( 'channel *', sub {
- my ( $message, $from ) = @_;
- return unless $from !~ m/\Q$jid\E/; # skip our messages
- warn "#Q<< $from [$jid] | $message\n";
- my ( undef, $channel, $user ) = split(/ /,$from,3);
-warn "# contacts ",dump($contacts);
- foreach my $contact ( keys %$contacts ) {
- next if $from =~ m/\Q$contact\E/;
- warn "# $jid [$from] -> [$contact] | $message\n";
- $cl->send_message( join(' ',$channel, $user, $message), $contact => $jid, 'chat' );
+ foreach my $to ( keys %$contacts, keys %$muc_rooms ) {
+ next if $from =~ m/\Q$to\E/; # FIXME
+ my $type = defined $muc_rooms->{$from} ? 'groupchat' : 'chat';
+ publish "SEND $jid $type $user $to" => $body;