From c06e64a6556f1703f9455ad91299c521ad8b3ed8 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Wed, 5 Oct 2016 11:06:16 +0200 Subject: weechat: I give up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Löthberg --- weechat/python/autojoin_on_invite.py | 102 ++ weechat/python/chanop.py | 3236 ---------------------------------- weechat/python/colorize_nicks.py | 14 +- weechat/python/go.py | 10 +- weechat/python/infolist.py | 195 ++ weechat/python/listbuffer.py | 467 +++++ weechat/python/nsb.py | 113 ++ 7 files changed, 896 insertions(+), 3241 deletions(-) create mode 100644 weechat/python/autojoin_on_invite.py delete mode 100644 weechat/python/chanop.py create mode 100644 weechat/python/infolist.py create mode 100644 weechat/python/listbuffer.py create mode 100644 weechat/python/nsb.py (limited to 'weechat/python') diff --git a/weechat/python/autojoin_on_invite.py b/weechat/python/autojoin_on_invite.py new file mode 100644 index 0000000..cdaeaf0 --- /dev/null +++ b/weechat/python/autojoin_on_invite.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2009 by xt +# +# 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 . +# + +# +# (this script requires WeeChat 0.3.0 or newer) +# +# History: +# 2013-12-21, Sebastien Helleu +# version 0.5: fix parsing of INVITE message +# 2013-11-28, sakkemo +# version 0.4: add whitelist for nicks/channels +# 2009-11-09, xt +# version 0.3: add ignore option for channels +# 2009-10-29, xt +# version 0.2: add ignore option +# 2009-10-28, xt +# version 0.1: initial release + +import weechat as w +import re + +SCRIPT_NAME = "autojoin_on_invite" +SCRIPT_AUTHOR = "xt " +SCRIPT_VERSION = "0.5" +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 +} + +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 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.+)!', 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)) + w.command('', '/quote -server %s JOIN %s' % (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)) + w.command('', '/quote -server %s JOIN %s' % (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)) + w.command('', '/quote -server %s JOIN %s' % (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)) + w.command('', '/quote -server %s JOIN %s' % (server, channel)) + + return w.WEECHAT_RC_OK diff --git a/weechat/python/chanop.py b/weechat/python/chanop.py deleted file mode 100644 index 848837e..0000000 --- a/weechat/python/chanop.py +++ /dev/null @@ -1,3236 +0,0 @@ -# -*- coding: utf-8 -*- -### -# Copyright (c) 2009-2013 by Elián Hanisch -# -# 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 . -### - -### -# Helper script for IRC Channel Operators -# -# Inspired by auto_bleh.pl (irssi) and chanserv.py (xchat) scripts. -# -# Networks like Freenode and some channels encourage operators to not stay -# permanently with +o privileges and only use it when needed. This script -# works along those lines, requesting op, kick/ban/etc and deop -# automatically with a single command. -# Still this script is very configurable and its behaviour can be configured -# in a per server or per channel basis so it can fit most needs without -# changing its code. -# -# Features several completions for ban/quiet masks and a memory for channel -# masks and users (so users that parted are still bannable by nick). -# -# -# Commands (see detailed help with /help in WeeChat): -# * /oop: Request or give op. -# * /odeop: Drop or remove op. -# * /okick: Kick user (or users). -# * /oban: Apply ban mask. -# * /ounban: Remove ban mask. -# * /oquiet: Apply quiet mask. -# * /ounquiet: Remove quiet mask. -# * /obankick: Ban and kick user (or users) -# * /otopic: Change channel topic -# * /omode: Change channel modes -# * /olist: List cached masks (bans or quiets) -# * /ovoice: Give voice to user -# * /odevoice: Remove voice from user -# -# -# Settings: -# Most configs (unless noted otherwise) can be defined for a server or a -# channel in particular, so it is possible to request op in different -# networks, stay always op'ed in one channel while -# auto-deop in another. -# -# For define an option for a specific server use: -# /set plugins.var.python.chanop.