# -*- coding: utf-8 -*- # # Copyright (C) 2013 Germain Z. # # 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 . # # # Redirects ChanServ's welcome notices to the intended channel's buffer. # # History: # version 0.1: initial release # import weechat SCRIPT_NAME = "welcome_notice_redirect" SCRIPT_AUTHOR = "GermainZ" SCRIPT_VERSION = "0.1" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = ("Redirects ChanServ's welcome notices to the intended" "channel's buffer") def notice_cb(data, modifier, modifier_data, string): """Callback for received notices. Change the receiver of the notice from the user to the intended channel, and remove the [#channel] part from it. """ msg = string.split(' ') sender = msg[0].split('!')[0][1:] receiver = msg[2] nick = weechat.info_get("irc_nick", modifier_data) if (receiver == nick and sender == "ChanServ" and msg[3].startswith(':[') and msg[3].endswith(']')): chan = msg.pop(3)[2:-1] msg[3] = ":%s" % msg[3] msg[2] = "%s" % chan return ' '.join(msg) weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '') weechat.hook_modifier("irc_in_notice", "notice_cb", '')