… | |
… | |
2425 | |
2425 | |
2426 | utf8::encode $text; |
2426 | utf8::encode $text; |
2427 | $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); |
2427 | $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); |
2428 | } |
2428 | } |
2429 | |
2429 | |
2430 | =item $client->send_msg ($color, $type, $msg, [extra...]) |
2430 | =item $client->send_msg ($channel, $msg, $color, [extra...]) |
2431 | |
2431 | |
2432 | Send a drawinfo or msg packet to the client, formatting the msg for the |
2432 | Send a drawinfo or msg packet to the client, formatting the msg for the |
2433 | client if neccessary. C<$type> should be a string identifying the type of |
2433 | client if neccessary. C<$type> should be a string identifying the type of |
2434 | the message, with C<log> being the default. If C<$color> is negative, suppress |
2434 | the message, with C<log> being the default. If C<$color> is negative, suppress |
2435 | the message unless the client supports the msg packet. |
2435 | the message unless the client supports the msg packet. |
2436 | |
2436 | |
2437 | =cut |
2437 | =cut |
2438 | |
2438 | |
2439 | sub cf::client::send_msg { |
2439 | sub cf::client::send_msg { |
2440 | my ($self, $color, $type, $msg, @extra) = @_; |
2440 | my ($self, $channel, $msg, $color, @extra) = @_; |
2441 | |
2441 | |
2442 | $msg = $self->pl->expand_cfpod ($msg); |
2442 | $msg = $self->pl->expand_cfpod ($msg); |
2443 | |
2443 | |
2444 | return unless @extra || length $msg; |
2444 | return unless @extra || length $msg; |
2445 | |
2445 | |
|
|
2446 | $color &= ~cf::NDI_UNIQUE; # just in case... |
|
|
2447 | |
|
|
2448 | if (ref $channel) { |
|
|
2449 | # send meta info to client, if not yet sent |
|
|
2450 | unless (exists $self->{channel}{$channel->{id}}) { |
|
|
2451 | $self->{channel}{$channel->{id}} = $channel; |
|
|
2452 | $self->ext_event (channel_info => %$channel); |
|
|
2453 | } |
|
|
2454 | |
|
|
2455 | $channel = $channel->{id}; |
|
|
2456 | } |
|
|
2457 | |
2446 | if ($self->can_msg) { |
2458 | if ($self->can_msg) { |
2447 | $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $type, $msg, @extra])); |
2459 | $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $channel, $msg, @extra])); |
2448 | } else { |
2460 | } else { |
2449 | # replace some tags by gcfclient-compatible ones |
2461 | # replace some tags by gcfclient-compatible ones |
2450 | for ($msg) { |
2462 | for ($msg) { |
2451 | 1 while |
2463 | 1 while |
2452 | s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ |
2464 | s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ |