Skip to content

Instantly share code, notes, and snippets.

@LifeIsPain
Forked from anonymous/strip_topic_color.pl
Created May 15, 2013 01:20
Show Gist options
  • Save LifeIsPain/5581004 to your computer and use it in GitHub Desktop.
Save LifeIsPain/5581004 to your computer and use it in GitHub Desktop.
# Name: strip_topic_color.pl
# Version: 001
# Author: LifeIsPain < idontlikespam (at) orvp [dot] net >
# Date: 2013-05-14
# Description: Strip the topic colors when coming in after someone edits the topic, or when getting a manual topic
# Version History
# 001 2013-05-14 Initial Version
use strict;
use warnings;
use Xchat qw (:all);
register('Strip Topic Color', '001', 'Strip colors on any inbound topic prior to display');
hook_server('topic', \&change_topic, PRI_HIGH);
hook_server('332', \&existing_topic, PRI_HIGH);
sub change_topic {
my $stripped_topic = strip_code($_[1][3]);
# If the topic is already stripped, no need to do anything
if ($stripped_topic eq $_[1][3]) {
return EAT_NONE;
}
else {
# receive a fake event with the stripped topic, rest of format is fine
command("RECV $_[0][0] $_[0][1] $_[0][2] $stripped_topic");
return EAT_ALL;
}
}
sub existing_topic {
my $stripped_topic = strip_code($_[1][4]);
# If the topic is already stripped, no need to do anything
if ($stripped_topic eq $_[1][4]) {
return EAT_NONE;
}
else {
# receive a fake event with the stripped topic, rest of format is fine
command("RECV $_[0][0] $_[0][1] $_[0][2] $_[0][3] $stripped_topic");
return EAT_ALL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment