… | |
… | |
2512 | sub cf::client::send_msg { |
2512 | sub cf::client::send_msg { |
2513 | my ($self, $channel, $msg, $color, @extra) = @_; |
2513 | my ($self, $channel, $msg, $color, @extra) = @_; |
2514 | |
2514 | |
2515 | $msg = $self->pl->expand_cfpod ($msg); |
2515 | $msg = $self->pl->expand_cfpod ($msg); |
2516 | |
2516 | |
2517 | $color &= ~cf::NDI_UNIQUE; # just in case... |
2517 | $color &= cf::NDI_CLIENT_MASK; # just in case... |
2518 | |
2518 | |
2519 | if (ref $channel) { |
2519 | if (ref $channel) { |
2520 | # send meta info to client, if not yet sent |
2520 | # send meta info to client, if not yet sent |
2521 | unless (exists $self->{channel}{$channel->{id}}) { |
2521 | unless (exists $self->{channel}{$channel->{id}}) { |
2522 | $self->{channel}{$channel->{id}} = $channel; |
2522 | $self->{channel}{$channel->{id}} = $channel; |
… | |
… | |
2527 | } |
2527 | } |
2528 | |
2528 | |
2529 | return unless @extra || length $msg; |
2529 | return unless @extra || length $msg; |
2530 | |
2530 | |
2531 | if ($self->can_msg) { |
2531 | if ($self->can_msg) { |
|
|
2532 | # default colour, mask it out |
|
|
2533 | $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) |
|
|
2534 | if $color & cf::NDI_DEF; |
|
|
2535 | |
2532 | $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $channel, $msg, @extra])); |
2536 | $self->send_packet ("msg " . $self->{json_coder}->encode ( |
|
|
2537 | [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra])); |
2533 | } else { |
2538 | } else { |
2534 | # replace some tags by gcfclient-compatible ones |
|
|
2535 | for ($msg) { |
|
|
2536 | 1 while |
|
|
2537 | s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ |
|
|
2538 | || s/<i>([^<]*)<\/i>/[i]${1}[\/i]/ |
|
|
2539 | || s/<u>([^<]*)<\/u>/[ul]${1}[\/ul]/ |
|
|
2540 | || s/<tt>([^<]*)<\/tt>/[fixed]${1}[\/fixed]/ |
|
|
2541 | || s/<fg name=\"([^"]+)\">([^<]*)<\/fg>/[color=$1]${2}[\/color]/; |
|
|
2542 | } |
|
|
2543 | |
|
|
2544 | if ($color >= 0) { |
2539 | if ($color >= 0) { |
|
|
2540 | # replace some tags by gcfclient-compatible ones |
|
|
2541 | for ($msg) { |
|
|
2542 | 1 while |
|
|
2543 | s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ |
|
|
2544 | || s/<i>([^<]*)<\/i>/[i]${1}[\/i]/ |
|
|
2545 | || s/<u>([^<]*)<\/u>/[ul]${1}[\/ul]/ |
|
|
2546 | || s/<tt>([^<]*)<\/tt>/[fixed]${1}[\/fixed]/ |
|
|
2547 | || s/<fg name=\"([^"]+)\">([^<]*)<\/fg>/[color=$1]${2}[\/color]/; |
|
|
2548 | } |
|
|
2549 | |
|
|
2550 | $color &= cf::NDI_COLOR_MASK; |
|
|
2551 | |
2545 | if (0 && $msg =~ /\[/) { |
2552 | if (0 && $msg =~ /\[/) { |
2546 | $self->send_packet ("drawextinfo $color 4 0 $msg") |
2553 | $self->send_packet ("drawextinfo $color 4 0 $msg") |
2547 | } else { |
2554 | } else { |
2548 | $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g; |
2555 | $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g; |
2549 | $self->send_packet ("drawinfo $color $msg") |
2556 | $self->send_packet ("drawinfo $color $msg") |