-
-
Save paoloantinori/9cc616ac004a89c67237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Copyright 2014 Alex Wood | |
# | |
# 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/>. | |
# Place this file in ~/.config/xchat2 and XChat will auto-load it. | |
import xchat | |
__module_name__ = "hush" | |
__module_version__ = "1.0" | |
__module_description__ = "Silence join and nick change messages" | |
hooks = [] | |
def toggle_cb(word, word_eol, userdata): | |
global hooks | |
if len(word) < 2 or word[1].lower() not in ['on', 'off', 'status']: | |
xchat.prnt("Please provide a command: 'on', 'off', or 'status'") | |
return xchat.EAT_ALL | |
command = word[1].lower() | |
if command == "on": | |
hooks.append(xchat.hook_print("Change Nick", hush_cb)) | |
hooks.append(xchat.hook_print("Join", hush_cb)) | |
xchat.prnt("Loaded Hush") | |
return xchat.EAT_ALL | |
elif command == "off": | |
if hooks: | |
map(xchat.unhook, hooks) | |
hooks = [] | |
xchat.prnt("Unloaded Hush") | |
else: | |
xchat.prnt("Hush is already off") | |
return xchat.EAT_ALL | |
elif command == "status": | |
xchat.prnt("Hush is %s" % bool(hooks)) | |
return xchat.EAT_ALL | |
def hush_cb(word, work_eol, userdata): | |
return xchat.EAT_XCHAT | |
xchat.hook_command("HUSH", toggle_cb, | |
help="/HUSH <on|off|status> Turn off joins and nick changes") | |
toggle_cb(['HUSH', 'on'], None, None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment