def find_sound_directory(self): current_directory = hexchat.get_pluginpref("soundalert_dir") if current_directory and os.path.isdir(current_directory): return current_directory else: if os.name == "nt": paths = [ "C:\\Program Files\\HexChat\\share\\sounds", "C:\\Program Files (x86)\\HexChat\\share\\sounds", os.path.join(os.getenv('appdata'), "HexChat\\sounds") ] elif os.name == "posix": paths = [ "/sbin/HexChat/share/sounds", "/usr/sbin/HexChat/share/sounds", "/usr/local/bin/HexChat/share/sounds" ] else: return False for path in paths: if os.path.isdir(path): hexchat.set_pluginpref("soundalert_dir", path) return path return False
def commands(self, word, word_eol, userdata): if len(word) < 2: hexchat.prnt("Not enough arguments given. See /help soundalert") else: if word[1] == "set": if len(word) < 3: hexchat.prnt("No directory specified.") if os.path.isdir(word_eol[2]): hexchat.set_pluginpref("soundalert_dir", word_eol[2]) self.sound_directory = self.find_sound_directory() self.file_list = self.find_sounds() else: hexchat.prnt("Not a valid directory.") elif word[1] == "on": self.enable() elif word[1] == "off": self.disable() elif word[1] == "get": hexchat.prnt("Currently set sound directory: {}".format( hexchat.get_pluginpref("soundalert_dir"))) elif word[1] == "test": self.debug = True self.spawn(None, None, None) else: hexchat.prnt("No such command exists.") return hexchat.EAT_ALL
def onCommand(words, words_eol, userdata): if (len(words) < 2): print(command_help) else: if words[1] == 'config': if len(words) > 2: if words[2] == 'help': result = '\n'.join([' \002' + key + '\002 => ' + value for key, value in available_config.items()]) print('Available configuration:\n\n' + result) elif words[2] == 'set': if (len(words) < 5): print(command_help) else: hexchat.set_pluginpref(config_prefix + words[3], words_eol[4]) print('\002' + words[3] + '\002 has been set to \002' + words_eol[4] + '\002') elif words[2] == 'unset': if (len(words) < 4): print(command_help) else: hexchat.del_pluginpref(config_prefix + words[3]) print('\002' + words[3] + '\002 has been unset') else: print(command_help) else: prefs_list = hexchat.list_pluginpref() result = '{\n' for pref in prefs_list: if pref[:9] == config_prefix: result = result + ' \002' + pref[len(config_prefix):] + '\002\00314 : \003\002' + hexchat.get_pluginpref(pref) + '\002\n' result = result + '}' print(result) else: print('wat') return hexchat.EAT_ALL
def commands(self, word, word_eol, userdata): if len(word) < 2: hexchat.prnt("Not enough arguments given. See /help soundalert") else: if word[1] == "set": if len(word) < 3: hexchat.prnt("No directory specified.") if os.path.isdir(word_eol[2]): hexchat.set_pluginpref("soundalert_dir", word_eol[2]) self.sound_directory = self.find_sound_directory() self.file_list = self.find_sounds() else: hexchat.prnt("Not a valid directory.") elif word[1] == "on": self.enable() elif word[1] == "off": self.disable() elif word[1] == "get": hexchat.prnt("Currently set sound directory: {}".format(hexchat.get_pluginpref("soundalert_dir"))) elif word[1] == "test": self.debug = True self.spawn(None, None, None) else: hexchat.prnt("No such command exists.") return hexchat.EAT_ALL
def shign_load_list(word=None,word_eol=None,userdata=None): global shign_prefix global shign_pluginpref_list global shign_list global shign_list_last_idx All_Prefs = hexchat.list_pluginpref() shign_pluginpref_list = [] shign_list = [] shign_list_last_idx = 0 if len(All_Prefs) == 0: #print('empty') #list is empty shign_list = [['shign1','All']] hexchat.set_pluginpref('shign1','All') shign_list_last_idx = 1 return for Prefs in All_Prefs: if Prefs.find(shign_prefix) != -1: #if the prefix is found shign_pluginpref_list.append(Prefs) #append to the list of prefs if int(Prefs[5:]) > shign_list_last_idx: shign_list_last_idx = int(Prefs[5:]) #print(shignpreflist) for shign_pluginpref in shign_pluginpref_list: temp_list = hexchat.get_pluginpref(shign_pluginpref).split() temp_list.insert(0, shign_pluginpref) shign_list.append(temp_list) print(__module_name__+'\tList loaded!')
def init_options(): """Initialize global options dict from client.""" global OPTIONS for opt, attr in DEFAULT_OPTIONS.items(): xchat_opt = '_'.join((__module_name__, opt)) if isinstance(attr[1], str): value = attr[1] else: value = ' '.join(attr[1]) desc = '{} (default: "{}")'.format(attr[0], value) if WEECHAT: weechat.config_set_desc_plugin(opt, desc) plugin_pref = weechat.config_is_set_plugin(opt) else: cmd_name = ''.join(('WVM', opt.upper())) xchat.hook_command(cmd_name, xchat_update_option_cb, userdata=opt, help='/{} -- {}'.format(cmd_name, desc)) plugin_pref = xchat.get_pluginpref(xchat_opt) if plugin_pref: value = weechat.config_get_plugin(opt) if WEECHAT else \ xchat.get_pluginpref(xchat_opt) if not isinstance(DEFAULT_OPTIONS[opt][1], str): value = list(map(str.strip, value.split())) set_option(opt, value) else: if WEECHAT: weechat.config_set_plugin(opt, value) else: xchat.set_pluginpref(xchat_opt, value) set_option(opt, attr[1])
def add_alias(name, cmd): hexchat.set_pluginpref('alias_' + name, cmd) hook = hexchat.hook_command(name, alias_cmd_cb, help='Alias: "{}" is an alias for "{}"'.format(name, get_alias(name))) alias_hooks[name] = hook if hook: return True return False
def setter(self, value): self.value = value hexchat.set_pluginpref("queercraft_{}".format(self.name), str(value)) if value and self.statusmsg.get("true", None): hexchat.prnt(self.statusmsg["true"]) elif (not value) and self.statusmsg.get("false", None): hexchat.prnt(self.statusmsg["false"])
def toggle_bookmark(chan, net): # It's a toggle because /menu sucks if chan == None: chan = hexchat.get_info('channel') if chan == '': return if net == None: try: # If from a $TAB it may be a different network. net = hexchat.find_context(None, chan).get_info('network') except AttributeError: net = hexchat.get_info('network') for channel in hexchat.get_list('channels'): if channel.channel == chan: if channel.type != 2: # Only bookmark channels return networks = get_networks(chan) pref = 'bookmark_' + chan if net in networks: # Remove if len(networks) == 1: hexchat.del_pluginpref(pref) else: networks.remove(net) hexchat.set_pluginpref(pref, ','.join(networks)) hexchat.command('menu del "Bookmarks/{}/{}"'.format(net, chan)) else: # Add networks.append(net) hexchat.set_pluginpref(pref, ','.join(networks)) hexchat.command('menu -p-2 add "Bookmarks/{}'.format(net)) hexchat.command('menu add "Bookmarks/{0}/{1}" "netjoin {1} {0}"'.format(net, chan))
def cleanOldVer(): if hexchat.get_pluginpref('lfmnwo_user'): hexchat.set_pluginpref('lastfm_user', hexchat.get_pluginpref('lfmnwo_user')) hexchat.del_pluginpref('lfmnwo_user') if hexchat.get_pluginpref('lfmnwo_apikey'): hexchat.del_pluginpref('lfmnwo_apikey') return
def find_sound_directory(self): if hexchat.get_pluginpref("soundalert_dir") != None: return hexchat.get_pluginpref("soundalert_dir") else: if os.name == "nt": paths = [ "C:\Program Files\HexChat\share\sounds", "C:\Program Files (x86)\HexChat\share\sounds", "%appdata%\HexChat\sounds" ] elif os.name == "posix": paths = [ "/sbin/HexChat/share/sounds", "/usr/sbin/HexChat/share/sounds", "/usr/local/bin/HexChat/share/sounds" ] else: return False for path in paths: if os.path.isdir(path): hexchat.set_pluginpref("soundalert_dir", path) return path return False
def save_session(userdata): # Saves the network|channels dictionary in pluginpref networks = {} channels = hexchat.get_list('channels') if not hexchat.get_context(): return # Build dictionary 'networks' # Iterate 'channels' and add all the servers for chan in channels: if chan.type == 1: networks[chan.network] = [] # Iterate 'channels' and add channels. # networks={'freenode':[chan1, chan2, chan3], 'dalnet':[]} for chan in channels: if chan.type == 2 or chan.type == 3: # Ignore notices and server tabs networks[chan.network].append(chan.channel) # Iterate 'networks' and store in hexchat.pluginpref as # session_freenode = chan1,chan2. This is written to # 'addon_python.conf' eventually. for network, channels in networks.items(): if len(network): hexchat.set_pluginpref('session_' + network, ','.join(channels)) return hexchat.EAT_ALL
def save_pref(resp_list): for pref in hexchat.list_pluginpref(): if pref.startswith(ELEM_PREFIX): hexchat.del_pluginpref(pref) for resp in resp_list: for rpk, rpv in resp.getPrefs().items(): hexchat.set_pluginpref(rpk, rpv)
def command(self, word, word_eol, userdata): if (len(word) > 1): newValue = word_eol[1] self.value = newValue if self.pluginpref: hexchat.set_pluginpref(self.pluginpref, newValue) hexchat.prnt(word[0].upper() + ': ' + str(self.value)) return hexchat.EAT_ALL
def switch_network(word): if len(word) == 3 and word[2] in DEFAULT_PROXY: hexchat.set_pluginpref("privacy_network", word[2]) hexchat.set_pluginpref("privacy_proxy", DEFAULT_PROXY[word[2]]) configure_hexchat() print("Switched network to", word[2]) else: do_help()
def savelist(): global ignorelist global botlist ignorelist = list(filter(None, ignorelist)) hexchat.set_pluginpref('ignorelist', str(ignorelist)) hexchat.set_pluginpref('botlist', str(botlist)) loadlist() printlist()
def serverchange(word, word_eol, userdata): if len(word) == 1: formattedprint('Current mpd hostname is \'%s\'.' % hexchat.get_pluginpref('mpdnp_server')) if len(word) == 2: formattedprint('mpd host changed to \'%s\'.' % word[1]) hexchat.set_pluginpref('mpdnp_server', word[1])
def command(self, word, word_eol, userdata): if (len(word)>1): newValue = word_eol[1] self.value = newValue if self.pluginpref: hexchat.set_pluginpref(self.pluginpref, newValue) hexchat.prnt( word[0].upper() + ': ' + str(self.value)) return hexchat.EAT_ALL
def portchange(word, word_eol, userdata): if len(word) == 1: formattedprint('Current mpd port is %s.' % hexchat.get_pluginpref('mpdnp_port')) if len(word) == 2: formattedprint('mpd port changed to %s.' % word[1]) hexchat.set_pluginpref('mpdnp_port', word[1])
def soakerlistadd(word, word_eol, userdata): ignoreList = hexchat.get_pluginpref('soakbotignorelist') if ignoreList != 'None': hexchat.set_pluginpref('soakbotignorelist', '%s %s' % (ignoreList, word_eol[1].lower())) else: hexchat.set_pluginpref('soakbotignorelist', '%s' % word_eol[1].lower()) print('%s added to the ignore list' % ', '.join(word_eol[1].split(' '))) return hexchat.EAT_ALL
def mxtmPrefs(word, word_eol, userdata): if word[1] == 'enable': hexchat.set_pluginpref('mxtm', 'yes') print('mxtm enabled') elif word[1] == 'disable': hexchat.del_pluginpref('mxtm') print('mxtm disabled >:') return hexchat.EAT_ALL
def chgcooldown(word, word_eol, userdata): if len(word) == 1: hexchat.emit_print("Notice", "AutoUB [PL]", "Current cooldown is %s seconds." % str( hexchat.get_pluginpref('aub_cooldown'))) return hexchat.EAT_ALL hexchat.set_pluginpref('aub_cooldown', word[1]) hexchat.emit_print("Notice", "AutoUB [PL]", "Cooldown set to %s seconds." % str( hexchat.get_pluginpref('aub_cooldown')))
def unignore(word, word_to_eol, userdata): unignoretarget = word[1] try: _ignorelist.remove(unignoretarget) print("Unignoring {}".format(unignoretarget)) hexchat.set_pluginpref("greyignore", ",".join(_ignorelist)) except ValueError: print("{} not found in ignore list".format(unignoretarget)) return hexchat.EAT_ALL
def setname_cmd(word, word_eol, userdata): global nickname if len(word) > 1: hexchat.set_pluginpref(__module_name__ + "name", word_eol[1]) nickname = word_eol[1] print("opvoice name set to:", getname()) else: print("Provide a name. Usage: O_SETNAME <Name>") return hexchat.EAT_ALL
def ignore(word, word_to_eol, userdata): ignoretarget = word[1] for user in _ignorelist: if hexchat.nickcmp(user, ignoretarget) == 0: print("User {} already in ignore list".format(ignoretarget)) return hexchat.EAT_ALL print("Ignoring {}".format(ignoretarget)) _ignorelist.append(ignoretarget) hexchat.set_pluginpref("greyignore", ",".join(_ignorelist)) return hexchat.EAT_ALL
def add_alias(name, cmd): hexchat.set_pluginpref('alias_' + name, cmd) hook = hexchat.hook_command(name, alias_cmd_cb, help='Alias: "{}" is an alias for "{}"'.format( name, get_alias(name))) alias_hooks[name] = hook if hook: return True return False
def saveconfig(): config = { "allowednets": allowednets, "sendvisual": sendvisual, "blockvisual": blockvisual, "whoistimeout": whois_timeout, "snotetimeout": snote_timeout, "snotespecific": snote_specific_timeout } hexchat.set_pluginpref(__module_name__ + "_config", json.dumps(config))
def __init__(self): hexchat.prnt("Razer Alert plugin loaded.") if hexchat.get_pluginpref("razeralert_active") is None: hexchat.set_pluginpref("razeralert_active", True) if not hexchat.get_pluginpref("razeralert_active"): hexchat.prnt("Alerts are currently disabled. Re-enable them with /alertson") self.blink = False
def __init__(self, prefix, defaults, write_defaults=True): self.prefix = prefix self.defaults = defaults self._initialized = True if write_defaults: for name, default in defaults.items(): key = '_'.join((prefix, name)) if hexchat.get_pluginpref(key) is None: hexchat.set_pluginpref(key, json.dumps(default))
def togglealerts(word, word_eol, userdata): setting = hexchat.get_pluginpref('aub_alertsenabled') if setting: hexchat.emit_print( "Notice", "AutoUB [PL]", "You have disabled alerts. To turn them on, /aubtogglealerts") else: hexchat.emit_print( "Notice", "AutoUB [PL]", "You have enabled alerts. To turn them off, /aubtogglealerts") hexchat.set_pluginpref('aub_alertsenabled', str(1 - setting)) return hexchat.EAT_ALL
def set_option(word): if len(word) == 2: for l in [x for x in hexchat.list_pluginpref() if x.startswith("privacy_")]: print(l, "=", hexchat.get_pluginpref(l)) elif len(word) == 4: k, v = word[2], word[3] hexchat.set_pluginpref(k, v) configure_hexchat() print(k, "=", v) else: do_help()
def __init__(self): hexchat.prnt("Sound Alert plugin loaded.") self.sound_directory = self.find_sound_directory() self.file_list = self.find_sounds() if hexchat.get_pluginpref("soundalert_active") == None: hexchat.set_pluginpref("soundalert_active", True) if hexchat.get_pluginpref("soundalert_active") == False: hexchat.prnt("Alerts are currently disabled. Re-enable them with /alertson")
def ss_cb(word, word_eol, userdata): if len(word) < 2: word.append("help") if word[1].lower() == "list": callCacheList() colourlist = [] for i in cache_list: if (i + ".py") in dlss_list: colourlist.append("\00303" + i + "\017") else: colourlist.append(i) pprefix("List of Scripts: " + ", ".join(colourlist)) elif word[1].lower() == "get": if not len(word) == 3: pprefix("Usage: /SS GET <script[.py]>") return hexchat.EAT_HEXCHAT script = word[2] if script[-3:] == ".py": script = script[:-3] if (script + ".py") in dlss_list: hexchat.hook_timer(0, pyunload_timer, script + ".py") callCacheList() if script in cache_list: dlss_list.append(script + ".py") hexchat.hook_timer(0, download, [script + ".py", True]) else: pprefix("\"{0}\" is not a known script!".format(word[2])) elif word[1].lower() == "startup": if not len(word) == 3: pprefix("Usage: /SS STARTUP <True/False>") return hexchat.EAT_HEXCHAT onstartload = bool(False if word[2].lower() == "false" else True) hexchat.set_pluginpref("ss_onstartload", onstartload) pprefix("On startup load plugins is set to\002\0030" + ("3" if onstartload else "4"), onstartload, "\017") elif word[1].lower() == "update": callCacheList() for i in dlss_list: if i[:-3] in cache_list: hexchat.hook_timer(0, pyunload_timer, i) hexchat.hook_timer(0, download, [i]) else: pprefix("/SS HELP -- Shows this help message") pprefix("/SS LIST -- Lists all SS Scripts you can get") pprefix("/SS GET <script[.py]> -- Downloads and loads <script>") pprefix("/SS STARTUP <True/False> -- Loads scripts on startup") pprefix("/SS UPDATE -- Updates all SS Scripts") pprefix("You have \00304{}\017 API Calls left!".format("~"+str(apicallsleft) if apicallsleft == 60 else apicallsleft)) return hexchat.EAT_HEXCHAT
def __init__(self): hexchat.prnt("Razer Alert plugin loaded.") if hexchat.get_pluginpref("razeralert_active") is None: hexchat.set_pluginpref("razeralert_active", True) if not hexchat.get_pluginpref("razeralert_active"): hexchat.prnt( "Alerts are currently disabled. Re-enable them with /alertson") self.blink = False
def __init__(self): hexchat.prnt("Sound Alert plugin loaded.") self.sound_directory = self.find_sound_directory() self.file_list = self.find_sounds() if hexchat.get_pluginpref("soundalert_active") == None: hexchat.set_pluginpref("soundalert_active", True) if hexchat.get_pluginpref("soundalert_active") == False: hexchat.prnt( "Alerts are currently disabled. Re-enable them with /alertson")
def changekey(word, word_eol, userdata): apikey = hexchat.get_pluginpref('lfm_key') if not apikey: hexchat.set_pluginpref('lfm_key', word[1]) hexchat.emit_print("Notice", "LfmNP [PL]", "Set apikey to '%s'." % word[1]) if apikey: hexchat.set_pluginpref('lfm_key', word[1]) hexchat.emit_print( "Notice", "LfmNP [PL]", "Set apikey to '%s'. (was: '%s')" % (word[1], apikey))
def changeuser(word, word_eol, userdata): username = hexchat.get_pluginpref('lfm_user') if not username: hexchat.set_pluginpref('lfm_user', word[1]) hexchat.emit_print("Notice", "LfmNP [PL]", "Set username to '%s'." % word[1]) if username: hexchat.set_pluginpref('lfm_user', word[1]) hexchat.emit_print( "Notice", "LfmNP [PL]", "Set username to '%s'. (was: '%s')" % (word[1], username))
def set_options(self, word, word_eol, userdata): if len(word) < 3: hexchat.prnt("Not enough arguments given. See /help soundalert") else: if word[1] == "set": if os.path.isdir(word_eol[1]): hexchat.set_pluginpref("soundalert_dir", word_eol[1]) else: hexchat.prnt("Not a valid directory.") return hexchat.EAT_ALL
def jptab_pref(word, word_eol, userdata): network = hexchat.get_info("network") channel = hexchat.get_info("channel") if len(word) == 3: if word[2].lower() == "network" and network != tab_name: if word[1].lower() == "add": hexchat.set_pluginpref("jptab_" + network, "network") hexchat.prnt("-\00322jptab\00399-\tNetwork \00319{}\00399 added to joint/part filters".format(network)) load_jpfilters() elif word[1].lower() == "remove": hexchat.del_pluginpref("jptab_" + network) hexchat.prnt("-\00322jptab\00399-\tNetwork \00319{}\00399 removed from joint/part filters".format(network)) load_jpfilters() else: hexchat.prnt("Usage: /jptab [add|remove] network") elif word[2].lower() == "channel" and network != tab_name: if word[1].lower() == "add": hexchat.set_pluginpref("jptab_" + channel, network) hexchat.prnt("-\00322jptab\00399-\tChannel \00319{0}\00399 on network {1} added to join/part filters".format(channel, network)) load_jpfilters() elif word[1].lower() == "remove": hexchat.del_pluginpref("jptab_" + channel) hexchat.prnt("-\00322jptab\00399-\tChannel \00319{0}\00399 on network {1} removed from joint/part filters".format(channel, network)) load_jpfilters() else: hexchat.prnt("Usage: /jptab [add|remove] channel") elif word[1].lower() == "list" and word[2].lower() == "filters": if len(network_lst) > 0: network_filters = ", ".join(network_lst) hexchat.prnt("-\00322jptab\00399-\tYour join/part network filters are: {}".format(network_filters)) if len(channel_lst) > 0: channel_filters_lst = [] for channel in channel_lst: network = get_network(channel) channel_filters_lst.append(channel + "/" + network) channel_filters = ", ".join(channel_filters_lst) hexchat.prnt("-\00322jptab\00399-\tYour join/part channel filters are: {}".format(channel_filters)) if len(network_lst) < 1 and len(channel_lst) < 1: hexchat.prnt("-\00322jptab\00399-\tYou are not filtering join/part messages on any network or channel") else: hexchat.prnt("Usage: /jptab [add|remove] [network|channel]\n\t /jptab list filters") else: hexchat.prnt("Usage: /jptab [add|remove] [network|channel]\n\t /jptab list filters") return hexchat.EAT_ALL
def set_option(word): if len(word) == 2: for l in [ x for x in hexchat.list_pluginpref() if x.startswith("privacy_") ]: print(l, "=", hexchat.get_pluginpref(l)) elif len(word) == 4: k, v = word[2], word[3] hexchat.set_pluginpref(k, v) configure_hexchat() print(k, "=", v) else: do_help()
def set_prop (word, word_eol, userdata): if len(word) < 3: print("Wrong syntax.") print(cmd_help["set"]) return if word[1] == "username": username = word[2] hexchat.set_pluginpref("lfm_username", username) elif word[1] == "password": password = pylast.md5(word[2]) hexchat.set_pluginpref("lfm_password", password) elif word[1] == "api_key": api_key = word[2] hexchat.set_pluginpref("lfm_api_key", api_key) elif word[1] == "api_sec": api_sec = word[2] hexchat.set_pluginpref("lfm_api_sec", api_sec) else: print("List of available parameters:") print("username"); print("password") print("api_key"); print("api_sec") return update_network() print("{} updated successfully.".format(word[1])) return hexchat.EAT_ALL
def autoafk_suffix(word, word_eol, userdata): if len(word) < 2: suffix = '' else: suffix = word[1] hexchat.set_pluginpref('autoafk_suffix', suffix) # TODO Evaluate return value print('AutoAFK: Suffix set: ' + (TEXT_ITALIC + TEXT_BOLD + suffix if len(suffix) > 0 else TEXT_ITALIC + 'disabled'))
def shign_add_list(word,word_eol,userdata): global shign_list global shign_list_last_idx global shign_prefix network_found = 0 if len(word) <= 3 and len(word) > 1: if len(word) == 3: #network provided IgnoredNick = word[1] IgnoredNetwork = word[2] else: if len(word) == 2:#netowkr isn't provided, assuming network is 'All' IgnoredNick = word[1] IgnoredNetwork = 'All' for item in shign_list: if item[1].lower() == 'all' and IgnoredNick.lower() in [j.lower() for j in item[2:]]: print(__module_name__+'\tAlready ignored on all networks') return if item[1].lower() == IgnoredNetwork.lower(): network_found = 1 if item[1].lower() == IgnoredNetwork.lower() and IgnoredNick.lower() in [j.lower() for j in item[2:]]: print(__module_name__+'\tAlready exists in the list') return else: network_idx = shign_list.index(item) shign_list[network_idx].append(IgnoredNick) hexchat.set_pluginpref(shign_list[network_idx][0],' '.join(shign_list[network_idx][1:])) print(__module_name__+'\tAdded',word[1],'to',IgnoredNetwork) if IgnoredNetwork == 'All': for m in shign_list[1:]: if IgnoredNick.lower() in [j.lower() for j in m[2:]]: hexchat.command('SHIGNDEL ' + IgnoredNick + ' ' + m[1]) break else: network_found = 0 continue else: if network_found == 0: shign_list_last_idx += 1 temp_list = [shign_prefix + str(shign_list_last_idx), IgnoredNetwork, IgnoredNick] shign_list.append(temp_list) hexchat.set_pluginpref(temp_list[0],' '.join(temp_list[1:])) print(__module_name__+'\tAdded',word[1],'to',IgnoredNetwork) else: if len(word) > 3: print(__module_name__+'\tInvalid syntax. ==>',word_eol[3]) print(addhelp()) else: print(addhelp())
def set_option(key, value): hkey = "{}_{}".format(__module_name__, key) success = hexchat.set_pluginpref(hkey, value) if not success: raise PluginConfigError((key, value)) make_argparser_and_args_after_config()
def passchange(word, word_eol, userdata): if len(word) == 1: if hexchat.get_pluginpref('mpdnp_pass') == '+-+nopassword+-+': formattedprint('Password protection is disabled.') else: formattedprint('Current mpd password is \'%s\'. To disable password protection, type /mpdpass disable' % hexchat.get_pluginpref('mpdnp_pass')) if len(word) == 2: if word[1].lower() == 'disable': formattedprint('Password protection disabled.') hexchat.set_pluginpref('mpdnp_pass', '+-+nopassword+-+') else: formattedprint( 'Password changed to \'%s\'. To disable password protection, type /mpdpass disable' % word[1]) hexchat.set_pluginpref('mpdnp_pass', word[1])
def save_colorpairs(): if len(colorpairs) > 0: colorpairs_json = json.dumps(colorpairs) if not hexchat.set_pluginpref(__module_name__ + "colorpairs", colorpairs_json): raise BaseException("Plugin ONoticeFormat couldn't save colorpairs table.") else: hexchat.del_pluginpref(__module_name__ + "colorpairs")
def __setitem__(self, key, value): if not isinstance(key, str): raise TypeError("Key must be a string") if value is None: raise ValueError("Can not set `None`") if not hexchat.set_pluginpref(self._keyname(key), value): raise RuntimeError("Could not set %s" % value)
def quit_cb(word, word_eol, userdata): networks = {} for chan in hexchat.get_list('channels'): if chan.type == 2 or chan.type == 3: # Ignore notices and server tabs if not chan.network in networks: networks[chan.network] = [] if (chan.channelkey): networks[chan.network].append(chan.channel + ' ' + chan.channelkey) else: networks[chan.network].append(chan.channel) for network, channels in networks.items(): hexchat.set_pluginpref('session_' + network, ','.join(channels)) hexchat.find_context(server=network).command('quit') hexchat.command('timer 1 killall') return hexchat.EAT_ALL
def first_start_default_config(): """ > load default entries in addon_python.conf on first install * do not change anything in the dictionary, change addon_python.conf after running once. """ config = { "autoback__threshold": "5", "autoback__enabled": "1", "autoback__talk_count": "0", "suffix": "[A]", "networks": "" } for key, value in config.items(): full_key = "hcaway_" + key if not hexchat.get_pluginpref(full_key): hexchat.set_pluginpref(full_key, value)
def set_aes_key(word, word_eol, userdata): context = hexchat.get_context() server = context.get_info('server') channel = context.get_info('channel') if len(word) < 2: if server + channel in channel_keys: del channel_keys[server + channel] hexchat.prnt('AESKEY: key for {} @ {} cleared'.format(channel, server)) return hexchat.EAT_ALL if len(server) == 0 or '#' not in channel: hexchat.prnt('AESKEY: no key set; use while in a channel') return hexchat.EAT_ALL channel_keys[server + channel] = word[1] # base64 encode so passwords don't show up with grep or something similar hexchat.set_pluginpref( __module_name__, base64.standard_b64encode(repr(channel_keys)) ) hexchat.prnt('AESKEY: key for {} @ {} set'.format(channel, server)) return hexchat.EAT_ALL
def shign_del_list(word,word_eol,userdata): global shign_list global shign_list_last_idx if len(word) <= 3 and len(word) > 1: if len(word) == 2: #nick only provided nick_found = 0 for item in shign_list: if word[1].lower() in [j.lower() for j in item[2:]]: nick_found = 1 for k in shign_list[shign_list.index(item)]: if k.lower() == word[1].lower(): shign_list[shign_list.index(item)].pop(shign_list[shign_list.index(item)].index(k)) hexchat.set_pluginpref(item[0],' '.join(item[1:])) print(__module_name__+'\tRemoved',word[1],'from',item[1]) break else: if nick_found == 0: print(__module_name__ + '\tNickname not found. Try /SHIGNLIST') if len(word) == 3: #nick and network provided #word[1] is the nickname #word[2] is the network network_found = 0 for item in shign_list: if item[1].lower() == word[2].lower(): network_found = 1 if word[1].lower() in [j.lower() for j in item[2:]]: nick_found = 1 for k in shign_list[shign_list.index(item)]: if k.lower() == word[1].lower(): shign_list[shign_list.index(item)].pop(shign_list[shign_list.index(item)].index(k)) hexchat.set_pluginpref(item[0],' '.join(item[1:])) print(__module_name__+'\tRemoved',word[1],'from',item[1]) break else: print(__module_name__ + '\tNickname not found in',item[1],'network. Try /SHIGNLIST') break else: if network_found == 0: print(__module_name__ + '\tNetwork not found. Try /SHIGNLIST') else: print(__module_name__ + '''\tUsage: /SHIGNDEL <nick> <network>, Delete nickname from a network If network is ommitted, nickname will be deleted from all networks''')
def find_sound_directory(self): if hexchat.get_pluginpref("soundalert_dir") != None: return hexchat.get_pluginpref("soundalert_dir") else: if os.name == "nt": paths = ["C:\Program Files\HexChat\share\sounds", "C:\Program Files (x86)\HexChat\share\sounds", "%appdata%\HexChat\sounds"] elif os.name == "posix": paths = ["/sbin/HexChat/share/sounds", "/usr/sbin/HexChat/share/sounds", "/usr/local/bin/HexChat/share/sounds"] else: return False for path in paths: if os.path.isdir(path): hexchat.set_pluginpref("soundalert_dir", path) return path return False
def lfm_cb(word, word_eol, userdata): global USERNAME if len(word) == 2: USERNAME = word[1] hexchat.set_pluginpref('lfm_username', USERNAME) print('Lastfm: Username set to {}'.format(USERNAME)) return hexchat.EAT_ALL if not USERNAME: print('Lastfm: No username set, use /lfm <username> to set it') return hexchat.EAT_ALL track = get_track() if not track: print('Lastfm: No song currently playing') else: print_nowplaying(track) return hexchat.EAT_ALL