return $instlabel;
}
-sub generate_prefix($) {
- $mc->tlvs_to_message([$mc->tlv_wrap(
+sub generate_outgoing($$) {
+ my ($text, $instlabel) = @_;
+
+ my $framedlabel = $mc->tlvs_to_message([$mc->tlv_wrap(
$known_types{'InstanceLabelHuffman1'},
- @_)]);
+ $instlabel)]);
+
+ if (Irssi::settings_get_bool("instance_tlvs_at_start")) {
+ $text = $framedlabel . $text . $instance_suffix;
+ } else {
+ $text = $text . $instance_suffix . $framedlabel;
+ }
}
my $suppress_out = 0;
my $instlabel = get_instance_label($$server{'address'},
$$channel{'name'});
- $text = generate_prefix($instlabel) . $text . $instance_suffix if "" ne $instlabel;
+
+ $text = generate_outgoing($text, $instlabel) if "" ne $instlabel;
$suppress_out = 1;
my $emitted_signal = Irssi::signal_get_emitted();
return;
}
- $text = $mc->tlvs_to_message([$mc->tlv_wrap(
- $known_types{'InstanceLabelHuffman1'},
- $instenc)
- ] ) . $text . $instance_suffix if "" ne $inst;
+ $text = generate_outgoing($text, $instenc) if "" ne $inst;
$suppress_out = 1;
Irssi::signal_emit("send text", $text, $server, $witem);
Irssi::command_bind('punt', 'cmd_punt');
Irssi::command_bind('unpunt', 'cmd_unpunt');
+# NOTICE: This is transitional for experimentation with the protocol and may
+# disappear soon. MasterCoder is aware to look at both ends of strings
+# passed to tlv_run_callbacks, so this option controls which position we use
+# when generating.
+Irssi::settings_add_bool('instance','instance_tlvs_at_start', 1);
+
# The old way of storing these...
#Irssi::settings_add_str('lookandfeel', 'current_instance', "default");
#Irssi::settings_add_str('lookandfeel', 'punt_list', "");
. (join ("",@{$$self{'code_chars'}}))
."]+)".$$self{'msg_suffix'}."(.*)\$";
- my $rest;
+ # This regex is a little different. It nongreedly consumes the
+ # ordinary text and will repeatedly backtrack in the presence of
+ # multiple message prefix sigils.
+ my $regex2 = "^(.*?)"
+ . $$self{'msg_prefix'}."(["
+ . (join ("",@{$$self{'code_chars'}}))
+ ."]+)".$$self{'msg_suffix'}."\$";
+
+ my ($tlvstr, $rest) = (undef, undef);
if ( $msg =~ /$regex/ ) {
+ $tlvstr = $1;
$rest = $2;
- # That's meta-l, not the conductive solid.
- my ($metal, $metallen) = $self->ldecode($1);
- return (0, $msg) if (length $1) < $metallen + $metal;
- # So here's an interesting connundrum. It might be that
- # the additional text we insert after ours looks like a
- # message end. Therefore, once we have extracted metal,
- # we need to check that there's a msg_suffix where there
- # should be.
- if ((length $1) > $metallen + $metal) {
- my $ssws = substr($1, $metallen + $metal);
- return (0, $msg) if (index $ssws, $$self{'msg_suffix'});
-
- # Now put what should be on $rest back on it.
- $rest = substr($1, $metallen + $metal) . $rest;
- }
- $msg = substr($1, $metallen, $metal);
+ } elsif ( $msg =~ /$regex2/ ) {
+ $tlvstr = $2;
+ $rest = $1;
} else {
return (0, $msg);
}
+ # That's meta-l, not the conductive solid.
+ my ($metal, $metallen) = $self->ldecode($tlvstr);
+ return (0, $msg) if (length $tlvstr) < $metallen + $metal;
+ # So here's an interesting connundrum. It might be that
+ # the additional text we insert after ours looks like a
+ # message end. Therefore, once we have extracted metal,
+ # we need to check that there's a msg_suffix where there
+ # should be.
+ if ((length $tlvstr) > $metallen + $metal) {
+ my $ssws = substr($tlvstr, $metallen + $metal);
+ return (0, $msg) if (index $ssws, $$self{'msg_suffix'});
+
+ # Now put what should be on $rest back on it.
+ $rest = substr($tlvstr, $metallen + $metal) . $rest;
+ }
+ $msg = substr($tlvstr, $metallen, $metal);
+
+
while( $msg ne "" )
{
last if length $msg < 2;