Guest User

Untitled

a guest
Oct 26th, 2011
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1.  
  2. # Name: channel_highlight-0.3.pl
  3. # Version: 0.3
  4. # Author: LifeIsPain < idontlikespam (at) orvp [dot] net >
  5. # Date: 2010-06-26
  6. # Description: Specify additional highlight words on a per channel basis
  7.  
  8. # Version History
  9. # 0.1 2008-11-14 Initial Version
  10. # 0.2 2008-11-14 Cleanup
  11. # 0.3 2010-06-26 Highlights now more highlighty (change tab color)
  12.  
  13.  
  14. use warnings;
  15. use strict;
  16. use Xchat qw( :all );
  17.  
  18. #$FH = "home";
  19. #$FilePath = "/home/default/.xchat2/sounds/Home.mp3";
  20.  
  21.  
  22.  
  23. my $name = 'Channel Highlight';
  24. my $version = '0.4';
  25.  
  26. register($name, $version, 'Allow for a per-channel based highlight list');
  27. prnt("Loading $name $version");
  28.  
  29. for ('Channel Message', 'Channel Action') {
  30. hook_print($_, \&channel_highlight, { priority => PRI_HIGHEST, data => $_ });
  31. }
  32.  
  33. # todo: among other things, escape extra characters like ( ) { } [ ] ' | when importing and building this list, perhaps , separate?
  34.  
  35. my %chan_highlights = (
  36. '#area51' => '(--\> foofoo)',
  37. '#area52' => '(--\> barbar)'
  38. # '#chan2' => '(peppers)'
  39. );
  40.  
  41. sub channel_highlight {
  42.  
  43. if (exists $chan_highlights{lc get_info('channel')} && $_[0][1] =~ m/(?:^|\W)$chan_highlights{lc get_info('channel')}(?:$|\W)/i)
  44. {
  45. my $event = $_[1];
  46.  
  47. # Set the timeout in seconds
  48. my $timeout = 60; # number of seconds to wait before firing again
  49.  
  50. # Where to write #channel.tmp
  51. my $tmpfile = '/home/sgallant/.xchat2/'.get_info('channel').'.tmp';
  52.  
  53. # opens the file and reads the contents if it exists
  54. if (-e $tmpfile) {
  55. open (TMPFILE, "$tmpfile");
  56. while (<TMPFILE>) {
  57. chomp;
  58. my $filetime = int($_);
  59. my $tmp = $filetime + $timeout;
  60. if (int($tmp) >= int(time()) ) {
  61. Xchat::print("should not fire");
  62. } else {
  63. Xchat::print("should fire");
  64. }
  65. }
  66. close (TMPFILE);
  67. } else {
  68. # if the file doesn't exist, create it
  69. open (TMPFILE, ">$tmpfile");
  70. print TMPFILE time();
  71. close (TMPFILE);
  72. }
  73.  
  74. if ($event eq 'Channel Message') { $event = 'Channel Msg Hilight'; }
  75. else { $event = 'Channel Action Hilight'; }
  76.  
  77. command ('gui color 3');
  78. # system('vlc /home/default/.xchat2/sounds/Home.mp3');
  79. system('mplayer /home/sgallant/.xchat2/sounds/KDE-Im-Nudge.ogg');
  80.  
  81. emit_print( $event, @{$_[0]} );
  82. return EAT_ALL;
  83. }
  84. return EAT_NONE;
  85. }
  86.  
  87.  
  88.  
  89.  
Advertisement
Add Comment
Please, Sign In to add comment