Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Name: channel_highlight-0.3.pl
- # Version: 0.3
- # Author: LifeIsPain < idontlikespam (at) orvp [dot] net >
- # Date: 2010-06-26
- # Description: Specify additional highlight words on a per channel basis
- # Version History
- # 0.1 2008-11-14 Initial Version
- # 0.2 2008-11-14 Cleanup
- # 0.3 2010-06-26 Highlights now more highlighty (change tab color)
- use warnings;
- use strict;
- use Xchat qw( :all );
- #$FH = "home";
- #$FilePath = "/home/default/.xchat2/sounds/Home.mp3";
- my $name = 'Channel Highlight';
- my $version = '0.4';
- register($name, $version, 'Allow for a per-channel based highlight list');
- prnt("Loading $name $version");
- for ('Channel Message', 'Channel Action') {
- hook_print($_, \&channel_highlight, { priority => PRI_HIGHEST, data => $_ });
- }
- # todo: among other things, escape extra characters like ( ) { } [ ] ' | when importing and building this list, perhaps , separate?
- my %chan_highlights = (
- '#area51' => '(--\> foofoo)',
- '#area52' => '(--\> barbar)'
- # '#chan2' => '(peppers)'
- );
- sub channel_highlight {
- if (exists $chan_highlights{lc get_info('channel')} && $_[0][1] =~ m/(?:^|\W)$chan_highlights{lc get_info('channel')}(?:$|\W)/i)
- {
- my $event = $_[1];
- # Set the timeout in seconds
- my $timeout = 60; # number of seconds to wait before firing again
- # Where to write #channel.tmp
- my $tmpfile = '/home/sgallant/.xchat2/'.get_info('channel').'.tmp';
- # opens the file and reads the contents if it exists
- if (-e $tmpfile) {
- open (TMPFILE, "$tmpfile");
- while (<TMPFILE>) {
- chomp;
- my $filetime = int($_);
- my $tmp = $filetime + $timeout;
- if (int($tmp) >= int(time()) ) {
- Xchat::print("should not fire");
- } else {
- Xchat::print("should fire");
- }
- }
- close (TMPFILE);
- } else {
- # if the file doesn't exist, create it
- open (TMPFILE, ">$tmpfile");
- print TMPFILE time();
- close (TMPFILE);
- }
- if ($event eq 'Channel Message') { $event = 'Channel Msg Hilight'; }
- else { $event = 'Channel Action Hilight'; }
- command ('gui color 3');
- # system('vlc /home/default/.xchat2/sounds/Home.mp3');
- system('mplayer /home/sgallant/.xchat2/sounds/KDE-Im-Nudge.ogg');
- emit_print( $event, @{$_[0]} );
- return EAT_ALL;
- }
- return EAT_NONE;
- }
Advertisement
Add Comment
Please, Sign In to add comment