X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/93a0fbf3c98153be394e1eeae32fdfadf39b985c..b47ffe60e244c9165f40371736079320ea2d848b:/weechat/perl/highmon.pl diff --git a/weechat/perl/highmon.pl b/weechat/perl/highmon.pl index 967f973..f843cad 100644 --- a/weechat/perl/highmon.pl +++ b/weechat/perl/highmon.pl @@ -1,16 +1,17 @@ # # highmon.pl - Highlight Monitoring for weechat 0.3.0 -# Version 2.3.3.2 # # Add 'Highlight Monitor' buffer/bar to log all highlights in one spot # # Usage: -# /highmon [help] | [monitor [channel [server]]] | [clean default|orphan|all] +# /highmon [help] | [monitor [channel [server]]] | [clean default|orphan|all] | clearbar # Command wrapper for highmon commands # # /highmon clean default|orphan|all will clean the config section of default 'on' entries, # channels you are no longer joined, or both # +# /highmon clearbar will clear the contents of highmon's bar output +# # /highmon monitor [channel] [server] is used to toggle a highlight monitoring on and off, this # can be used in the channel buffer for the channel you wish to toggle, or be given # with arguments e.g. /highmon monitor #weechat freenode @@ -62,10 +63,26 @@ # servername is the internal name for the server (set when you use /server add) # #channel is the channel name, (where # is whatever channel type that channel happens to be) # +# Optional, set up tweaks; Hide the status and input lines on highmon +# +# /set weechat.bar.status.conditions "${window.buffer.full_name} != perl.highmon" +# /set weechat.bar.input.conditions "${window.buffer.full_name} != perl.highmon" +# # Bugs and feature requests at: https://github.com/KenjiE20/highmon # History: +# 2020-06-21, Sebastien Helleu : +# v2.7: make call to bar_new compatible with WeeChat >= 2.9 +# 2019-05-13, HubbeKing +# v2.6: -add: send "logger_backlog" signal on buffer open if logging is enabled +# 2014-08-16, KenjiE20 : +# v2.5: -add: clearbar command to clear bar output +# -add: firstrun output prompt to check the help text for set up hints as they were being missed +# and update hint for conditions to use eval +# -change: Make all outputs use the date callback for more accurate timestamps (thanks Germainz) +# 2013-12-04, KenjiE20 : +# v2.4: -add: Support for eval style colour codes in time format used for bar output # 2013-10-22, KenjiE20 : # v2.3.3.2: -fix: Typo in fix command # 2013-10-10, KenjiE20 : @@ -138,11 +155,13 @@ @bar_lines_time = (); # Replicate info earlier for in-client help -$highmonhelp = weechat::color("bold")."/highmon [help] | [monitor [channel [server]]] | [clean default|orphan|all]".weechat::color("-bold")." +$highmonhelp = weechat::color("bold")."/highmon [help] | [monitor [channel [server]]] | [clean default|orphan|all] | clearbar".weechat::color("-bold")." Command wrapper for highmon commands ".weechat::color("bold")."/highmon clean default|orphan|all".weechat::color("-bold")." will clean the config section of default 'on' entries, channels you are no longer joined, or both +".weechat::color("bold")."/highmon clearbar".weechat::color("-bold")." will clear the contents of highmon's bar output + ".weechat::color("bold")."/highmon monitor [channel] [server]".weechat::color("-bold")." is used to toggle a highlight monitoring on and off, this can be used in the channel buffer for the channel you wish to toggle, or be given with arguments e.g. /highmon monitor #weechat freenode ".weechat::color("bold")."/set plugins.var.perl.highmon.alignment".weechat::color("-bold")." @@ -188,7 +207,12 @@ Setting this to 'on' will only put messages in the highmon buffer when you set y ".weechat::color("bold")."servername.#channel".weechat::color("-bold")." servername is the internal name for the server (set when you use /server add) - #channel is the channel name, (where # is whatever channel type that channel happens to be)"; + #channel is the channel name, (where # is whatever channel type that channel happens to be) + +".weechat::color("bold")."Optional, set up tweaks;".weechat::color("-bold")." Hide the status and input lines on highmon + +".weechat::color("bold")."/set weechat.bar.status.conditions \"\${window.buffer.full_name} != perl.highmon\"".weechat::color("-bold")." +".weechat::color("bold")."/set weechat.bar.input.conditions \"\${window.buffer.full_name} != perl.highmon\"".weechat::color("-bold"); # Print verbose help sub print_help { @@ -243,7 +267,14 @@ sub highmon_bar_open # Make the bar item weechat::bar_item_new("highmon", "highmon_bar_build", ""); - $highmon_bar = weechat::bar_new ("highmon", "off", 100, "root", "", "bottom", "vertical", "vertical", 0, 0, "default", "cyan", "default", "on", "highmon"); + if (weechat::info_get("version_number", "") >= 0x02090000) + { + $highmon_bar = weechat::bar_new ("highmon", "off", 100, "root", "", "bottom", "vertical", "vertical", 0, 0, "default", "cyan", "default", "default", "on", "highmon"); + } + else + { + $highmon_bar = weechat::bar_new ("highmon", "off", 100, "root", "", "bottom", "vertical", "vertical", 0, 0, "default", "cyan", "default", "on", "highmon"); + } return weechat::WEECHAT_RC_OK; } @@ -285,7 +316,7 @@ sub highmon_buffer_open # Turn off notify, highlights if ($highmon_buffer ne "") { - if (weechat::config_get_plugin("hotlist_show" eq "off")) + if (weechat::config_get_plugin("hotlist_show") eq "off") { weechat::buffer_set($highmon_buffer, "notify", "0"); } @@ -296,6 +327,11 @@ sub highmon_buffer_open { weechat::buffer_set($highmon_buffer, "localvar_set_no_log", "1"); } + # send "logger_backlog" signal if logging is enabled to display backlog + if (weechat::config_get_plugin("logging") eq "on") + { + weechat::hook_signal_send("logger_backlog", weechat::WEECHAT_HOOK_SIGNAL_POINTER, $highmon_buffer) + } } return weechat::WEECHAT_RC_OK; } @@ -353,6 +389,15 @@ sub highmon_command_cb { highmon_config_clean($data, $buffer, $arg); } + # clearbar command + elsif ($cmd eq "clearbar") + { + if (weechat::config_get_plugin("output") eq "bar") + { + @bar_lines = (); + weechat::bar_item_update("highmon"); + } + } # Fix closed buffer elsif ($cmd eq "fix") { @@ -452,6 +497,15 @@ sub highmon_config_clean # Check config elements sub highmon_config_init { + # First run default + if (!(weechat::config_is_set_plugin ("first_run"))) + { + if (weechat::config_get_plugin("first_run") ne "true") + { + weechat::print("", "\tThis appears to be the first time highmon has been run. For help and common set up hints see /highmon help"); + weechat::config_set_plugin("first_run", "true"); + } + } # Alignment default if (!(weechat::config_is_set_plugin ("alignment"))) { @@ -638,7 +692,7 @@ sub highmon_hook weechat::hook_print("", "", "", 0, "highmon_new_message", ""); weechat::hook_command("highclean", "Highmon config clean up", "default|orphan|all", " default: Cleans all config entries with the default \"on\" value\n orphan: Cleans all config entries for channels you aren't currently joined\n all: Does both defaults and orphan", "default|orphan|all", "highmon_config_clean", ""); - weechat::hook_command("highmon", "Highmon help", "[help] | [monitor [channel [server]]] | [clean default|orphan|all]", " help: Print help on config options for highmon\n monitor: Toggles monitoring for a channel\n clean: Highmon config clean up (/highclean)", "help || monitor %(irc_channels) %(irc_servers) || clean default|orphan|all", "highmon_command_cb", ""); + weechat::hook_command("highmon", "Highmon help", "[help] | [monitor [channel [server]]] | [clean default|orphan|all] | clearbar", " help: Print help on config options for highmon\n monitor: Toggles monitoring for a channel\n clean: Highmon config clean up (/highclean)\nclearbar: Clear Highmon bar", "help || monitor %(irc_channels) %(irc_servers) || clean default|orphan|all || clearbar", "highmon_command_cb", ""); weechat::hook_config("plugins.var.perl.highmon.*", "highmon_config_cb", ""); weechat::hook_config("weechat.look.prefix_suffix", "highmon_config_cb", ""); @@ -671,7 +725,7 @@ sub highmon_new_message if ($cb_high == "1" || (weechat::config_get_plugin("merge_private") eq "on" && $cb_tags =~ /notify_private/)) { # Pre bug #29618 (0.3.3) away detect - if (weechat::info_get("version_number", "") <= 197120) + if (weechat::info_get("version_number", "") <= 0x00030200) { $away = ''; # Get infolist for this server @@ -718,7 +772,7 @@ sub highmon_new_message $nick = weechat::color("chat_highlight").$uncolnick.weechat::color("reset"); } # Send to output - highmon_print ($cb_msg, $cb_bufferp, $nick); + highmon_print ($cb_msg, $cb_bufferp, $nick, $cb_date, $cb_tags); } } # Or is private message @@ -729,7 +783,7 @@ sub highmon_new_message # Format nick $nick = " ".weechat::config_get_plugin("nick_prefix").weechat::color("chat_highlight").$uncolnick.weechat::color("reset").weechat::config_get_plugin("nick_suffix"); #Send to output - highmon_print ($cb_msg, $cb_bufferp, $nick); + highmon_print ($cb_msg, $cb_bufferp, $nick, $cb_date, $cb_tags); } } } @@ -742,6 +796,8 @@ sub highmon_print $cb_msg = $_[0]; my $cb_bufferp = $_[1] if ($_[1]); my $nick = $_[2] if ($_[2]); + my $cb_date = $_[3] if ($_[3]); + my $cb_tags = $_[4] if ($_[4]); #Normal channel message if ($cb_bufferp && $nick) @@ -844,21 +900,36 @@ sub highmon_print # Search for and confirm buffer $highmon_buffer = weechat::buffer_search("perl", "highmon"); # Print - weechat::print($highmon_buffer, $outstr); + if ($cb_date) + { + weechat::print_date_tags($highmon_buffer, $cb_date, $cb_tags, $outstr); + } + else + { + weechat::print($highmon_buffer, $outstr); + } } elsif (weechat::config_get_plugin("output") eq "bar") { # Add time string use POSIX qw(strftime); - $time = strftime(weechat::config_string(weechat::config_get("weechat.look.buffer_time_format")), localtime); + if ($cb_date) + { + $time = strftime(weechat::config_string(weechat::config_get("weechat.look.buffer_time_format")), localtime($cb_date)); + } + else + { + $time = strftime(weechat::config_string(weechat::config_get("weechat.look.buffer_time_format")), localtime); + } # Colourise - if ($time =~ /\$\{\w+\}/) # Coloured string + if ($time =~ /\$\{(?:color:)?[\w,]+\}/) # Coloured string { - while ($time =~ /\$\{(\w+)\}/) + while ($time =~ /\$\{(?:color:)?([\w,]+)\}/) { $color = weechat::color($1); - $time =~ s/\$\{\w+\}/$color/; + $time =~ s/\$\{(?:color:)?[\w,]+\}/$color/; } + $time .= weechat::color("reset"); } else # Default string { @@ -1068,7 +1139,7 @@ sub format_buffer_name } # Check result of register, and attempt to behave in a sane manner -if (!weechat::register("highmon", "KenjiE20", "2.3.3.2", "GPL3", "Highlight Monitor", "", "")) +if (!weechat::register("highmon", "KenjiE20", "2.7", "GPL3", "Highlight Monitor", "", "")) { # Double load weechat::print ("", "\tHighmon is already loaded");