Long Action Message Fix for XChat-WDK and Justin.TV JTVIRC

By KinKinnyKith on Feb 20, 2012

Long /me action messages sent over the Justin.TV IRC Network are not displayed as actions by XChat-WDK clients. This requested snippet corrects this quirk.

JTVIRC truncates long messages (at 250 characters, excluding header) with an ellipsis (three full stops), and similarly truncates /me action messages the same way, but does not replace the terminating control code lost in the truncation. Apparently XChat-WDK demands paired control codes in order to process the message as an action.

For example, sending:
/me 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789

Will result in this broken action being received and displayed as a message by XChat-WDK (possibly other clients as well):
< kin> ACTION 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12...

This simple script rebuilds the terminating control code, and retriggers the message receive event, so that the message will be correctly displayed as a channel action:
* kin 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12...

To use: Install perl (I use activeperl) and the perl plugin for XChat-WDK, and save this snippet to your XChat-WDK plugins folder as a .pl file. Restart XChat-WDK and you should see a message that it is loaded.

Thanks to rom138 for the request and pointing out this quirk.

##########################################
### Kin's Justin.TV JTVIRC Action Fix  ###
### Requested by themanbot / rom138    ###
###   in #Script-Help irc.GeekShed.net ###
### 2012-02-06 v1.1                    ###
##########################################
# 2012-02-06 v1.1 - Removed print hook and emit, and instead, hooked into the server message at highest priority to
#                     reconstruct the broken action extended data by adding even delimiter at message suffix,
#                     and retrigger the message so that other scripts may use the reconstructed action.
# 2012-02-06 v1   - Request by themanbot
#-----------------------------------------
# Justin.TV's IRC truncates long messages (>250 char) with three full stops...
# JTV fails to re-add the trailing \001 control code to the end of truncated /me action messages
# XChat-WDK, and possibly other clients, will not display this message as a channel action, because of the lack of paired extended data delimiting;
#   Instead of a channel action, these messages will be displayed as a channel message, including the broken ACTION header.
# This small script catches this case, reconstructs the action extended data delimiting, and retriggers the event for proper handling by the client.
#-----------------------------------------
use strict; use warnings;
Xchat::register("JTVIRC Action Fix", "v1.1", "Kin's Justin.TV JTVIRC Action Fix");
Xchat::hook_server( "PRIVMSG", \&JTVIRCMeFix, Xchat::PRI_HIGHEST );
sub JTVIRCMeFix {
    my $strPrivMsg = $_[1][0];
    if ($strPrivMsg =~ s/^(.*:\001ACTION\s.*?\.{3})$/$1\001/) { Xchat::command("recv $strPrivMsg"); return Xchat::EAT_XCHAT; }
    return Xchat::EAT_NONE;
}
Xchat::print("Kin's Justin.TV JTVIRC Action Fix v1.1 Loaded");

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.