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 on_init_cb(): global kbd_status kbd_status = True hexchat.hook_print("Channel Msg Hilight", dispatcher, None, hexchat.PRI_LOWEST) hexchat.hook_print("Focus Window", notification_checked, None, hexchat.PRI_LOWEST) hexchat.hook_unload(unload_cb) hexchat.hook_command("kbdlight", toggle_kbd) print("\0034 {} {} {}".format(__module_name__, __module_version__,"has been loaded\003"))
def __init__(self, pluginpref, defaultvalue, command, commandhelp=''): self.pluginpref = pluginpref hexchat.hook_command(command, self.command, help=commandhelp) self.value = None if pluginpref: self.value = hexchat.get_pluginpref(pluginpref) if not self.value: self.value = defaultvalue
def __init__(self, pluginpref, defaultvalue, command, commandhelp = ''): self.pluginpref = pluginpref hexchat.hook_command(command, self.command, help=commandhelp) self.value = None if pluginpref: self.value = hexchat.get_pluginpref(pluginpref) if not self.value: self.value = defaultvalue
def on_init_cb(): global fda_status fda_status = True hexchat.hook_print("Channel Message", freedom_alert_cb, None, hexchat.PRI_LOWEST) hexchat.hook_unload(unload_cb) hexchat.hook_command("fda", toggle_fda) print("\0034 {} {} {}".format(__module_name__, __module_version__, "has been loaded\003"))
def load(*args): hexchat.hook_command('openLogFile', openLogFile, help='openLogFile') hexchat.hook_command('openLogFolder', openLogFolder, help='openLogFolder') hexchat.hook_unload(unload_openLogFile) hexchat.hook_unload(unload_openLogFolder) menu_clear() menu_add("Window/logs") menu_item("open log file", "openLogFile") menu_item("open logs folder", "openLogFile") hexchat.prnt("Loaded.")
def init(): hexchat.hook_command( 'pings', pings, help= 'Usage: PINGS [date (MM-DD)] [time (hh:mm[:ss])], lists pings since time specified' ) hexchat.hook_print('Channel Msg Hilight', catch_msg) hexchat.hook_print('Channel Action Hilight', catch_emote) hexchat.hook_unload(unload) hexchat.prnt('Loaded {} {}'.format(__module_name__, __module_version__))
def init(): try: if os.path.isfile(PASSFILE): hexchat.prnt(textPos(PASSFILE + " loaded!")) hexchat.hook_command('', send) hexchat.hook_command('enc', enc, help="For help use the command /enc") hexchat.hook_print('Private Message to Dialog', receive) else: hexchat.prnt(textNeg("Could not open passfile")) except Exception as e: hexchat.prnt(textNeg(str(e)))
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 enfab_callback(word, word_eol, user_data): global fab_hook if fab_hook is None: fab_hook = hexchat.hook_command('', fab_passthru_callback) hexchat.prnt('Fabulous mode on') return hexchat.EAT_ALL
def main(): ########################################################################### # Manage Preferences global prefs prefs = JSONPluginPref(__module_name__) if prefs.version is NotImplemented: print("There was an error retrieving the preferences' version.\n" "It is advised to seek help from the author (FichteFoll) " "and run around in circles.") return if prefs.version is None: # before 0.3.0 # convert preferences to JSON storage bare_prefs = PluginPref(__module_name__, prefix_sep="_") for key, value in bare_prefs.items(): if key in ('announce', 'mute'): value = list(filter(None, value.split(","))) prefs[key] = value del bare_prefs[key] prefs.version = (0, 3, 0) # hardcode for further migrations print("Converted preference storage to 0.3.0") # if prefs.version < (0, 3, 4): # pass # Write current version at last prefs.version = versioninfo ########################################################################### # Register Hooks hexchat.hook_command("YTT", yttcmd_cb, help=HELP_STR) private_msg_events = ("Notice", "Private Message", "Private Action") for event in private_msg_events: hexchat.hook_print(event, privmsg_cb) public_msg_events = ("Channel Message", "Action", "Your Message", "Your Action") for event in public_msg_events: hexchat.hook_print(event, msg_cb) print(__module_name__, __module_version__, "loaded")
def load_aliases(): for pref in hexchat.list_pluginpref(): if pref[:6] == 'alias_': name = pref[6:] hook = hexchat.hook_command( name, alias_cmd_cb, help='Alias: "{}" is an alias for "{}"'.format( name, get_alias(name))) alias_hooks[name] = hook
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 send_getbool_to_callback(callback): # TODO: More generalised callback-command thing? cmdname = ".floodcontrol_cb_getbool" @default_returnvalue(hexchat.EAT_HEXCHAT, hexchat.EAT_ALL) def callback_and_unhook(words, words_eol, *args): o = bool(int(words_eol[1])) threading.Thread(target=callback, args=(o,)).start() {hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname]} {hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname]} handler = hexchat.hook_command(cmdname, callback_and_unhook, userdata=time.time()) hexchat_callback_handlers[cmdname].append(handler) hexchat.command(" ".join(("GETBOOL", cmdname, '"Floodcontrol"', '"Confirm sending to pastebin?"')))
def send_getstr_to_callback(callback): # TODO: More generalised callback-command thing? cmdname = ".floodcontrol_cb_getstr" @default_returnvalue(hexchat.EAT_HEXCHAT, hexchat.EAT_ALL) def callback_and_unhook(words, words_eol, *args): o = words_eol[1] if o != "(paste here)": threading.Thread(target=callback, args=(o,)).start() {hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname]} {hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname]} handler = hexchat.hook_command(cmdname, callback_and_unhook, userdata=time.time()) hexchat_callback_handlers[cmdname].append(handler) hexchat.command(" ".join(("GETSTR", '"(paste here)"', cmdname, '"Floodcontrol pastebin input:"')))
def init(): rat_irc.init(root_path, on_console_write) hexchat.hook_server("PRIVMSG", handle_privmsg) hexchat.hook_command( "FR_LOG", lambda word, word_eol, userdata : rat_irc.handle_fr_log(word), help=rat_irc.fr_log_usage) hexchat.hook_command( "FR_CLIP", lambda word, word_eol, userdata : rat_irc.handle_fr_clip(word), help=rat_irc.fr_clip_usage) hexchat.hook_command( "FR_PLATFORM", lambda word, word_eol, userdata : rat_irc.handle_fr_platform(word), help=rat_irc.fr_platform_usage) hexchat.hook_command( "FR_SOUND", lambda word, word_eol, userdata : rat_irc.handle_fr_sound(word), help=rat_irc.fr_sound_usage) hexchat.hook_command( "FR_GAME_VERSION", lambda word, word_eol, userdata : rat_irc.handle_fr_game_version(word), help=rat_irc.fr_game_version_usage)
def send_notice_cb(word, word_eol, userdata): global send_notice_hook to = word[1] context = hexchat.find_context(server=hexchat.get_info('server'), channel=to) if not context: if to.startswith('#'): return hexchat.EAT_NONE else: hexchat.command('QUERY -nofocus %s' % to) context = hexchat.find_context(server=hexchat.get_info('server'), channel=to) if context: context.set() hexchat.unhook(send_notice_hook) context.command(word_eol[0]) send_notice_hook = hexchat.hook_command("NOTICE", send_notice_cb) return hexchat.EAT_ALL
def send_getbool_to_callback(callback): # TODO: More generalised callback-command thing? cmdname = ".floodcontrol_cb_getbool" @default_returnvalue(hexchat.EAT_HEXCHAT, hexchat.EAT_ALL) def callback_and_unhook(words, words_eol, *args): o = bool(int(words_eol[1])) threading.Thread(target=callback, args=(o, )).start() { hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname] } {hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname]} handler = hexchat.hook_command(cmdname, callback_and_unhook, userdata=time.time()) hexchat_callback_handlers[cmdname].append(handler) hexchat.command(" ".join(("GETBOOL", cmdname, '"Floodcontrol"', '"Confirm sending to pastebin?"')))
def send_getstr_to_callback(callback): # TODO: More generalised callback-command thing? cmdname = ".floodcontrol_cb_getstr" @default_returnvalue(hexchat.EAT_HEXCHAT, hexchat.EAT_ALL) def callback_and_unhook(words, words_eol, *args): o = words_eol[1] if o != "(paste here)": threading.Thread(target=callback, args=(o, )).start() { hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname] } {hexchat.unhook(handler) for handler in hexchat_callback_handlers[cmdname]} handler = hexchat.hook_command(cmdname, callback_and_unhook, userdata=time.time()) hexchat_callback_handlers[cmdname].append(handler) hexchat.command(" ".join(("GETSTR", '"(paste here)"', cmdname, '"Floodcontrol pastebin input:"')))
def __init__(self): self.givenAnswers = [] self.questions = [] self.quizzfile = Setting('gbquizz_quizzfile', '', 'QUIZZFILE', '/QUIZZFILE <nom du fichier>: régler le nom du fichier de quizz. Sans argument, permet de connaître ce nom de fichier.') self.timeHint = Setting('gbquizz_timehint', 15, 'QUIZZTIMEHINT', '/QUIZZTIMEHINT <temps en secondes>: temps restant à l\'affichage de l\'indice.') self.timeQuestion = Setting('gbquizz_timequestion', 60, 'QUIZZTIMEQUESTION', '/QUIZZTIMEQUESTION <temps en secondes>: durée de chaque question.') self.multicastEnabled = Setting('gbquizz_multicastenabled', 0, 'QUIZZMULTICAST', '/QUIZZMULTICAST <1 ou 0>: activer ou désactiver le multicast.') self.timePause = Setting('gbquizz_timepause', 15, 'QUIZZTIMEPAUSE', '/QUIZZTIMEPAUSE <temps en secondes>: durée de chaque pause.') self.channel = Setting(None, hexchat.get_info('channel'), 'QUIZZCHANNEL', '/QUIZZCHANNEL <canal>: changer le canal du bot de quizz.') self.tick = Setting('gbquizz_tick', 0, 'QUIZZTICK', '/QUIZZTICK <valeur>: changer la valeur du temps pour le bot.') self.mode = 0 self.ignoredList = hexchat.get_pluginpref('gbquizz_ignored').split(' ') self.loadScores() self.currentAnswers = [] hexchat.hook_command('QUIZZSTART', self.startQuizz) hexchat.hook_command('QUIZZSTOP', self.stop) hexchat.hook_command('QUESTION', self.newQuestion) hexchat.hook_server('PRIVMSG', self.messageHook) hexchat.hook_server('JOIN', self.joinHook) hexchat.hook_unload(self.quit)
def load_plugin(): if OVERRIDE_SAY: # override /say command hexchat.hook_command("", say_cb) if OVERRIDE_ME: # override /me command hexchat.hook_command("ME", me_cb) # register emojify command (/em <text>) hexchat.hook_command( "EM", em_cb, userdata={"command": COMMAND_EM_SIMULATES}, help= "Usage: EM <text>, converts text with emojis aliases into an unicode encoded text" ) hexchat.hook_unload(unload_cb) print(f"{__module_name__} version {__module_version__} loaded.")
def init(): global frequency log("init", "=============------------===============") log("init", "initializing commands...") cmd = commands() log("init", "hooking server...") # hook is fired on server message/PM hc.hook_server("PRIVMSG", cmd.parseHook) # hooks when the user is mentioned # hooks fire when the associated slash-command is entered log("init", "hooking commands...") hc.hook_command("test", cmd.test) hc.hook_command("readOut", cmd.readOut) hc.hook_command("purge", cmd.purge) # for timed reminders, HC provides a method for triggering timed callbacks log("init", "Hooking timer...") hc.hook_timer(frequency, cmd.readOut) log("init", "Done!") log( "Init", "-----------------\n{} version {} loaded successfully!\n--------------" .format(__module_name__, __module_version__))
def __init__(self): self.givenAnswers = [] self.questions = [] self.quizzfile = Setting( 'gbquizz_quizzfile', '', 'QUIZZFILE', '/QUIZZFILE <nom du fichier>: régler le nom du fichier de quizz. Sans argument, permet de connaître ce nom de fichier.' ) self.timeHint = Setting( 'gbquizz_timehint', 15, 'QUIZZTIMEHINT', '/QUIZZTIMEHINT <temps en secondes>: temps restant à l\'affichage de l\'indice.' ) self.timeQuestion = Setting( 'gbquizz_timequestion', 60, 'QUIZZTIMEQUESTION', '/QUIZZTIMEQUESTION <temps en secondes>: durée de chaque question.' ) self.multicastEnabled = Setting( 'gbquizz_multicastenabled', 0, 'QUIZZMULTICAST', '/QUIZZMULTICAST <1 ou 0>: activer ou désactiver le multicast.') self.timePause = Setting( 'gbquizz_timepause', 15, 'QUIZZTIMEPAUSE', '/QUIZZTIMEPAUSE <temps en secondes>: durée de chaque pause.') self.channel = Setting( None, hexchat.get_info('channel'), 'QUIZZCHANNEL', '/QUIZZCHANNEL <canal>: changer le canal du bot de quizz.') self.tick = Setting( 'gbquizz_tick', 0, 'QUIZZTICK', '/QUIZZTICK <valeur>: changer la valeur du temps pour le bot.') self.mode = 0 self.ignoredList = hexchat.get_pluginpref('gbquizz_ignored').split(' ') self.loadScores() self.currentAnswers = [] hexchat.hook_command('QUIZZSTART', self.startQuizz) hexchat.hook_command('QUIZZSTOP', self.stop) hexchat.hook_command('QUESTION', self.newQuestion) hexchat.hook_server('PRIVMSG', self.messageHook) hexchat.hook_server('JOIN', self.joinHook) hexchat.hook_unload(self.quit)
return def lfm_cb(word, word_eol, userdata): global USERNAME echo = False if len(word) == 2: if word[1] == "-e": echo = True else: 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, echo) return hexchat.EAT_ALL hexchat.hook_command("lfm", lfm_cb, help=lfm_help)
return def unload(userdata): hexchat.unhook(command_hook) hexchat.unhook(DCC_complete_hook) hexchat.unhook(unload_hook) print("\00310\002ユイ\017 v%s plugin by \00311\002Wizongod\017 has been unloaded." % __module_version__) return # Hooks for detecting events command_hook = hexchat.hook_command('xdcc', commander) DCC_complete_hook = hexchat.hook_print('DCC RECV Complete',XDCC_complete) unload_hook = hexchat.hook_unload(unload) def is_valid_pack(pack_no): if strip_hash(pack_no).isdigit(): return True else: return False def strip_hash(string): if string[0] == "#":
if word[0].lower() in config["override"]: pass else: if word[0][::-1].lower() == ident.lower(): word[0] = word[0][::-1] else: if hasNumbers(word[0]): word[0] = ''.join([i for i in word[0] if not i.isdigit()]) hexchat.command("sanick %s %s" % (word[0], word[0][::-1])) else: hexchat.command("sanick %s %s" % (word[0], word[0][::-1])) hexchat.hook_print("Join", userJoin) def revnick(word, word_eol, userdata): try: word[1] print(word[1]) except IndexError: print("Please enter a nick.") else: word.pop(0) for name in word: newNick = newNick = word[1][::-1] hexchat.command("sanick %s %s" % (name, newNick.title())) hexchat.hook_command("revnick", revnick)
return hexchat.EAT_ALL elif word[3] in (':USERCOLOR', ':USERSTATE', ':HISTORYEND', ':EMOTESET', ':CLEARCHAT', ':SPECIALUSER'): return hexchat.EAT_ALL # Eat any message starting with a '.', twitch eats all of them too. @twitchOnly def yourmsg_cb(word, word_eol, userdata): if word[1][0] == '.': return hexchat.EAT_ALL # Just prefix with a '.'. @twitchOnly def command_cb(word, word_eol, alias): if alias: if len(word_eol) > 1: hexchat.command('say .{} {}'.format(alias, word_eol[1])) else: hexchat.command('say .{}'.format(alias)) else: hexchat.command('say .{}'.format(word_eol[0])) return hexchat.EAT_ALL for command in commands: hexchat.hook_command(command, command_cb) for command, alias in aliases.items(): hexchat.hook_command(command, command_cb, alias) hexchat.hook_print('Your Message', yourmsg_cb) hexchat.hook_server('421', servererr_cb) #hexchat.hook_server('376', endofmotd_cb) hexchat.hook_server('PRIVMSG', privmsg_cb)
def pyload_timer(script): hexchat.command("py load {}".format(os.path.join(ss_dir, script))) return False def pyunload_timer(script): hexchat.command("py unload {}".format(script)) return False def callCacheList(): if not len(cache_list) > 0: updateCacheList() def updateCacheList(): global cache_list, apicallsleft httpresponse = urllib_request.urlopen(contents) apicallsleft = httpresponse.info()["X-RateLimit-Remaining"] cache_list = [] for i in json.loads(httpresponse.read().decode()): if i["path"][-3:] == ".py": if not i["path"] in ["ss.py", "loader.py"]: cache_list.append(i["path"][:-3]) def unload_cb(userdata): for i in dlss_list: hexchat.command("py unload {}".format(i)) hexchat.hook_command("SS", ss_cb) hexchat.hook_unload(unload_cb) hexchat.prnt(__module_name__ + ' script loaded!')
for h in set(word[1:-1]): if len(h) == 32: cmds.append('say #crash:note:remove %s' % (h)) cmds.append('say #crash:note:set %s "%s"' % (h, note)) else: errs.append('Invalid hash length (%d; %s)!' % (len(h), h)) if cmd == 'CRASHNOTEREMOVE': for h in set(word[1:]): if len(h) == 32: cmds.append('say #crash:note:remove %s' % (h)) else: errs.append('Invalid hash length (%d; %s)!' % (len(h), h)) if errs: hexchat.prnt('\n'.join(errs)) if cmds: hexchat.prnt('Sending %d command(s)...' % (len(cmds))) for i in range(0, len(cmds)): cmd = 'timer %.1f %s' % (i * delay + 0.1, cmds[i]) hexchat.command(cmd) return hexchat.EAT_ALL hexchat.hook_command('CRASHNOTESET', cmd_openeye) hexchat.hook_command('CRASHNOTEUPDATE', cmd_openeye) hexchat.hook_command('CRASHNOTEREMOVE', cmd_openeye) hexchat.prnt('%s version %s loaded.' % (__module_name__, __module_version__))
hexchat.command("ME " + pirate(pirate_jargon)) except IndexError: hexchat.prnt( "Error: Please include something to translate. Use -e to echo and -m for emote." ) else: try: pirate_jargon = word_eol[1] hexchat.command("SAY " + pirate(pirate_jargon)) except IndexError: hexchat.prnt( "Error: Please include something to translate. Use -e to echo and -m for emote." ) return hexchat.EAT_ALL except IndexError: pass return hexchat.EAT_NONE def unload(userdata): hexchat.prnt(__module_name__ + " " + __module_version__ + " unloaded.") hexchat.prnt( __module_name__ + " " + __module_version__ + " loaded. Use /pirate <text to translate> and /pirate -e <text to translate> for echo and -m for emote." ) hexchat.hook_unload(unload) hexchat.hook_command("pirate", pirate_func)
hexchat.prnt(self.statusmsg["false"]) def hexchat_setter(self, word, word_eol, userdata): if len(word) >= 2: if word[1][0].lower() == "t": self.setter(True) if word[1][0].lower() == "f": self.setter(False) return hexchat.EAT_ALL def __bool__(self): return self.value #make color setting _cols = BoolConfig("cols", True, true="Colors enabled", false="Colors disabled") hexchat.hook_command("enableqccolors", _cols.hexchat_setter, help="/enableqccolors true|false") #make badge setting _badge = BoolConfig("badge", True, true="Rank symbols enabled", false="Rank symbols disabled") hexchat.hook_command("enableqcranks", _badge.hexchat_setter, help="/enableqcranks true|false. " "Please see " "http://hexchat.readthedocs.org/en/latest/faq.html" # use a full link here "#how-do-i-show-and-in-front-of-nicknames-that-are-op-and-voice-when-they-talk" " before using this.") #hexchat parsing stuff hexchat_textevent_parser = re.compile("%([%RIBOUCH])") hexchat_textevent_map = { '%': '%', # escape 'R': '\x16', # swap/reverse 'I': '\x1d', # italic
return def lfm_cb(word, word_eol, userdata): global USERNAME echo = False if len(word) == 2: if word[1] == '-e': echo = True else: 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, echo) return hexchat.EAT_ALL hexchat.hook_command('lfm', lfm_cb, help=lfm_help)
""" Plugin which provides a command to change nickname on RH IRC server but not on the others. HexChat Python Interface: http://hexchat.readthedocs.io/en/latest/script_python.html IRC String Formatting: https://github.com/myano/jenni/wiki/IRC-String-Formatting """ import hexchat __module_name__ = 'rh_status' __module_description__ = 'Change nick only on RH server' __module_version__ = '1.0' def on_rh_nick(word, word_eol, userdata): """ Callback function which changes nickname, but only on server/network 'RedHat'. Command usage: /rh-nick new_nick """ new_nick = word[1] rh = hexchat.find_context(server='RedHat') rh.command('nick {}'.format(new_nick)) return hexchat.EAT_HEXCHAT hexchat.prnt('{}, version {}'.format(__module_name__, __module_version__)) hexchat.hook_command('rh-nick', on_rh_nick)
hdd_temps = [s for s in sensor_list if (s.SensorType == u'Temperature' and u'hdd' in s.Parent.lower())] return u'\002Storage\002: %.2fTB Used (%.2fTB Total) [%.2f°C (%.2f°C)]' % (round(bytes_to_tbytes(sum([d.used for d in disks])), 2), round(bytes_to_tbytes(sum([d.total for d in disks])), 2), round(avg(float(h.Value) for h in hdd_temps), 2), round(avg(float(h.Max) for h in hdd_temps), 2)) def get_uptime(): uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time()) hours, remainder = divmod(uptime.seconds, 3600) minutes, seconds = divmod(remainder, 60) return u'\002Uptime\002: %ud %uh %um %us' % (uptime.days, hours, minutes, seconds) def get_system_info(wmi_CIMV2, wmi_OpenHardwareMonitor): hardware_list = wmi_OpenHardwareMonitor.get('Hardware') sensor_list = wmi_OpenHardwareMonitor.get('Sensor') return [get_client_info(), get_os_info(wmi_CIMV2), get_cpu_info(hardware_list, sensor_list), get_gpu_info(hardware_list, sensor_list), get_memory_info(), get_disk_info(sensor_list), get_uptime()] def send_system_info(word, word_eol, userdata): wmi_CIMV2 = WMI('\\\\root\CIMV2') wmi_OpenHardwareMonitor = WMI('\\\\root\OpenHardwareMonitor') hexchat.command('say %s' % (u' \002•\002 '.join(get_system_info(wmi_CIMV2, wmi_OpenHardwareMonitor)).encode('utf-8'),)) return hexchat.EAT_ALL hexchat.hook_command("systeminfo", send_system_info)
import hexchat __module_name__ = "~blah" __module_version__ = "0.1" __module_description__ = "Recreation of NTA's ~blah script" oldnick = hexchat.get_info("nick") # we use whatever a person's nick is as # default when the plugin loads def doStuff(word, eol, data): try: suffix = word[1] hexchat.command("say ~" + suffix) hexchat.command("nick " + oldnick + "|" + suffix) except IndexError: hexchat.command("say ~") hexchat.command("nick " + oldnick) hexchat.hook_command("blah", doStuff)
if user.lower() == object.nick.lower(): host = "*!*@" + object.host.split("@")[1] return host return user def un_Ban(word, word_eol, userdata): user = word[1] if user in host_list: hexchat.command("unban " + host_list[user]) del host_list[user] else: hexchat.command("unban " + user) return hexchat.EAT_ALL def kick_Ban(word, word_eol, userdata): user = word[1] host_list[user] = get_Host(user) hexchat.command("kick " + user + " " + word_eol[2]) if len(word_eol) >= 3: hexchat.command("ban " + host_list[user]) else: hexchat.command("ban " + host_list[user]) return hexchat.EAT_ALL hexchat.hook_command("kb", kick_Ban) hexchat.hook_command("ub", un_Ban) print "Loaded", __module_name__, __module_version__
format(user.title() + " has been streaming for " + str(combineddate)) except Exception: format(user.title() + " is not streaming.") def unload_cb(userdata): hexchat.prnt("\00304" + __module_name__ + __module_version__ + "successfully unloaded.\003") def format(string, special=0): if(special): string = string.replace(string[:1],'') string = '\002\035' + string hexchat.prnt(string) def loadJSON(url): try: with urllib.urlopen(url, timeout=3) as data: obj = json.loads(data.readall().decode('utf-8')) return obj except Exception: return json.dumps(None) hexchat.hook_server('PRIVMSG', checkmessage_cb) hexchat.hook_command('STREAM', stream_cb, help ="/STREAM Use in twitch.tv chats to check if the stream is online.") hexchat.hook_command('UPTIME', uptime_cb) hexchat.hook_unload(unload_cb) timerHook = hexchat.hook_timer(10000, checkStreams_cb) hexchat.prnt("\00304" + __module_name__ + __module_version__ + "successfully loaded.\003")
mask = get_mask(word[1]) if mask: do_op() if word[0] == 'ban': command = 'mode +b {}'.format(mask) elif word[0] == 'kickban': nick = word[1] chan = hexchat.get_info('channel') message = word_eol[2] if len(word_eol) > 2 else "" command = 'mode +b {}\r\nKICK {} {} :{}'.format(mask, chan, nick, message) elif word[0] == 'quiet': command = 'mode +q {}'.format(mask) hexchat.hook_timer(100, do_command, command) return hexchat.EAT_HEXCHAT else: return hexchat.EAT_NONE def unload_cb(userdata): print(__module_name__ + ' version ' + __module_version__ + ' unloaded.') hexchat.hook_command('kickban', ban_cb) hexchat.hook_command('ban', ban_cb) hexchat.hook_command('quiet', ban_cb) hexchat.hook_unload(unload_cb) print(__module_name__ + ' version ' + __module_version__ + ' loaded.')
__module_version__ = '0.2' __module_description__ = 'Print Unicode emoticons to IRC' EMOTES = { 'SHRUG': u'¯\\_(ツ)_/¯', 'FLIP': u'(╯°□°)╯︵ ┻━┻', 'UNFLIP': u'┬──┬ ノ( ゜-゜ノ)', 'CSI': u'''\ •_•) ( •_•)>⌐■-■ (⌐■_■)''', 'DISAPPROVE': u'ಠ_ಠ', } def fullwidth(s): trans = str.maketrans({a: a + 0xff00 - 0x20 for a in range(0x21, 0x7f)}) return s.translate(trans) def emote_cb(word, word_eol, emote): hexchat.command(u'SAY {}'.format(emote)) return hexchat.EAT_ALL def fullwidth_cb(word, word_eol, userdata): hexchat.command(u'SAY {}'.format(fullwidth(word_eol[1]))) return hexchat.EAT_ALL for name, emote in EMOTES.items(): hexchat.hook_command(name, emote_cb, emote) hexchat.hook_command('FULLWIDTH', fullwidth_cb)
'Password changed to \'%s\'. To disable password protection, type /mpdpass disable' % word[1]) hexchat.set_pluginpref('mpdnp_pass', word[1]) 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 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]) hexchat.hook_command('np', np) hexchat.hook_command('mpdpass', passchange) hexchat.hook_command('mpdport', portchange) hexchat.hook_command('mpdserver', serverchange) hexchat.emit_print("Notice", __module_name__ + " [S]", "%s by %s loaded. You are using version %s of the script." % ( __module_name__, __author__, __module_version__))
def register(words, word_eols, userdata): if len(words) < 2: hexchat.prnt("You did not specify a channel") elif words[1] in channels: hexchat.prnt("Removed \002{}\002 from caps list".format(words[1])) channels.remove(words[1]) else: hexchat.prnt("Capitalization is now enabled for \002{}\002".format( words[1])) channels.append(words[1]) return hexchat.EAT_ALL def send(key, data, userdata): if key[0] == "65293": user_input = hexchat.get_info("inputbox") if hexchat.get_info("channel") in channels: if user_input.startswith("/") and not user_input.startswith("/me"): return hexchat.EAT_NONE hexchat.command("say {}".format(user_input.upper())) hexchat.command("settext ") return hexchat.EAT_ALL return hexchat.EAT_NONE hexchat.hook_command( "caps", register, help="/caps <channel> : Capitalize all text sent to the specified channel") hexchat.hook_print("Key Press", send)
filention = filename + "." + extention if not extention == "py": hexchat.emit_print("Channel Message", __module_shortname__, "Not a python script!", "") return hexchat.emit_print("Channel Message", __module_shortname__, "Downloading {}...".format(filention), "") try: urllib_request.urlretrieve(url, os.path.join(addon_dir, filention)) except urllib_error.HTTPError as err: hexchat.emit_print("Channel Message", __module_shortname__, "Error downloading {} ({})".format(filention, err), "") else: hexchat.emit_print("Channel Message", __module_shortname__, "Download complete, loading script...", "") hexchat.hook_timer(0, loadpy_timer, filention) return def download_timer(url): download(url) return False def loadpy_timer(script): hexchat.command("py load {}".format(script)) return False def isURL(url): parsedurl = urllib.parse.urlparse(url) if parsedurl.netloc: return True return False hexchat.hook_command("DOWNLOAD", download_cb) hexchat.prnt(__module_name__ + ' script loaded')
# This will popup a choose program prompt /url doesn't hexchat.command('exec -d gvfs-open {}'.format(expand_script(arg))) else: hexchat.command('url {}'.format(expand_script(arg))) elif cmd == 'search': search(arg) elif cmd == 'remove': if arg == 'script.py': print('Script: I refuse.') return hexchat.EAT_ALL if os.path.exists(expand_script(arg)): hexchat.command('unload ' + expand_script(arg)) os.remove(expand_script(arg)) else: print('Script: {} is not installed.'.format(arg)) else: hexchat.command('help script') return hexchat.EAT_ALL def unload_callback(userdata): print(__module_name__, 'version', __module_version__, 'unloaded.') if THREADS_SUPPORTED: threading.Thread(target=update_addons).start() else: update_addons() hexchat.hook_command('script', script_cb, help=script_help) hexchat.hook_unload(unload_callback) print(__module_name__, 'version', __module_version__, 'loaded.')
import hexchat __module_name__ = 'masshl' __module_author__ = 'Orc' __module_version__ = '1.0' __module_description__ = 'mass highlights' full_name = "{} v{} by {}".format(__module_name__,__module_version__,__module_author__) help_hook = "\"/masshl\" will highlight every nick in the current channel." def masshl(word, word_eol, userdata): names = "" for i in hexchat.get_list("users"): names += i.nick + " " hexchat.command("say " + names) return hexchat.EAT_NONE hexchat.hook_command("masshl", masshl, help=help_hook) hexchat.prnt(full_name + " loaded.")
try: cmd = os.popen("whoami") try: user = cmd.readlines() user = user[0].strip("\n") if 'Windows' == comp: user = user.split("\\")[1] finally: cmd.close() except IOError: pass if "ghost" != user: if 'Windows' == comp: nibl_dir = "C:/Users/" + user + "/.config/nibl/" else: nibl_dir = "/home/" + user + "/.config/nibl/" check_dirs(nibl_dir) hexchat.hook_command("NXF", Main, help="/NXF <cmd>") hexchat.command("MENU -p5 ADD NIBL") if os.path.exists(nibl_dir + "xdccfilter"): hexchat.command("MENU -t1 ADD \"NIBL/XDCC Filter\" \"nxf on\" \"nxf off\"") hexchat.command("nxf on") else: hexchat.command("MENU -t0 ADD \"NIBL/XDCC Filter\" \"nxf on\" \"nxf off\"") hexchat.command("MENU ADD \"NIBL/XDCC Output\" \"nxf open\"")
format_kws['msg1'] = blank_msg1.format(getname()) format_kws['msg2'] = time.strftime("%H:%M") format_kws['ccode1'] = colorcode_by_name(w[0]) format_kws['ccode2'] = colorcode_by_name("_time") format_kws['R'] = C_RESET format_kws['rest'] = weol[1] hexchat.command("notice {prefix}{chan} {ccode1}{msg1}{R} {ccode2}{msg2}{R} {rest}".format(**format_kws)) else: print("Provide a message. Usage: {} <message>".format(w[0])) return hexchat.EAT_HEXCHAT def no_cmd(w, weol, userdata): if len(weol) > 1: hexchat.command("notice " + weol[1]) else: hexchat.command("notice") return hexchat.EAT_HEXCHAT hexchat.hook_command("o", noticeformat_cmd, userdata=("{} to o", "@"), help="Send a notice to channel operators. Usage: O <message>") hexchat.hook_command("oh", noticeformat_cmd, userdata=("{} to o/h", "%@"), help="Send a notice to chanops and halfops. Usage: OH <message>") hexchat.hook_command("ov", noticeformat_cmd, userdata=("{} to o/v", "@+"), help="Send a notice to chanops and voiced users. Usage: OV <message>") hexchat.hook_command("no", no_cmd, help="Send a notice. Alias for /NOTICE") hexchat.hook_command("o_setname", setname_cmd, help="Usage: O_SETNAME <Name>") hexchat.hook_command("o_delname", delname_cmd) hexchat.hook_command("o_setcolor", setcolor_by_name_cmd, help=setcolorusage) print("{} version {} loaded.".format(__module_name__, __module_version__))
import requests import hexchat import threading __module_name__ = 'whatpulse spam' __module_description__ = 'spams whatpulse' __module_version__ = '0.0.3a' __author__ = 'Erica Garcia [ericathesnark] <*****@*****.**>' # TODO: make this more configurable, this is terrible. wpUsername = None def getData(chan): wpData = requests.get( "http://api.whatpulse.org/user.php?user={}&format=json".format(wpUsername)).json() spamString = "WhatPulse Stats for \002\00302{}\017 | Keys: \002\00302{}\017 (Rank \002\00302{}\017) | Clicks: \002\00302{}\017 (Rank \002\00302{}\017) | DL: \002\00302{}\017 (Rank \002\00302{}\017) | UL: \002\00302{}\017 (Rank \002\00302{}\017) | Uptime: \002\00302{}\017 (Rank \002\00302{}\017) | Avg. Keys/s \002\00302{}\017 | Avg. Clicks/s \002\00302{}\017".format( wpData['AccountName'], wpData['Keys'], wpData['Ranks']['Keys'], wpData['Clicks'], wpData['Ranks']['Clicks'], wpData['Download'], wpData['Ranks']['Download'], wpData['Upload'], wpData['Ranks']['Upload'], wpData['UptimeShort'], wpData['Ranks']['Uptime'], wpData['AvKPS'], wpData['AvCPS']) hexchat.command("msg {} {}".format(chan, spamString)) def spamWP(word, word_eol, userdata): chan = hexchat.get_info('channel') dataThread = threading.Thread(target=getData, kwargs={"chan": chan}) dataThread.start() return hexchat.EAT_ALL hexchat.hook_command("whatpulse", spamWP)
""" Usage: /ud <word> Creator: x13machine <https://github.com/x13machine> License: WTFPL <http://www.wtfpl.net/> """ __module_name__ = "Urban Dictionary" __module_version__ = "1.0" __module_description__ = "Gets the Urban Dictionary" import hexchat import requests def ud(word, word_eol, userdata): try: r = requests.get('http://api.urbandictionary.com/v0/define', params={'term': word_eol[1]}) data = r.json()['list'][0] hexchat.prnt('Urban Dictionary -> ' + data['word'] + ': ' + data['definition']) except: hexchat.prnt('Urban Dictionary: ENGLISH, M**********R DO YOU SPEAK IT???') hexchat.hook_command('ud', ud, help='UD <word>')
__module_name__ = 'HashLib' __module_author__ = 'OverCoder' __module_version__ = '0.8' __module_description__ = 'Hash strings on the fly' def sha1(words, word_eols, userdata): hexchat.command("say " + hashlib.sha1(word_eols[1].encode()).hexdigest()) def sha256(words, word_eols, userdata): hexchat.command("say " + hashlib.sha256(word_eols[1].encode()).hexdigest()) def sha384(words, word_eols, userdata): hexchat.command("say " + hashlib.sha384(word_eols[1].encode()).hexdigest()) def sha512(words, word_eols, userdata): hexchat.command("say " + hashlib.sha512(word_eols[1].encode()).hexdigest()) def md5(words, word_eols, userdata): hexchat.command("say " + hashlib.md5(word_eols[1].encode()).hexdigest()) def crc32(words, word_eols, userdata): hexchat.command("say " + str(binascii.crc32(word_eols[1].encode()))) hexchat.hook_command("sha1", sha1) hexchat.hook_command("sha256", sha256) hexchat.hook_command("sha384", sha384) hexchat.hook_command("sha512", sha512) hexchat.hook_command("md5", md5) hexchat.hook_command("crc32", crc32)
def start_blinking(self, word, word_eol, userdata): self.blink = True do_thread = Thread(target=self.handle_start_blinking) do_thread.start() def stop_blinking(self, word, word_eol, userdata): self.blink = False do_thread = Thread(target=self.handle_stop_blinking) do_thread.start() alert = RazerAlert() hexchat.hook_command( "soundalert", alert.set_options, help= "/soundalert set <directory> -- Sets a directory for Sound Alert to pull sounds from." ) hexchat.hook_command("alertson", alert.enable, help="Turns on soundalert alerts.") hexchat.hook_command("alertsoff", alert.disable, help="Turns off soundalert alerts.") hexchat.hook_print("Channel Action Hilight", alert.start_blinking) hexchat.hook_print("Channel Msg Hilight", alert.start_blinking) hexchat.hook_print("Private Message", alert.start_blinking) hexchat.hook_print("Focus Window", alert.stop_blinking)
def replace_cmd(words, *args): replace(words[1], words[2]) return hexchat.EAT_HEXCHAT if __name__ == "__main__": __module_name__ = str("Inputbox manipulation") __module_description__ = str( "For manipulating HexChat's inputbox, complimenting the SETTEXT and SETCURSOR commands." ) __module_version__ = str("1") hexchat.hook_command( "APPENDTEXT", append_cmd, help="Usage: APPENDTEXT <new text>, add text to the input box") hexchat.hook_command( "ADDTEXT", add_cmd, help= "Usage: ADDTEXT <new text>, add text to the input box before the current cursor position" ) hexchat.hook_command( "REPLACETEXT", replace_cmd, help= "Usage: REPLACETEXT <\"original text\"> <\"new text\">, replace some text in the input box" )
__module_name__ = "Hexchat Slap" __module_version__ = "1.2" __module_description__ = "A classic IRC '/slap' command." __author__ = "sentriz" full_name = "{} v{} by {}".format(__module_name__,__module_version__,__author__) help = """ \"/slap [nick]\" will slap a [nick]. - Use \"/slap [nick] {nick2} {nick3} {ect.}\" to slap multiple nicks. - ^ There is no limit.""" str_prefix = "\00301[\002HexChat\002\00301 \00304\002Slap\002\00301] \002:\002 \017" import hexchat def slap_func(word, word_eol, userdata): if len(word) >= 2: for nick in word[1:]: hexchat.command("me slaps \002{}\002 around a bit with a large trout.".format(nick)) else: hexchat.prnt(str_prefix + "Could not slap. " + help) return hexchat.EAT_ALL hexchat.hook_command("slap",slap_func,help=help) hexchat.prnt(str_prefix + full_name + " loaded.")
if add_alias(word[1], word_eol[2]): if edited: print('Alias: {} edited'.format(word[1])) else: print('Alias: {} added'.format(word[1])) else: print('Alias: {} failed to hook'.format(word[1])) else: print(help_msg) return hexchat.EAT_ALL def aliases_cb(word, word_eol, userdata): print('\026{0: <10}{1: <50}'.format('NAME', 'CMD')) for pref in hexchat.list_pluginpref(): if pref[:6] == 'alias_': print('{0: <10}{1: <50}'.format(pref[6:], get_alias(pref[6:]))) return hexchat.EAT_ALL def unload_callback(userdata): print(__module_name__, 'version', __module_version__, 'unloaded.') hexchat.hook_command("alias", alias_cb, help=help_msg) hexchat.hook_command("aliases", aliases_cb, help=help_msg) hexchat.hook_command("unalias", unalias_cb, help=help_msg) hexchat.hook_unload(unload_callback) load_aliases() print(__module_name__, 'version', __module_version__, 'loaded.')
continue safes.append(safe) aye.append(safe) if nye: print(cf.vformat("{0:list} {1:is} already in safes.", (nye, len(nye)), {})) save_safe() if aye: print(cf.vformat("{0:list} {1:is} added to safes.", (aye, len(aye)), {})) @command("safe del", args=1) def sadd(*nsafe): global safes aye = [] nye = [] for safe in nsafe: if safe not in safes: nye.append(safe) continue safes.remove(safe) aye.append(safe) if nye: print(cf.vformat("{0:list} {1:is} not in safes.", (nye, len(nye)), {})) save_safe() if aye: print(cf.vformat("{0:list} {1:is} removed from safes.", (aye, len(aye)), {})) hexchat.hook_command("", notice_override) hexchat.hook_command("WW", ww, help="AA") load_safe()
# Convert text to CP1252 encoding since that's what the MPC Web interface reports convert = content.encode('cp1252').decode('utf-8') # Convert the html content into a beautiful soup object soup = BeautifulSoup(convert, "html5lib") # If no web interface then MPC isn't running except: hexchat.prnt('Nothing open in MPC') return # Get the info from the page to parse with regex nowplaying = soup.p.string # Take the text found on the page and run it through regex to grab the info line = re.search('(MPC.*?)\s(.*?)\s•\s(.*?)\s•\s(.*?)\s•\s(.*?(GB|MB))', nowplaying, flags=re.UNICODE) if len(word) > 1 and (word[1] == 'v' or word[1] == 'full'): hexchat.command('SAY Now Playing in {1} : {3} @ {4} [{5}]'.format(line.group(0), line.group(1), line.group(2), line.group(3), line.group(4), line.group(5))) else: hexchat.command('SAY Now Playing in {1} : {3} '.format(line.group(0), line.group(1), line.group(2), line.group(3), line.group(4), line.group(5))) return hexchat.EAT_ALL def unload_callback(userdata): hexchat.prnt('Now Playing script unloaded.') # Hexchat hooks - Command to set in hexchat hexchat.hook_command('np', now_playing, help='"/np" to display currently playing MPC media, "/np full" to show full info.') hexchat.hook_unload(unload_callback) hexchat.prnt('hexchat.mpc.nowplaying loaded')
def generate_colour(last_colour): colour_code = "" while True: colour_code = "\00300," + str(random.randint(1, 12)) if not colour_code == last_colour: break return colour_code def rainbow(key, data, userdata): global enabled if not enabled: return hexchat.EAT_NONE if key[0] == "65293": if (hexchat.get_info("inputbox").startswith("/")): return hexchat.EAT_NONE output = "\002" colour = "" for word in hexchat.get_info("inputbox").strip(" ").split(" "): colour = generate_colour(colour) output = output + colour + " " + word + " " hexchat.command("say " + output) hexchat.command("settext ") return hexchat.EAT_ALL return hexchat.EAT_NONE hexchat.hook_print("Key Press", rainbow) hexchat.hook_command("rainbow", toggle)
print("Failed to load entry {}:".format(ix), str(ex)) ok = False continue key = alert.name.lower() if key in alerts: print( "Failed to load entry {}: Alert '{}' duplicated in save data.". format(ix, alert.name)) ok = False continue alerts[key] = alert def unload_hook(userdata): save() print(("{name} version {version} loaded. Type " + IRC.bold("/alerts help") + " for usage instructions").format(name=__module_name__, version=__module_version__)) load() print("{} alert(s) loaded".format(len(alerts))) hexchat.hook_unload(unload_hook) hexchat.hook_command("alerts", command_hook, help="Configures custom alerts") event_hooks = {} for event in ("Channel Msg Hilight", "Channel Message", "Channel Action", "Private Message", "Private Message to Dialog", "Private Action", "Private Action to Dialog"): event_hooks[event] = hexchat.hook_print(event, message_hook, event)
def mpv_np(caller, callee, helper): try: with MpvIpcClient.for_platform() as mpv: command = mpv.expand_properties(CMD_FMT) if command is None: print("unable to expand property string - falling back to legacy") command = NotImplemented if command is NotImplemented: title = mpv.command("get_property", "media-title") command = LEGACY_CMD_FMT.format(title=title) hexchat.command(command) except OSError: # import traceback; traceback.print_exc() print("mpv IPC not running or bad configuration (see /help mpv)") return hexchat.EAT_ALL if __name__ == '__main__': help_str = ( "Usage: /mpv\n" "Setup: set `input-ipc-server={path}` in your mpv.conf file " "(or adjust the path in the script source)." .format(path=WIN_PIPE_PATH if sys.platform == 'win32' else UNIX_PIPE_PATH) ) hexchat.hook_command("mpv", mpv_np, help=help_str) print(__module_name__, __module_version__, "loaded")