Finish weechat setup
This commit is contained in:
parent
393ad37da8
commit
b670f92b52
|
@ -18,7 +18,7 @@ imports = [
|
|||
./modules/home-options.nix
|
||||
./modules/eventd.nix
|
||||
./modules/unlock.nix
|
||||
./modules/weechat.nix
|
||||
./modules/weechat
|
||||
../common/private-options.nix
|
||||
../common/secret
|
||||
# ./sort-mail.nix
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
in {
|
||||
|
||||
options.m-0.weechat = {
|
||||
enable = mkEnableOption "Weechat";
|
||||
channels = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
pw = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.m-0.weechat.enable {
|
||||
systemd.user.services = {
|
||||
weechat = {
|
||||
Unit = {
|
||||
Description = "Weechat IRC Client (in tmux)";
|
||||
};
|
||||
Service = {
|
||||
ExecStart = "${pkgs.tmux}/bin/tmux -L weechat -2 new-window -kt irc:0 '${pkgs.weechat}/bin/weechat'";
|
||||
ExecStop = "${pkgs.tmux}/bin/tmux -L weechat kill-window -t irc:0";
|
||||
};
|
||||
Install = {
|
||||
WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
weechat-tmux = {
|
||||
Unit = {
|
||||
Description = "Weechat Tmux Session";
|
||||
};
|
||||
Service = {
|
||||
ExecStart = "${pkgs.tmux}/bin/tmux -L weechat -2 new-window -d -s irc -n 'bash' '${pkgs.zsh}/bin/zsh'";
|
||||
ExecStop = "${pkgs.tmux}/bin/tmux -L weechat kill-window -t irc";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
86
home-manager/modules/weechat/default.nix
Normal file
86
home-manager/modules/weechat/default.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
in {
|
||||
|
||||
options.m-0.weechat = {
|
||||
enable = mkEnableOption "Weechat";
|
||||
channels = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
pw = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.m-0.weechat.enable {
|
||||
home.file = {
|
||||
python_plugins = {
|
||||
target = ".weechat/python";
|
||||
source = ./plugins/python;
|
||||
};
|
||||
perl_plugins = {
|
||||
target = ".weechat/perl";
|
||||
source = ./plugins/perl;
|
||||
};
|
||||
weechat = {
|
||||
target = ".weechat/weechat.conf";
|
||||
text = ''
|
||||
[color]
|
||||
chat_nick_colors = "cyan,magenta,green,brown,lightblue,default,lightcyan,lightmagenta,lightgreen,blue,31,35,38,40,49,63,70,80,92,99,112,126,130,138,142,148,160,162,167,169,174,176,178,184,186,210,212,215,228"
|
||||
|
||||
[network]
|
||||
gnutls_ca_file = "/etc/nixos/home-manager/modules/weechat/rootca.crt"
|
||||
'';
|
||||
};
|
||||
logger = {
|
||||
target = ".weechat/logger.conf";
|
||||
text = ''
|
||||
[look]
|
||||
backlog = 100
|
||||
|
||||
[file]
|
||||
mask = "$name/%Y"
|
||||
path = "${config.home.homeDirectory}/logs/"
|
||||
'';
|
||||
};
|
||||
irc = {
|
||||
target = ".weechat/irc.conf";
|
||||
text = ''
|
||||
[server]
|
||||
hackint.addresses = "irc.hackint.org/6697"
|
||||
hackint.ssl = on
|
||||
hackint.sasl_mechanism = plain
|
||||
hackint.sasl_username = "${config.m-0.weechat.user}"
|
||||
hackint.sasl_password = "${config.m-0.weechat.pw}"
|
||||
hackint.autoconnect = on
|
||||
hackint.username = "${config.m-0.weechat.user}"
|
||||
hackint.autojoin = "${config.m-0.weechat.channels}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services = {
|
||||
weechat = {
|
||||
Unit = {
|
||||
Description = "Weechat Tmux Session";
|
||||
};
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
KillMode = "none";
|
||||
ExecStart = "${pkgs.tmux}/bin/tmux -L weechat -2 new-session -d -s irc -n weechat '${pkgs.weechat}/bin/weechat'";
|
||||
ExecStop = "${pkgs.tmux}/bin/tmux -L weechat kill-session -t irc";
|
||||
};
|
||||
Install = {
|
||||
WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
../mass_hl_blocker.pl
|
41
home-manager/modules/weechat/plugins/perl/mass_hl_blocker.pl
Normal file
41
home-manager/modules/weechat/plugins/perl/mass_hl_blocker.pl
Normal file
|
@ -0,0 +1,41 @@
|
|||
# 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>
|
||||
|
||||
weechat::register('mass_hl_blocker', 'arza <arza\@arza.us>', '0.1', 'GPL3', 'Block mass highlights', '', '');
|
||||
|
||||
my $version=weechat::info_get('version_number', '') || 0;
|
||||
|
||||
my $limit=5;
|
||||
|
||||
if(weechat::config_is_set_plugin('limit')){ $limit=weechat::config_get_plugin('limit'); }
|
||||
else{ weechat::config_set_plugin('limit', $limit); }
|
||||
|
||||
if($version>=0x00030500){ weechat::config_set_desc_plugin('limit', 'minimum amount of nicks in line to disable highlight (default: 5)'); }
|
||||
|
||||
weechat::hook_config('plugins.var.perl.mass_highlight_block.limit', 'set_limit', '');
|
||||
weechat::hook_modifier('2000|weechat_print', 'block', '');
|
||||
|
||||
sub block { my $message=$_[3];
|
||||
|
||||
$_[2]=~/(\S+);(\S+)\.(\S+);(\S+)/ || return $message;
|
||||
my ($plugin, $server, $channel, $tags) = ($1, $2, $3, $4);
|
||||
index($message, weechat::info_get('irc_nick', $server)) != -1 && index($tags, 'notify_message') != -1 && index($tags, 'no_highlight') == -1 || return $message;
|
||||
|
||||
my $count=0;
|
||||
foreach my $word (split(' ', $message)){
|
||||
my $infolist=weechat::infolist_get('irc_nick', '', "$server,$channel,$word");
|
||||
if($infolist){ $count++; }
|
||||
weechat::infolist_free($infolist);
|
||||
}
|
||||
|
||||
if($count>=$limit){
|
||||
weechat::print_date_tags(weechat::buffer_search($plugin, "$server.$channel"), 0, "$tags,no_highlight", $message);
|
||||
return '';
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
sub set_limit {
|
||||
$limit=$_[2];
|
||||
return weechat::WEECHAT_RC_OK;
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2009 by xt <xt@bash.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# (this script requires WeeChat 0.3.0 or newer)
|
||||
#
|
||||
# History:
|
||||
# 2015-10-11, Simmo Saan <simmo.saan@gmail.com>
|
||||
# version 0.6: allow joining channels with keys in autojoin
|
||||
# 2013-12-21, Sebastien Helleu <flashcode@flashtux.org>
|
||||
# version 0.5: fix parsing of INVITE message
|
||||
# 2013-11-28, sakkemo <scajanus@gmail.com>
|
||||
# version 0.4: add whitelist for nicks/channels
|
||||
# 2009-11-09, xt <xt@bash.no>
|
||||
# version 0.3: add ignore option for channels
|
||||
# 2009-10-29, xt <xt@bash.no>
|
||||
# version 0.2: add ignore option
|
||||
# 2009-10-28, xt <xt@bash.no>
|
||||
# version 0.1: initial release
|
||||
|
||||
import weechat as w
|
||||
import re
|
||||
|
||||
SCRIPT_NAME = "autojoin_on_invite"
|
||||
SCRIPT_AUTHOR = "xt <xt@bash.no>"
|
||||
SCRIPT_VERSION = "0.6"
|
||||
SCRIPT_LICENSE = "GPL3"
|
||||
SCRIPT_DESC = "Auto joins channels when invited"
|
||||
|
||||
# script options
|
||||
settings = {
|
||||
'whitelist_nicks': '', # comma separated list of nicks,
|
||||
# overrides ignore_nicks
|
||||
'whitelist_channels': '', # comma separated list of channels,
|
||||
# overrides ignore_channels
|
||||
'ignore_nicks': '', # comma separated list of nicks
|
||||
#that we will not accept auto invite from
|
||||
'ignore_channels': '', # comma separated list of channels to not join
|
||||
'autojoin_key': 'on', # use channel keys from server's autojoin list
|
||||
}
|
||||
|
||||
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
|
||||
SCRIPT_DESC, "", ""):
|
||||
for option, default_value in settings.iteritems():
|
||||
if not w.config_is_set_plugin(option):
|
||||
w.config_set_plugin(option, default_value)
|
||||
|
||||
w.hook_signal('*,irc_in2_invite', 'invite_cb', '')
|
||||
|
||||
def join(server, channel):
|
||||
key = None
|
||||
|
||||
if w.config_string_to_boolean(w.config_get_plugin('autojoin_key')):
|
||||
autojoin = w.config_string(w.config_get('irc.server.%s.autojoin' % server)).split(' ', 1)
|
||||
|
||||
if len(autojoin) > 1: # any keys specified
|
||||
autojoin_keys = dict(zip(autojoin[0].split(','), autojoin[1].split(',')))
|
||||
key = autojoin_keys.get(channel) # defaults to None when not set
|
||||
|
||||
if key:
|
||||
w.command('', '/quote -server %s JOIN %s %s' % (server, channel, key))
|
||||
else:
|
||||
w.command('', '/quote -server %s JOIN %s' % (server, channel))
|
||||
|
||||
def invite_cb(data, signal, signal_data):
|
||||
server = signal.split(',')[0] # EFNet,irc_in_INVITE
|
||||
channel = signal_data.split()[-1].lstrip(':') # :nick!ident@host.name INVITE yournick :#channel
|
||||
from_nick = re.match(':(?P<nick>.+)!', signal_data).groups()[0]
|
||||
|
||||
if len(w.config_get_plugin('whitelist_nicks')) > 0 and len(w.config_get_plugin('whitelist_channels')) > 0: # if there's two whitelists, accept both
|
||||
if from_nick in w.config_get_plugin('whitelist_nicks').split(',') or channel in w.config_get_plugin('whitelist_channels').split(','):
|
||||
w.prnt('', 'Automatically joining %s on server %s, invitation from %s (whitelist).' \
|
||||
%(channel, server, from_nick))
|
||||
join(server, channel)
|
||||
else:
|
||||
w.prnt('', 'Ignoring invite from %s to channel %s. Neither inviter nor channel in whitelist.' %(from_nick, channel))
|
||||
|
||||
elif len(w.config_get_plugin('whitelist_nicks')) > 0: # if there's a whitelist, accept nicks in it
|
||||
if from_nick in w.config_get_plugin('whitelist_nicks').split(','):
|
||||
w.prnt('', 'Automatically joining %s on server %s, invitation from %s (whitelist).' \
|
||||
%(channel, server, from_nick))
|
||||
join(server, channel)
|
||||
else:
|
||||
w.prnt('', 'Ignoring invite from %s to channel %s. Inviter not in whitelist.' %(from_nick, channel))
|
||||
|
||||
elif len(w.config_get_plugin('whitelist_channels')) > 0: # if there's a whitelist, accept channels in it
|
||||
if channel in w.config_get_plugin('whitelist_channels').split(','):
|
||||
w.prnt('', 'Automatically joining %s on server %s, invitation from %s (whitelist).' \
|
||||
%(channel, server, from_nick))
|
||||
join(server, channel)
|
||||
else:
|
||||
w.prnt('', 'Ignoring invite from %s to channel %s. Channel not in whitelist.' %(from_nick, channel))
|
||||
|
||||
else: # use the ignore lists to make the decision
|
||||
if from_nick in w.config_get_plugin('ignore_nicks').split(','):
|
||||
w.prnt('', 'Ignoring invite from %s to channel %s. Invite from ignored inviter.' %(from_nick, channel))
|
||||
elif channel in w.config_get_plugin('ignore_channels').split(','):
|
||||
w.prnt('', 'Ignoring invite from %s to channel %s. Invite to ignored channel.' %(from_nick, channel))
|
||||
else:
|
||||
w.prnt('', 'Automatically joining %s on server %s, invitation from %s.' \
|
||||
%(channel, server, from_nick))
|
||||
join(server, channel)
|
||||
|
||||
return w.WEECHAT_RC_OK
|
|
@ -0,0 +1 @@
|
|||
../autojoin_on_invite.py
|
|
@ -0,0 +1 @@
|
|||
../buffer_autoclose.py
|
|
@ -0,0 +1 @@
|
|||
../colorize_nicks.py
|
1
home-manager/modules/weechat/plugins/python/autoload/grep.py
Symbolic link
1
home-manager/modules/weechat/plugins/python/autoload/grep.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
../grep.py
|
|
@ -0,0 +1 @@
|
|||
../topicdiff.py
|
|
@ -0,0 +1 @@
|
|||
../whois_on_query.py
|
137
home-manager/modules/weechat/plugins/python/buffer_autoclose.py
Normal file
137
home-manager/modules/weechat/plugins/python/buffer_autoclose.py
Normal file
|
@ -0,0 +1,137 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2009 by xt <xt@bash.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# (this script requires WeeChat 0.3.0 or newer)
|
||||
#
|
||||
# History:
|
||||
# 2018-04-10, Sébastien Helleu <flashcode@flashtux.org>
|
||||
# version 0.5: fix infolist_time for WeeChat >= 2.2 (WeeChat returns a long
|
||||
# integer instead of a string)
|
||||
# 2016-02-05, ixti
|
||||
# version 0.4: Add Python3 support
|
||||
# 2009-12-15, xt
|
||||
# version 0.3: moved around some control structures to not be as noisy
|
||||
# 2009-12-02, xt
|
||||
# version 0.2: bugfix, more printing
|
||||
# 2009-12-01, xt <xt@bash.no>
|
||||
# version 0.1: initial release
|
||||
|
||||
import weechat as w
|
||||
import time
|
||||
|
||||
SCRIPT_NAME = "buffer_autoclose"
|
||||
SCRIPT_AUTHOR = "xt <xt@bash.no>"
|
||||
SCRIPT_VERSION = "0.5"
|
||||
SCRIPT_LICENSE = "GPL3"
|
||||
SCRIPT_DESC = "Automatically close inactive private message buffers"
|
||||
|
||||
settings = {
|
||||
'interval': '1', # How often in minutes to check
|
||||
'age_limit': '30', # How old in minutes before auto close
|
||||
'ignore': '', # Buffers to ignore (use full name: server.buffer_name)
|
||||
}
|
||||
|
||||
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
|
||||
SCRIPT_DESC, "", ""):
|
||||
for option, default_value in settings.items():
|
||||
if not w.config_is_set_plugin(option):
|
||||
w.config_set_plugin(option, default_value)
|
||||
w.hook_timer(\
|
||||
int(w.config_get_plugin('interval')) * 1000 * 60,
|
||||
0,
|
||||
0,
|
||||
"close_time_cb",
|
||||
'')
|
||||
|
||||
|
||||
def get_all_buffers():
|
||||
'''Returns list with pointers of all open buffers.'''
|
||||
buffers = []
|
||||
infolist = w.infolist_get('buffer', '', '')
|
||||
while w.infolist_next(infolist):
|
||||
buffer_type = w.buffer_get_string(w.infolist_pointer(infolist, 'pointer'), 'localvar_type')
|
||||
if buffer_type == 'private': # we only close private message buffers for now
|
||||
buffers.append(w.infolist_pointer(infolist, 'pointer'))
|
||||
w.infolist_free(infolist)
|
||||
return buffers
|
||||
|
||||
def get_last_line_date(buffer):
|
||||
date = '1970-01-01 01:00:00'
|
||||
infolist = w.infolist_get('buffer_lines', buffer, '')
|
||||
while w.infolist_prev(infolist):
|
||||
date = w.infolist_time(infolist, 'date')
|
||||
# since WeeChat 2.2, infolist_time returns a long integer instead of
|
||||
# a string
|
||||
if not isinstance(date, str):
|
||||
date = time.strftime('%F %T', time.localtime(int(date)))
|
||||
if date != '1970-01-01 01:00:00':
|
||||
# Some lines like "Day changed to" message doesn't have date
|
||||
# set so loop until we find a message that does
|
||||
break
|
||||
w.infolist_free(infolist)
|
||||
return date
|
||||
|
||||
def is_in_hotlist(buffer):
|
||||
''' Returns true if buffer is in hotlist, false if not'''
|
||||
|
||||
hotlist = w.infolist_get('hotlist', '', '')
|
||||
found = False
|
||||
while w.infolist_next(hotlist):
|
||||
thebuffer = w.infolist_pointer(hotlist, 'buffer_pointer')
|
||||
if thebuffer == buffer:
|
||||
found = True
|
||||
name = w.buffer_get_string(thebuffer, 'short_name')
|
||||
break
|
||||
|
||||
w.infolist_free(hotlist)
|
||||
return found
|
||||
|
||||
def close_time_cb(buffer, args):
|
||||
''' Callback for check for inactivity and close '''
|
||||
|
||||
for buffer in get_all_buffers():
|
||||
name = w.buffer_get_string(buffer, 'name')
|
||||
|
||||
|
||||
date = get_last_line_date(buffer)
|
||||
date = time.mktime(time.strptime(date, '%Y-%m-%d %H:%M:%S'))
|
||||
now = time.time()
|
||||
seconds_old = now - date
|
||||
if seconds_old > int(w.config_get_plugin('age_limit'))*60:
|
||||
if is_in_hotlist(buffer):
|
||||
#w.prnt('', '%s: Not closing buffer: %s: it is in hotlist' %(SCRIPT_NAME, name))
|
||||
continue
|
||||
if name in w.config_get_plugin('ignore').split(','):
|
||||
#w.prnt('', '%s: Not closing buffer: %s: it is in ignore list' %(SCRIPT_NAME, name))
|
||||
continue
|
||||
if buffer == w.current_buffer():
|
||||
# Never close current buffer
|
||||
#w.prnt('', '%s: Not closing buffer: %s: it is in currently active' %(SCRIPT_NAME, name))
|
||||
continue
|
||||
if len(w.buffer_get_string(buffer, 'input')):
|
||||
# Don't close buffers with text on input line
|
||||
#w.prnt('', '%s: Not closing buffer: %s: it has input' %(SCRIPT_NAME, name))
|
||||
continue
|
||||
|
||||
w.prnt('', '%s: Closing buffer: %s' %(SCRIPT_NAME, name))
|
||||
w.command(buffer, '/buffer close')
|
||||
#else:
|
||||
# w.prnt('', '%s: Not closing buffer: %s: it is too new: %s' %(SCRIPT_NAME, name, seconds_old))
|
||||
|
||||
return w.WEECHAT_RC_OK
|
400
home-manager/modules/weechat/plugins/python/colorize_nicks.py
Normal file
400
home-manager/modules/weechat/plugins/python/colorize_nicks.py
Normal file
|
@ -0,0 +1,400 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2010 by xt <xt@bash.no>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# This script colors nicks in IRC channels in the actual message
|
||||
# not just in the prefix section.
|
||||
#
|
||||
#
|
||||
# History:
|
||||
# 2018-04-06: Joey Pabalinas <joeypabalinas@gmail.com>
|
||||
# version 26: fix freezes with too many nicks in one line
|
||||
# 2018-03-18: nils_2
|
||||
# version 25: fix unable to run function colorize_config_reload_cb()
|
||||
# 2017-06-20: lbeziaud <louis.beziaud@ens-rennes.fr>
|
||||
# version 24: colorize utf8 nicks
|
||||
# 2017-03-01, arza <arza@arza.us>
|
||||
# version 23: don't colorize nicklist group names
|
||||
# 2016-05-01, Simmo Saan <simmo.saan@gmail.com>
|
||||
# version 22: invalidate cached colors on hash algorithm change
|
||||
# 2015-07-28, xt
|
||||
# version 21: fix problems with nicks with commas in them
|
||||
# 2015-04-19, xt
|
||||
# version 20: fix ignore of nicks in URLs
|
||||
# 2015-04-18, xt
|
||||
# version 19: new option ignore nicks in URLs
|
||||
# 2015-03-03, xt
|
||||
# version 18: iterate buffers looking for nicklists instead of servers
|
||||
# 2015-02-23, holomorph
|
||||
# version 17: fix coloring in non-channel buffers (#58)
|
||||
# 2014-09-17, holomorph
|
||||
# version 16: use weechat config facilities
|
||||
# clean unused, minor linting, some simplification
|
||||
# 2014-05-05, holomorph
|
||||
# version 15: fix python2-specific re.search check
|
||||
# 2013-01-29, nils_2
|
||||
# version 14: make script compatible with Python 3.x
|
||||
# 2012-10-19, ldvx
|
||||
# version 13: Iterate over every word to prevent incorrect colorization of
|
||||
# nicks. Added option greedy_matching.
|
||||
# 2012-04-28, ldvx
|
||||
# version 12: added ignore_tags to avoid colorizing nicks if tags are present
|
||||
# 2012-01-14, nesthib
|
||||
# version 11: input_text_display hook and modifier to colorize nicks in input bar
|
||||
# 2010-12-22, xt
|
||||
# version 10: hook config option for updating blacklist
|
||||
# 2010-12-20, xt
|
||||
# version 0.9: hook new config option for weechat 0.3.4
|
||||
# 2010-11-01, nils_2
|
||||
# version 0.8: hook_modifier() added to communicate with rainbow_text
|
||||
# 2010-10-01, xt
|
||||
# version 0.7: changes to support non-irc-plugins
|
||||
# 2010-07-29, xt
|
||||
# version 0.6: compile regexp as per patch from Chris quigybo@hotmail.com
|
||||
# 2010-07-19, xt
|
||||
# version 0.5: fix bug with incorrect coloring of own nick
|
||||
# 2010-06-02, xt
|
||||
# version 0.4: update to reflect API changes
|
||||
# 2010-03-26, xt
|
||||
# version 0.3: fix error with exception
|
||||
# 2010-03-24, xt
|
||||
# version 0.2: use ignore_channels when populating to increase performance.
|
||||
# 2010-02-03, xt
|
||||
# version 0.1: initial (based on ruby script by dominikh)
|
||||
#
|
||||
# Known issues: nicks will not get colorized if they begin with a character
|
||||
# such as ~ (which some irc networks do happen to accept)
|
||||
|
||||
import weechat
|
||||
import re
|
||||
w = weechat
|
||||
|
||||
SCRIPT_NAME = "colorize_nicks"
|
||||
SCRIPT_AUTHOR = "xt <xt@bash.no>"
|
||||
SCRIPT_VERSION = "26"
|
||||
SCRIPT_LICENSE = "GPL"
|
||||
SCRIPT_DESC = "Use the weechat nick colors in the chat area"
|
||||
|
||||
# Based on the recommendations in RFC 7613. A valid nick is composed
|
||||
# of anything but " ,*?.!@".
|
||||
VALID_NICK = r'([@~&!%+-])?([^\s,\*?\.!@]+)'
|
||||
valid_nick_re = re.compile(VALID_NICK)
|
||||
ignore_channels = []
|
||||
ignore_nicks = []
|
||||
|
||||
# Dict with every nick on every channel with its color as lookup value
|
||||
colored_nicks = {}
|
||||
|
||||
CONFIG_FILE_NAME = "colorize_nicks"
|
||||
|
||||
# config file and options
|
||||
colorize_config_file = ""
|
||||
colorize_config_option = {}
|
||||
|
||||
def colorize_config_init():
|
||||
'''
|
||||
Initialization of configuration file.
|
||||
Sections: look.
|
||||
'''
|
||||
global colorize_config_file, colorize_config_option
|
||||
colorize_config_file = weechat.config_new(CONFIG_FILE_NAME,
|
||||
"", "")
|
||||
if colorize_config_file == "":
|
||||
return
|
||||
|
||||
# section "look"
|
||||
section_look = weechat.config_new_section(
|
||||
colorize_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "")
|
||||
if section_look == "":
|
||||
weechat.config_free(colorize_config_file)
|
||||
return
|
||||
colorize_config_option["blacklist_channels"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "blacklist_channels",
|
||||
"string", "Comma separated list of channels", "", 0, 0,
|
||||
"", "", 0, "", "", "", "", "", "")
|
||||
colorize_config_option["blacklist_nicks"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "blacklist_nicks",
|
||||
"string", "Comma separated list of nicks", "", 0, 0,
|
||||
"so,root", "so,root", 0, "", "", "", "", "", "")
|
||||
colorize_config_option["min_nick_length"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "min_nick_length",
|
||||
"integer", "Minimum length nick to colorize", "",
|
||||
2, 20, "", "", 0, "", "", "", "", "", "")
|
||||
colorize_config_option["colorize_input"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "colorize_input",
|
||||
"boolean", "Whether to colorize input", "", 0,
|
||||
0, "off", "off", 0, "", "", "", "", "", "")
|
||||
colorize_config_option["ignore_tags"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "ignore_tags",
|
||||
"string", "Comma separated list of tags to ignore; i.e. irc_join,irc_part,irc_quit", "", 0, 0,
|
||||
"", "", 0, "", "", "", "", "", "")
|
||||
colorize_config_option["greedy_matching"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "greedy_matching",
|
||||
"boolean", "If off, then use lazy matching instead", "", 0,
|
||||
0, "on", "on", 0, "", "", "", "", "", "")
|
||||
colorize_config_option["match_limit"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "match_limit",
|
||||
"integer", "Fall back to lazy matching if greedy matches exceeds this number", "",
|
||||
20, 1000, "", "", 0, "", "", "", "", "", "")
|
||||
colorize_config_option["ignore_nicks_in_urls"] = weechat.config_new_option(
|
||||
colorize_config_file, section_look, "ignore_nicks_in_urls",
|
||||
"boolean", "If on, don't colorize nicks inside URLs", "", 0,
|
||||
0, "off", "off", 0, "", "", "", "", "", "")
|
||||
|
||||
def colorize_config_read():
|
||||
''' Read configuration file. '''
|
||||
global colorize_config_file
|
||||
return weechat.config_read(colorize_config_file)
|
||||
|
||||
def colorize_nick_color(nick, my_nick):
|
||||
''' Retrieve nick color from weechat. '''
|
||||
if nick == my_nick:
|
||||
return w.color(w.config_string(w.config_get('weechat.color.chat_nick_self')))
|
||||
else:
|
||||
return w.info_get('irc_nick_color', nick)
|
||||
|
||||
def colorize_cb(data, modifier, modifier_data, line):
|
||||
''' Callback that does the colorizing, and returns new line if changed '''
|
||||
|
||||
global ignore_nicks, ignore_channels, colored_nicks
|
||||
|
||||
|
||||
full_name = modifier_data.split(';')[1]
|
||||
channel = '.'.join(full_name.split('.')[1:])
|
||||
|
||||
buffer = w.buffer_search('', full_name)
|
||||
# Check if buffer has colorized nicks
|
||||
if buffer not in colored_nicks:
|
||||
return line
|
||||
|
||||
if channel and channel in ignore_channels:
|
||||
return line
|
||||
|
||||
min_length = w.config_integer(colorize_config_option['min_nick_length'])
|
||||
reset = w.color('reset')
|
||||
|
||||
# Don't colorize if the ignored tag is present in message
|
||||
tags_line = modifier_data.rsplit(';')
|
||||
if len(tags_line) >= 3:
|
||||
tags_line = tags_line[2].split(',')
|
||||
for i in w.config_string(colorize_config_option['ignore_tags']).split(','):
|
||||
if i in tags_line:
|
||||
return line
|
||||
|
||||
for words in valid_nick_re.findall(line):
|
||||
nick = words[1]
|
||||
# Check that nick is not ignored and longer than minimum length
|
||||
if len(nick) < min_length or nick in ignore_nicks:
|
||||
continue
|
||||
|
||||
# If the matched word is not a known nick, we try to match the
|
||||
# word without its first or last character (if not a letter).
|
||||
# This is necessary as "foo:" is a valid nick, which could be
|
||||
# adressed as "foo::".
|
||||
if nick not in colored_nicks[buffer]:
|
||||
if not nick[-1].isalpha() and not nick[0].isalpha():
|
||||
if nick[1:-1] in colored_nicks[buffer]:
|
||||
nick = nick[1:-1]
|
||||
elif not nick[0].isalpha():
|
||||
if nick[1:] in colored_nicks[buffer]:
|
||||
nick = nick[1:]
|
||||
elif not nick[-1].isalpha():
|
||||
if nick[:-1] in colored_nicks[buffer]:
|
||||
nick = nick[:-1]
|
||||
|
||||
# Check that nick is in the dictionary colored_nicks
|
||||
if nick in colored_nicks[buffer]:
|
||||
nick_color = colored_nicks[buffer][nick]
|
||||
|
||||
try:
|
||||
# Let's use greedy matching. Will check against every word in a line.
|
||||
if w.config_boolean(colorize_config_option['greedy_matching']):
|
||||
cnt = 0
|
||||
limit = w.config_integer(colorize_config_option['match_limit'])
|
||||
|
||||
for word in line.split():
|
||||
cnt += 1
|
||||
assert cnt < limit
|
||||
# if cnt > limit:
|
||||
# raise RuntimeError('Exceeded colorize_nicks.look.match_limit.');
|
||||
|
||||
if w.config_boolean(colorize_config_option['ignore_nicks_in_urls']) and \
|
||||
word.startswith(('http://', 'https://')):
|
||||
continue
|
||||
|
||||
if nick in word:
|
||||
# Is there a nick that contains nick and has a greater lenght?
|
||||
# If so let's save that nick into var biggest_nick
|
||||
biggest_nick = ""
|
||||
for i in colored_nicks[buffer]:
|
||||
cnt += 1
|
||||
assert cnt < limit
|
||||
|
||||
if nick in i and nick != i and len(i) > len(nick):
|
||||
if i in word:
|
||||
# If a nick with greater len is found, and that word
|
||||
# also happens to be in word, then let's save this nick
|
||||
biggest_nick = i
|
||||
# If there's a nick with greater len, then let's skip this
|
||||
# As we will have the chance to colorize when biggest_nick
|
||||
# iterates being nick.
|
||||
if len(biggest_nick) > 0 and biggest_nick in word:
|
||||
pass
|
||||
elif len(word) < len(biggest_nick) or len(biggest_nick) == 0:
|
||||
new_word = word.replace(nick, '%s%s%s' % (nick_color, nick, reset))
|
||||
line = line.replace(word, new_word)
|
||||
|
||||
# Switch to lazy matching
|
||||
else:
|
||||
raise AssertionError
|
||||
|
||||
except AssertionError:
|
||||
# Let's use lazy matching for nick
|
||||
nick_color = colored_nicks[buffer][nick]
|
||||
# The two .? are in case somebody writes "nick:", "nick,", etc
|
||||
# to address somebody
|
||||
regex = r"(\A|\s).?(%s).?(\Z|\s)" % re.escape(nick)
|
||||
match = re.search(regex, line)
|
||||
if match is not None:
|
||||
new_line = line[:match.start(2)] + nick_color+nick+reset + line[match.end(2):]
|
||||
line = new_line
|
||||
|
||||
return line
|
||||
|
||||
def colorize_input_cb(data, modifier, modifier_data, line):
|
||||
''' Callback that does the colorizing in input '''
|
||||
|
||||
global ignore_nicks, ignore_channels, colored_nicks
|
||||
|
||||
min_length = w.config_integer(colorize_config_option['min_nick_length'])
|
||||
|
||||
if not w.config_boolean(colorize_config_option['colorize_input']):
|
||||
return line
|
||||
|
||||
buffer = w.current_buffer()
|
||||
# Check if buffer has colorized nicks
|
||||
if buffer not in colored_nicks:
|
||||
return line
|
||||
|
||||
channel = w.buffer_get_string(buffer, 'name')
|
||||
if channel and channel in ignore_channels:
|
||||
return line
|
||||
|
||||
reset = w.color('reset')
|
||||
|
||||
for words in valid_nick_re.findall(line):
|
||||
nick = words[1]
|
||||
# Check that nick is not ignored and longer than minimum length
|
||||
if len(nick) < min_length or nick in ignore_nicks:
|
||||
continue
|
||||
if nick in colored_nicks[buffer]:
|
||||
nick_color = colored_nicks[buffer][nick]
|
||||
line = line.replace(nick, '%s%s%s' % (nick_color, nick, reset))
|
||||
|
||||
return line
|
||||
|
||||
def populate_nicks(*args):
|
||||
''' Fills entire dict with all nicks weechat can see and what color it has
|
||||
assigned to it. '''
|
||||
global colored_nicks
|
||||
|
||||
colored_nicks = {}
|
||||
|
||||
buffers = w.infolist_get('buffer', '', '')
|
||||
while w.infolist_next(buffers):
|
||||
buffer_ptr = w.infolist_pointer(buffers, 'pointer')
|
||||
my_nick = w.buffer_get_string(buffer_ptr, 'localvar_nick')
|
||||
nicklist = w.infolist_get('nicklist', buffer_ptr, '')
|
||||
while w.infolist_next(nicklist):
|
||||
if buffer_ptr not in colored_nicks:
|
||||
colored_nicks[buffer_ptr] = {}
|
||||
|
||||
if w.infolist_string(nicklist, 'type') != 'nick':
|
||||
continue
|
||||
|
||||
nick = w.infolist_string(nicklist, 'name')
|
||||
nick_color = colorize_nick_color(nick, my_nick)
|
||||
|
||||
colored_nicks[buffer_ptr][nick] = nick_color
|
||||
|
||||
w.infolist_free(nicklist)
|
||||
|
||||
w.infolist_free(buffers)
|
||||
|
||||
return w.WEECHAT_RC_OK
|
||||
|
||||
def add_nick(data, signal, type_data):
|
||||
''' Add nick to dict of colored nicks '''
|
||||
global colored_nicks
|
||||
|
||||
# Nicks can have , in them in some protocols
|
||||
splitted = type_data.split(',')
|
||||
pointer = splitted[0]
|
||||
nick = ",".join(splitted[1:])
|
||||
if pointer not in colored_nicks:
|
||||
colored_nicks[pointer] = {}
|
||||
|
||||
my_nick = w.buffer_get_string(pointer, 'localvar_nick')
|
||||
nick_color = colorize_nick_color(nick, my_nick)
|
||||
|
||||
colored_nicks[pointer][nick] = nick_color
|
||||
|
||||
return w.WEECHAT_RC_OK
|
||||
|
||||
def remove_nick(data, signal, type_data):
|
||||
''' Remove nick from dict with colored nicks '''
|
||||
global colored_nicks
|
||||
|
||||
# Nicks can have , in them in some protocols
|
||||
splitted = type_data.split(',')
|
||||
pointer = splitted[0]
|
||||
nick = ",".join(splitted[1:])
|
||||
|
||||
if pointer in colored_nicks and nick in colored_nicks[pointer]:
|
||||
del colored_nicks[pointer][nick]
|
||||
|
||||
return w.WEECHAT_RC_OK
|
||||
|
||||
def update_blacklist(*args):
|
||||
''' Set the blacklist for channels and nicks. '''
|
||||
global ignore_channels, ignore_nicks
|
||||
ignore_channels = w.config_string(colorize_config_option['blacklist_channels']).split(',')
|
||||
ignore_nicks = w.config_string(colorize_config_option['blacklist_nicks']).split(',')
|
||||
return w.WEECHAT_RC_OK
|
||||
|
||||
if __name__ == "__main__":
|
||||
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
|
||||
SCRIPT_DESC, "", ""):
|
||||
colorize_config_init()
|
||||
colorize_config_read()
|
||||
|
||||
# Run once to get data ready
|
||||
update_blacklist()
|
||||
populate_nicks()
|
||||
|
||||
w.hook_signal('nicklist_nick_added', 'add_nick', '')
|
||||
w.hook_signal('nicklist_nick_removed', 'remove_nick', '')
|
||||
w.hook_modifier('weechat_print', 'colorize_cb', '')
|
||||
# Hook config for changing colors
|
||||
w.hook_config('weechat.color.chat_nick_colors', 'populate_nicks', '')
|
||||
w.hook_config('weechat.look.nick_color_hash', 'populate_nicks', '')
|
||||
# Hook for working togheter with other scripts (like colorize_lines)
|
||||
w.hook_modifier('colorize_nicks', 'colorize_cb', '')
|
||||
# Hook for modifying input
|
||||
w.hook_modifier('250|input_text_display', 'colorize_input_cb', '')
|
||||
# Hook for updating blacklist (this could be improved to use fnmatch)
|
||||
weechat.hook_config('%s.look.blacklist*' % SCRIPT_NAME, 'update_blacklist', '')
|
1746
home-manager/modules/weechat/plugins/python/grep.py
Normal file
1746
home-manager/modules/weechat/plugins/python/grep.py
Normal file
File diff suppressed because it is too large
Load diff
106
home-manager/modules/weechat/plugins/python/topicdiff.py
Normal file
106
home-manager/modules/weechat/plugins/python/topicdiff.py
Normal file
|
@ -0,0 +1,106 @@
|
|||
# Show differences between old and new topics
|
||||
# Author: Dafydd Harries <daf@rhydd.org>
|
||||
# License: GPL3
|
||||
|
||||
import re
|
||||
|
||||
from itertools import izip_longest
|
||||
|
||||
import weechat
|
||||
|
||||
SCRIPT_NAME = "topicdiff"
|
||||
SCRIPT_AUTHOR = "Dafydd Harries <daf@rhydd.org>"
|
||||
SCRIPT_VERSION = "0.3"
|
||||
SCRIPT_LICENSE = "GPL3"
|
||||
SCRIPT_DESC = "Show differences between old and new topics."
|
||||
|
||||
pending_change_buffer = None
|
||||
topics = {}
|
||||
|
||||
def topic_chunks(s):
|
||||
return re.split(r'\s+[-~|]+\s+', s)
|
||||
|
||||
def topic_changed(buffer, new_topic):
|
||||
if buffer in topics:
|
||||
old_chunks = topic_chunks(topics[buffer])
|
||||
new_chunks = topic_chunks(new_topic)
|
||||
|
||||
for old_chunk, new_chunk in izip_longest(old_chunks, new_chunks):
|
||||
if old_chunk and old_chunk not in new_chunks:
|
||||
weechat.prnt(buffer, '%s-\t%s' % (
|
||||
weechat.color('red'),
|
||||
old_chunk
|
||||
))
|
||||
|
||||
if new_chunk and new_chunk not in old_chunks:
|
||||
weechat.prnt(buffer, '%s+\t%s' % (
|
||||
weechat.color('green'),
|
||||
new_chunk
|
||||
))
|
||||
|
||||
topics[buffer] = new_topic
|
||||
|
||||
def print_332(data, buffer, time, tags, displayed, highlight, prefix, message):
|
||||
#weechat.prnt('', 'print: %r' % (a,))
|
||||
global pending_change_buffer
|
||||
pending_change_buffer = buffer
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
def print_topic(
|
||||
data, buffer, time, tags, displayed, highlight, prefix, message):
|
||||
global pending_change_buffer
|
||||
pending_change_buffer = buffer
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
def irc_in2_332(data, tags, msg):
|
||||
global pending_change_buffer
|
||||
|
||||
if pending_change_buffer is None:
|
||||
# Hmm, that's weird.
|
||||
#weechat.prnt('', 'no pending buffer :(')
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
match = re.match(r':\S+ 332 \S+ \S+ :(.*)', msg)
|
||||
|
||||
if not match:
|
||||
#weechat.prnt('', 'no match :(')
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
new_topic = match.group(1)
|
||||
topic_changed(pending_change_buffer, new_topic)
|
||||
pending_change_buffer = None
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
def irc_in2_topic(data, tags, msg):
|
||||
global pending_change_buffer
|
||||
|
||||
#weechat.prnt('', '%r' % ((tags, msg),))
|
||||
|
||||
if pending_change_buffer is None:
|
||||
# Hmm, that's weird.
|
||||
#weechat.prnt('', 'no pending buffer :(')
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
match = re.match(r':\S+ TOPIC \S+ :(.*)', msg)
|
||||
|
||||
if not match:
|
||||
#weechat.prnt('', 'no match :(')
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
new_topic = match.group(1)
|
||||
topic_changed(pending_change_buffer, new_topic)
|
||||
pending_change_buffer = None
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
def register():
|
||||
weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
|
||||
SCRIPT_LICENSE, SCRIPT_DESC, '', '')
|
||||
|
||||
weechat.hook_print('', 'irc_332', '', 1, 'print_332', '')
|
||||
weechat.hook_print('', 'irc_topic', '', 1, 'print_topic', '')
|
||||
weechat.hook_signal('*,irc_in2_332', 'irc_in2_332', '')
|
||||
weechat.hook_signal('*,irc_in2_topic', 'irc_in2_topic', '')
|
||||
|
||||
if __name__ == '__main__':
|
||||
register()
|
||||
|
119
home-manager/modules/weechat/plugins/python/whois_on_query.py
Normal file
119
home-manager/modules/weechat/plugins/python/whois_on_query.py
Normal file
|
@ -0,0 +1,119 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009-2012 Sebastien Helleu <flashcode@flashtux.org>
|
||||
# Copyright (C) 2011 Elián Hanisch <lambdae2@gmail.com>
|
||||
# Copyright (C) 2011 ArZa <arza@arza.us>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# Send "whois" on nick when receiving (or opening) new IRC query.
|
||||
# (this script requires WeeChat 0.3.2 or newer)
|
||||
#
|
||||
# History:
|
||||
#
|
||||
# 2017-05-28, Jos Ahrens <buughost@gmail.com>:
|
||||
# version 0.6.1: Corrected a typo in help description for option self_query
|
||||
# 2012-01-03, Sebastien Helleu <flashcode@flashtux.org>:
|
||||
# version 0.6: make script compatible with Python 3.x
|
||||
# 2011-10-17, Sebastien Helleu <flashcode@flashtux.org>:
|
||||
# version 0.5: add option "self_query" to do whois on self query,
|
||||
# add help for options (WeeChat >= 0.3.5)
|
||||
# 2011-07-06, ArZa <arza@arza.us>:
|
||||
# version 0.4: fix target buffer for command
|
||||
# 2011-05-31, Elián Hanisch <lambdae2@gmail.com>:
|
||||
# version 0.3: depends on WeeChat 0.3.2
|
||||
# use irc_is_nick instead of irc_is_channel.
|
||||
# only /whois when somebody opens a query with you.
|
||||
# 2009-05-02, Sebastien Helleu <flashcode@flashtux.org>:
|
||||
# version 0.2: sync with last API changes
|
||||
# 2009-02-08, Sebastien Helleu <flashcode@flashtux.org>:
|
||||
# version 0.1: initial release
|
||||
#
|
||||
|
||||
try:
|
||||
import weechat
|
||||
from weechat import WEECHAT_RC_OK, prnt
|
||||
import_ok = True
|
||||
except ImportError:
|
||||
print('This script must be run under WeeChat.')
|
||||
print('Get WeeChat now at: http://www.weechat.org/')
|
||||
import_ok = False
|
||||
|
||||
SCRIPT_NAME = 'whois_on_query'
|
||||
SCRIPT_AUTHOR = 'Sebastien Helleu <flashcode@flashtux.org>'
|
||||
SCRIPT_VERSION = '0.6.1'
|
||||
SCRIPT_LICENSE = 'GPL3'
|
||||
SCRIPT_DESC = 'Whois on query'
|
||||
|
||||
# script options
|
||||
woq_settings_default = {
|
||||
'command' : ('/whois $nick $nick', 'the command sent to do the whois ($nick is replaced by nick)'),
|
||||
'self_query': ('off', 'if on, send whois for self queries'),
|
||||
}
|
||||
|
||||
irc_pv_hook = ''
|
||||
|
||||
def unhook_irc_pv():
|
||||
"""Remove irc_pv hook."""
|
||||
global irc_pv_hook
|
||||
if irc_pv_hook:
|
||||
weechat.unhook(irc_pv_hook)
|
||||
irc_pv_hook = ''
|
||||
|
||||
def exec_command(buffer, nick):
|
||||
"""Execute the whois command."""
|
||||
command = weechat.config_get_plugin('command').replace('$nick', nick)
|
||||
weechat.command(buffer, command)
|
||||
|
||||
def signal_irc_pv_opened(data, signal, signal_data):
|
||||
"""Callback for signal 'irc_pv_opened'."""
|
||||
global irc_pv_hook
|
||||
if weechat.buffer_get_string(signal_data, 'plugin') == 'irc':
|
||||
nick = weechat.buffer_get_string(signal_data, 'localvar_channel')
|
||||
if weechat.info_get('irc_is_nick', nick) == '1':
|
||||
unhook_irc_pv()
|
||||
if weechat.config_get_plugin('self_query') == 'on':
|
||||
exec_command(signal_data, nick)
|
||||
else:
|
||||
# query open, wait for a msg to come (query was open by user) or if we send a msg out
|
||||
# (query was open by us)
|
||||
server = weechat.buffer_get_string(signal_data, 'localvar_server')
|
||||
irc_pv_hook = weechat.hook_signal('irc_pv', 'signal_irc_pv',
|
||||
'%s,%s' % (signal_data, nick))
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
def signal_irc_pv(data, signal, signal_data):
|
||||
"""Callback for signal 'irc_pv'."""
|
||||
buffer, nick = data.split(',')
|
||||
if signal_data.startswith(':' + nick + '!'):
|
||||
# ok, run command
|
||||
exec_command(buffer, nick)
|
||||
unhook_irc_pv()
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
if __name__ == '__main__' and import_ok:
|
||||
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
|
||||
SCRIPT_DESC, '', ''):
|
||||
# set default settings
|
||||
version = weechat.info_get('version_number', '') or 0
|
||||
for option, value in woq_settings_default.items():
|
||||
if not weechat.config_is_set_plugin(option):
|
||||
weechat.config_set_plugin(option, value[0])
|
||||
if int(version) >= 0x00030500:
|
||||
weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))
|
||||
|
||||
# hook signal 'irc_pv_opened'
|
||||
weechat.hook_signal('irc_pv_opened', 'signal_irc_pv_opened', '')
|
125
home-manager/modules/weechat/rootca.crt
Normal file
125
home-manager/modules/weechat/rootca.crt
Normal file
|
@ -0,0 +1,125 @@
|
|||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 11988360117959724374 (0xa65f36029e730d56)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: O=Hackint IRC Network, OU=http://www.hackint.org, CN=Hackint IRC Network Root CA/emailAddress=ca@hackint.org
|
||||
Validity
|
||||
Not Before: Jul 1 00:00:00 2015 GMT
|
||||
Not After : Dec 31 23:59:59 2035 GMT
|
||||
Subject: O=Hackint IRC Network, OU=http://www.hackint.org, CN=Hackint IRC Network Root CA/emailAddress=ca@hackint.org
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
Public-Key: (4096 bit)
|
||||
Modulus:
|
||||
00:e2:e7:b3:d6:18:b1:cc:7f:19:4d:ca:3b:57:51:
|
||||
2e:28:60:ae:fb:f8:2d:41:c8:9b:73:88:35:98:6c:
|
||||
48:9a:9a:b9:98:6c:e6:77:ba:4c:df:1f:89:c7:1c:
|
||||
e2:ee:02:24:08:4f:c4:f0:f2:05:57:33:0e:b0:08:
|
||||
da:65:01:43:74:98:02:10:86:1b:b5:d0:fc:2c:04:
|
||||
b8:df:eb:7f:05:fc:d4:cf:cc:19:b3:88:c6:72:ca:
|
||||
e4:ab:bf:20:24:66:9e:8a:b6:fe:43:01:7c:a6:21:
|
||||
5e:82:ec:b9:95:c2:12:62:a8:2e:7e:60:50:b5:25:
|
||||
b6:49:b7:cc:06:ad:ec:3f:60:ba:eb:a1:85:09:9b:
|
||||
49:fb:16:95:bf:12:45:2b:97:77:10:38:72:15:e7:
|
||||
11:65:f4:bc:51:e3:18:7f:94:2d:40:b8:0b:1a:c2:
|
||||
ff:2f:6b:14:05:1a:2b:a7:db:91:78:8d:de:a5:fc:
|
||||
4b:df:d2:da:fa:db:c9:29:11:71:f8:86:ca:64:78:
|
||||
db:10:87:db:94:52:98:f1:0a:93:50:aa:1e:d6:ca:
|
||||
2d:4c:fd:08:62:2b:d1:85:b8:e0:dd:d3:0b:14:ef:
|
||||
b8:8e:7d:c7:09:97:71:55:7f:f6:e3:2d:c3:bd:08:
|
||||
e3:0b:38:15:9a:26:01:29:24:c3:70:8f:6b:81:93:
|
||||
ba:4c:29:27:30:dd:2d:aa:be:da:81:c5:fe:d5:b5:
|
||||
fb:e5:c8:f7:97:e4:2e:fe:5c:25:d7:56:20:45:71:
|
||||
8b:9b:ce:63:65:36:ae:67:de:a1:1b:30:6e:2d:ab:
|
||||
07:71:47:83:21:6e:1c:b8:06:13:86:90:53:5d:51:
|
||||
1b:1f:e0:de:3b:4e:f3:d5:e9:e8:25:1c:f2:dc:d3:
|
||||
9b:98:bc:be:55:21:d7:4d:c4:7d:63:ae:9c:55:61:
|
||||
7e:fa:29:7b:e9:47:8f:af:51:36:18:56:2f:26:d8:
|
||||
0e:11:7f:e2:4c:23:90:84:2d:f8:9e:d9:c8:60:86:
|
||||
18:a8:8c:0b:8a:0e:e2:9f:99:6d:ef:f9:f9:2e:1a:
|
||||
48:c4:0b:90:3c:35:fc:c3:ec:43:86:24:1d:a8:b0:
|
||||
06:ca:3f:aa:f1:ef:bb:55:b8:0a:34:78:c3:cb:1e:
|
||||
28:e9:81:87:22:5c:81:a8:a6:bc:2a:16:b8:ed:b6:
|
||||
f4:5a:32:41:b2:c3:02:ea:e8:90:f2:7c:1f:21:32:
|
||||
f3:2f:99:53:e7:ab:1e:33:6e:63:9a:4b:f5:2d:da:
|
||||
2a:d5:c1:4d:24:f6:38:83:37:6f:5d:4e:f7:37:c9:
|
||||
21:f0:5b:46:dd:f8:bb:79:7d:62:43:0c:bf:e5:6f:
|
||||
68:ad:f1:9f:29:25:89:99:c2:dd:5e:ee:f9:78:2c:
|
||||
d7:66:d9
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Basic Constraints: critical
|
||||
CA:TRUE
|
||||
X509v3 Subject Key Identifier:
|
||||
15:99:CF:BE:19:58:9C:1D:0E:C8:E0:50:E9:3E:46:5D:AF:79:CD:0B
|
||||
X509v3 Key Usage: critical
|
||||
Certificate Sign, CRL Sign
|
||||
Authority Information Access:
|
||||
CA Issuers - URI:http://hackint.org/ca.html
|
||||
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
1b:cd:a1:76:62:e9:7e:f1:bb:45:86:ed:09:be:85:e2:ef:05:
|
||||
04:5c:6f:cd:1e:18:7b:99:ce:3c:12:9a:03:e0:87:03:e2:86:
|
||||
49:c9:c1:16:0f:c4:f9:a3:08:f8:84:37:8f:84:a0:6a:bd:0c:
|
||||
64:ac:2e:e5:f2:37:11:37:58:45:e5:d6:b5:2b:84:df:f5:27:
|
||||
4f:d5:35:7d:f5:13:4c:db:8a:c2:41:4c:de:9e:5b:ca:b5:73:
|
||||
82:61:77:7c:8e:da:48:01:72:a1:af:3c:c6:5e:91:fd:fc:e3:
|
||||
5e:b5:c2:a7:e7:82:cb:fb:44:2d:39:9a:d9:64:61:f9:53:91:
|
||||
09:7d:fd:ee:1f:85:15:5b:b1:dc:9b:5f:04:3f:ba:b9:6e:77:
|
||||
30:e9:8d:bd:27:76:86:77:62:f1:1a:55:6e:09:25:31:f5:16:
|
||||
c5:cc:0a:cf:e4:7d:ed:05:e1:36:8a:47:df:72:75:ae:64:66:
|
||||
f7:f4:54:69:d2:a3:0a:18:88:7b:ec:cc:fd:e6:49:50:f3:9b:
|
||||
22:a8:82:68:23:ff:a9:50:31:ae:ec:07:4e:2f:04:b6:93:45:
|
||||
35:30:8e:c5:ed:25:c1:9e:a5:54:d2:d6:ba:7e:f3:63:7f:af:
|
||||
93:43:ee:93:a2:aa:9d:f0:65:34:62:b5:40:3c:64:4d:02:c8:
|
||||
2d:d8:06:a3:95:90:d7:56:0d:a0:c9:87:1b:3b:4b:81:9b:62:
|
||||
58:b1:8b:36:14:eb:b4:02:11:34:ab:9c:de:cc:34:04:e9:6f:
|
||||
fa:8b:22:1f:e2:af:0c:db:d1:2a:e7:dc:d9:e3:64:68:67:cb:
|
||||
ab:b4:c9:76:18:80:2b:68:0a:91:86:00:43:9c:df:0c:1c:12:
|
||||
b2:96:ed:0a:cb:33:62:01:00:8a:7d:cf:aa:84:14:74:6f:1f:
|
||||
fb:82:38:f4:4d:31:4b:b3:d6:40:4e:f9:7b:b2:7d:30:29:c4:
|
||||
95:0c:40:3d:69:3d:c6:e6:61:b6:47:96:50:7b:24:a4:28:eb:
|
||||
34:ee:e4:dd:db:21:57:47:eb:9f:63:b1:3e:d4:a0:42:38:ed:
|
||||
67:14:0a:41:96:33:41:f3:e4:8f:f7:95:b8:5c:16:c5:06:3d:
|
||||
a5:97:4e:92:ee:df:44:66:da:2c:4c:93:6d:01:d9:5b:cd:36:
|
||||
ae:09:9a:2f:1c:48:b5:64:0a:a9:9c:46:d5:96:bb:46:52:a8:
|
||||
e1:6b:ab:f5:91:ae:60:a3:00:12:73:e6:84:98:f6:2a:59:97:
|
||||
24:06:88:75:01:7a:2c:0d:cd:4b:42:af:a5:6b:4e:7e:b8:da:
|
||||
6a:ba:07:1c:e5:27:af:10:71:08:19:5f:a0:1a:70:c3:7a:fb:
|
||||
24:14:06:39:52:bd:e5:2c
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIGBzCCA++gAwIBAgIJAKZfNgKecw1WMA0GCSqGSIb3DQEBCwUAMIGEMRwwGgYD
|
||||
VQQKExNIYWNraW50IElSQyBOZXR3b3JrMR8wHQYDVQQLExZodHRwOi8vd3d3Lmhh
|
||||
Y2tpbnQub3JnMSQwIgYDVQQDExtIYWNraW50IElSQyBOZXR3b3JrIFJvb3QgQ0Ex
|
||||
HTAbBgkqhkiG9w0BCQEWDmNhQGhhY2tpbnQub3JnMB4XDTE1MDcwMTAwMDAwMFoX
|
||||
DTM1MTIzMTIzNTk1OVowgYQxHDAaBgNVBAoTE0hhY2tpbnQgSVJDIE5ldHdvcmsx
|
||||
HzAdBgNVBAsTFmh0dHA6Ly93d3cuaGFja2ludC5vcmcxJDAiBgNVBAMTG0hhY2tp
|
||||
bnQgSVJDIE5ldHdvcmsgUm9vdCBDQTEdMBsGCSqGSIb3DQEJARYOY2FAaGFja2lu
|
||||
dC5vcmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDi57PWGLHMfxlN
|
||||
yjtXUS4oYK77+C1ByJtziDWYbEiamrmYbOZ3ukzfH4nHHOLuAiQIT8Tw8gVXMw6w
|
||||
CNplAUN0mAIQhhu10PwsBLjf638F/NTPzBmziMZyyuSrvyAkZp6Ktv5DAXymIV6C
|
||||
7LmVwhJiqC5+YFC1JbZJt8wGrew/YLrroYUJm0n7FpW/EkUrl3cQOHIV5xFl9LxR
|
||||
4xh/lC1AuAsawv8vaxQFGiun25F4jd6l/Evf0tr628kpEXH4hspkeNsQh9uUUpjx
|
||||
CpNQqh7Wyi1M/QhiK9GFuODd0wsU77iOfccJl3FVf/bjLcO9COMLOBWaJgEpJMNw
|
||||
j2uBk7pMKScw3S2qvtqBxf7VtfvlyPeX5C7+XCXXViBFcYubzmNlNq5n3qEbMG4t
|
||||
qwdxR4Mhbhy4BhOGkFNdURsf4N47TvPV6eglHPLc05uYvL5VIddNxH1jrpxVYX76
|
||||
KXvpR4+vUTYYVi8m2A4Rf+JMI5CELfie2chghhiojAuKDuKfmW3v+fkuGkjEC5A8
|
||||
NfzD7EOGJB2osAbKP6rx77tVuAo0eMPLHijpgYciXIGoprwqFrjttvRaMkGywwLq
|
||||
6JDyfB8hMvMvmVPnqx4zbmOaS/Ut2irVwU0k9jiDN29dTvc3ySHwW0bd+Lt5fWJD
|
||||
DL/lb2it8Z8pJYmZwt1e7vl4LNdm2QIDAQABo3oweDAPBgNVHRMBAf8EBTADAQH/
|
||||
MB0GA1UdDgQWBBQVmc++GVicHQ7I4FDpPkZdr3nNCzAOBgNVHQ8BAf8EBAMCAQYw
|
||||
NgYIKwYBBQUHAQEEKjAoMCYGCCsGAQUFBzAChhpodHRwOi8vaGFja2ludC5vcmcv
|
||||
Y2EuaHRtbDANBgkqhkiG9w0BAQsFAAOCAgEAG82hdmLpfvG7RYbtCb6F4u8FBFxv
|
||||
zR4Ye5nOPBKaA+CHA+KGScnBFg/E+aMI+IQ3j4Sgar0MZKwu5fI3ETdYReXWtSuE
|
||||
3/UnT9U1ffUTTNuKwkFM3p5byrVzgmF3fI7aSAFyoa88xl6R/fzjXrXCp+eCy/tE
|
||||
LTma2WRh+VORCX397h+FFVux3JtfBD+6uW53MOmNvSd2hndi8RpVbgklMfUWxcwK
|
||||
z+R97QXhNopH33J1rmRm9/RUadKjChiIe+zM/eZJUPObIqiCaCP/qVAxruwHTi8E
|
||||
tpNFNTCOxe0lwZ6lVNLWun7zY3+vk0Puk6KqnfBlNGK1QDxkTQLILdgGo5WQ11YN
|
||||
oMmHGztLgZtiWLGLNhTrtAIRNKuc3sw0BOlv+osiH+KvDNvRKufc2eNkaGfLq7TJ
|
||||
dhiAK2gKkYYAQ5zfDBwSspbtCsszYgEAin3PqoQUdG8f+4I49E0xS7PWQE75e7J9
|
||||
MCnElQxAPWk9xuZhtkeWUHskpCjrNO7k3dshV0frn2OxPtSgQjjtZxQKQZYzQfPk
|
||||
j/eVuFwWxQY9pZdOku7fRGbaLEyTbQHZW802rgmaLxxItWQKqZxG1Za7RlKo4Wur
|
||||
9ZGuYKMAEnPmhJj2KlmXJAaIdQF6LA3NS0KvpWtOfrjaaroHHOUnrxBxCBlfoBpw
|
||||
w3r7JBQGOVK95Sw=
|
||||
-----END CERTIFICATE-----
|
|
@ -1,8 +1,16 @@
|
|||
{ pkgs, ... }:
|
||||
{ pkgs, config, ... }:
|
||||
{
|
||||
|
||||
imports = [
|
||||
../../home-manager
|
||||
./secret
|
||||
];
|
||||
|
||||
m-0.weechat = {
|
||||
enable = true;
|
||||
user = config.m-0.private.hackint.user;
|
||||
pw = config.m-0.private.hackint.hackint_pw;
|
||||
channels = config.m-0.private.hackint.channels;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
BIN
hosts/hera/secret/default.nix
Normal file
BIN
hosts/hera/secret/default.nix
Normal file
Binary file not shown.
Loading…
Reference in a new issue