logo

dotfiles

My dotfiles, one branch per machine, rebased on base git clone https://hacktivis.me/git/dotfiles.git

mass_hl_blocker.pl (1535B)


  1. # Mass highlight blocker for WeeChat by arza <arza@arza.us>, distributed freely and without any warranty, licensed under GPL3 <http://www.gnu.org/licenses/gpl.html>
  2. weechat::register('mass_hl_blocker', 'arza <arza\@arza.us>', '0.1', 'GPL3', 'Block mass highlights', '', '');
  3. my $version=weechat::info_get('version_number', '') || 0;
  4. my $limit=5;
  5. if(weechat::config_is_set_plugin('limit')){ $limit=weechat::config_get_plugin('limit'); }
  6. else{ weechat::config_set_plugin('limit', $limit); }
  7. if($version>=0x00030500){ weechat::config_set_desc_plugin('limit', 'minimum amount of nicks in line to disable highlight (default: 5)'); }
  8. weechat::hook_config('plugins.var.perl.mass_highlight_block.limit', 'set_limit', '');
  9. weechat::hook_modifier('2000|weechat_print', 'block', '');
  10. sub block { my $message=$_[3];
  11. $_[2]=~/(\S+);(\S+)\.(\S+);(\S+)/ || return $message;
  12. my ($plugin, $server, $channel, $tags) = ($1, $2, $3, $4);
  13. index($message, weechat::info_get('irc_nick', $server)) != -1 && index($tags, 'notify_message') != -1 && index($tags, 'no_highlight') == -1 || return $message;
  14. my $count=0;
  15. foreach my $word (split(' ', $message)){
  16. my $infolist=weechat::infolist_get('irc_nick', '', "$server,$channel,$word");
  17. if($infolist){ $count++; }
  18. weechat::infolist_free($infolist);
  19. }
  20. if($count>=$limit){
  21. weechat::print_date_tags(weechat::buffer_search($plugin, "$server.$channel"), 0, "$tags,no_highlight", $message);
  22. return '';
  23. }
  24. return $message;
  25. }
  26. sub set_limit {
  27. $limit=$_[2];
  28. return weechat::WEECHAT_RC_OK;
  29. }