Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.9 KiB

4 years ago
  1. ###############################################################################
  2. #
  3. # Copyright (c) 2008 by GolemJ <golemj@gmail.com>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19. ###############################################################################
  20. #
  21. # Log highlights msg to core buffer
  22. # You need to set "notify" to "yes" and "command" to proper command to run
  23. # external command. You also need "shell" script to run external command.
  24. #
  25. # History:
  26. # 2010-06-20, GolemJ <golemj@gmail.com>
  27. # version 0.8, add posibility to execute command for notification
  28. # 2010-02-14, Emmanuel Bouthenot <kolter@openics.org>
  29. # version 0.7, add colors and notifications support
  30. # 2009-05-02, FlashCode <flashcode@flashtux.org>:
  31. # version 0.6, sync with last API changes
  32. # 2008-11-30, GolemJ <golemj@gmail.com>:
  33. # version 0.5, conversion to WeeChat 0.3.0+
  34. #
  35. ###############################################################################
  36. use strict;
  37. weechat::register( "awaylog", "Jiri Golembiovsky", "0.8", "GPL", "Prints highlights to core buffer", "", "" );
  38. weechat::hook_print( "", "", "", 1, "highlight_cb", "" );
  39. if( weechat::config_get_plugin( "on_away_only" ) eq "" ) {
  40. weechat::config_set_plugin( "on_away_only", "off" );
  41. }
  42. if( weechat::config_get_plugin( "plugin_color" ) eq "" ) {
  43. weechat::config_set_plugin( "plugin_color", "default" );
  44. }
  45. if( weechat::config_get_plugin( "name_color" ) eq "" ) {
  46. weechat::config_set_plugin( "name_color", "default" );
  47. }
  48. if( weechat::config_get_plugin( "notify" ) eq "" ) {
  49. weechat::config_set_plugin( "notify", "off" );
  50. }
  51. if( weechat::config_get_plugin( "command" ) eq "") {
  52. weechat::config_set_plugin( "command", "" );
  53. }
  54. sub highlight_cb {
  55. if( $_[5] == 1 ) {
  56. my $away = weechat::buffer_get_string($_[1], "localvar_away");
  57. if (($away ne "") || (weechat::config_get_plugin( "on_away_only" ) ne "on"))
  58. {
  59. my $buffer_color = weechat::color(weechat::config_get_plugin( "plugin_color"))
  60. . weechat::buffer_get_string($_[1], "plugin")
  61. . "."
  62. . weechat::buffer_get_string($_[1], "name")
  63. . weechat::color("default");
  64. my $buffer = weechat::buffer_get_string($_[1], "plugin")
  65. . "."
  66. . weechat::buffer_get_string($_[1], "name");
  67. my $name_color = weechat::color(weechat::config_get_plugin( "name_color"))
  68. . $_[6]
  69. . weechat::color("default");
  70. my $name = $_[6];
  71. my $message_color = "${buffer_color} -- ${name_color} :: $_[7]";
  72. my $message = "${buffer} -- ${name} :: $_[7]";
  73. if( weechat::config_get_plugin( "notify" ) ne "on" ) {
  74. my $command = weechat::config_get_plugin( "command" );
  75. if( $command ne "" ) {
  76. if( $command =~ /\$msg/ ) {
  77. $command =~ s/\$msg/\'$message\'/;
  78. } else {
  79. $command = "$command '$message'";
  80. }
  81. weechat::command( "", "/shell $command" );
  82. } else {
  83. weechat::print("", $message_color);
  84. }
  85. } else {
  86. weechat::print_date_tags("", 0, "notify_highlight", $message_color);
  87. }
  88. }
  89. }
  90. return weechat::WEECHAT_RC_OK;
  91. }