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 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__(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__(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 init(): hexchat.hook_command('mask', add_mask, help='Usage: MASK <name>, sets mask for this channel') hexchat.hook_command('maskcolor', override_mask_color, help='Usage: MASKCOLOR <color>, sets mask color to ' + 'one of ' + COLOR_DEMO) hexchat.hook_command('resetmaskcolor', reset_mask_color, help='Resets mask color for this channel') hexchat.hook_command('togglemaskcolors', toggle_mask_colors, help='Toggles mask colors in chat') hexchat.hook_command('unmask', remove_mask, help='Removes mask for this channel') hexchat.hook_command('unmasked', unmasked_message, help='Usage: UNMASKED <message>, sends message ' + 'without mask') hexchat.hook_command('', msg_hook) hexchat.hook_unload(unload) hexchat.prnt('Loaded {} {}'.format(__module_name__, __module_version__))
ctx.emit_print("Kick", qc_host, compress_colors(nick), ctx.get_info("channel"), reason, time=attributes.time) else: ctx.emit_print("Kick", qc_host, compress_colors(nick), ctx.get_info("channel"), reason) return hexchat.EAT_ALL return hexchat.EAT_NONE # Message/action hooks hexchat.hook_print_attrs("Channel Message", qcbot_msg, userdata=["Channel Message", qc_msg_mask]) hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_msg, userdata=["Channel Msg Hilight", qc_msg_mask]) hexchat.hook_print_attrs("Channel Message", qcbot_msg, userdata=["Channel Action", qc_action_mask]) hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_msg, userdata=["Channel Action Hilight", qc_action_mask]) # Connect/disconnect hooks hexchat.hook_print_attrs("Channel Message", qcbot_connect) hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_connect) hexchat.hook_print_attrs("Channel Message", qcbot_disconnect) hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_disconnect) # kick hexchat.hook_print_attrs("Channel Message", qcbot_kick) hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_kick) def unload(userdata): print("qc.py unloaded") hexchat.hook_unload(unload) print("qc.py loaded")
if re.search(user_message) != None and channel == x and hexchat.get_info("network") == net: hexchat.command("mode %s +b *!*%s" % (channel, user_host)) hexchat.command("kick %s regex pattern detected" % user_nickname) return hexchat.EAT_ALL def notice_search(word, word_eol, userdata): if word[2].startswith('#') == False: return user_message = ' '.join(word[3:])[1:] channel = word[2] user_nickname = ''.join(word[0][1:word[0].index('!')]) user_host = ''.join(word[0][word[0].index('@'):]) for x in check_channels: if re.search(user_message) != None and channel == x and hexchat.get_info("network") == net: hexchat.command("mode %s +b *!*%s" % (channel, user_host)) hexchat.command("kick %s regex pattern detected" % user_nickname) return hexchat.EAT_ALL def unload_regexkb(userdata): print(__module_name__, 'version', __module_version__, 'unloaded.') hexchat.hook_server("PRIVMSG", msg_search) hexchat.hook_server("NOTICE", notice_search) hexchat.hook_unload(unload_regexkb) print(__module_name__, 'version', __module_version__, 'loaded.')
def msgchannels(word, word_eol, userdata): channels = word[1] channels = channels.split(",") for channel in channels: parts = channel.split(":") if len(parts) == 2: ctx = hexchat.find_context(server=parts[0], channel=parts[1]) ctx.command("msg {} {}".format(parts[1], word_eol[2])) else: hexchat.command("msg {} {}".format(channel, word_eol[2])) return hexchat.EAT_ALL def on_unload(userdata): global hooks for hook in hooks: if hook is not None: hexchat.unhook(hook) del hooks[:] print("Send Multiple Channels unloaded") hooks.append( hexchat.hook_command( "msgchannels", msgchannels, "Command is /msgchannels <[server:]channel_list> <msg>. Example: /msgchannels freenode:#python,Rizon#news Hello World!" )) hexchat.hook_unload(on_unload) print("Send Multiple Channels v{} loaded".format(__module_version__))
global limit limit = 0 return 0 def unban(word, word_eol, userdata): global limit if limit == 0: nick = hexchat.get_info('nick') hexchat.command('RAW PRIVMSG ChanServ :UNBAN %s %s' % (userdata, nick)) hexchat.command('timer 1 RAW JOIN %s' % userdata) limit = 1 hexchat.hook_timer(2000, timereset) return hexchat.EAT_PLUGIN hexchat.hook_print('You Kicked', rejoin) def nwo_unloaded(userdata): hexchat.emit_print( 'Notice', '', '%s v%s by %s unloaded' % (__module_name__, __module_version__, __module_author__)) return hexchat.EAT_ALL hexchat.emit_print( 'Notice', '', '%s v%s by %s loaded' % (__module_name__, __module_version__, __module_author__)) hexchat.hook_unload(nwo_unloaded)
def main(): for event_name in HOOK_PRINT_EVENTS: hexchat.hook_print(event_name, print_event_callback, event_name) hexchat.hook_timer(OUTPUT_QUEUE_INTERVAL, output_queue_callback) hexchat.hook_unload(unload_callback)
def main(): for event_name in HOOK_PRINT_EVENTS: hexchat.hook_print(event_name, print_event_callback, event_name) hexchat.hook_timer(OUTPUT_QUEUE_INTERVAL, output_queue_callback) hexchat.hook_unload(unload_callback)
return None if hexchat.get_prefs('gui_focus_omitalerts') and hexchat.get_info( 'win_status') == 'active': return None except Exception as err: pass try: if len(word) >= 3: Pop(word[2] + word[0], word[1]) else: Pop(word[0], word[1]) except Exception as err: print('Bubbling Error:') print(err) def unloader(userdata): try: DestroyWindow(w.hwnd) PostQuitMessage(0) UnregisterClass(w.classAtom, w.wc.hInstance) except Exception as err: print('Failed to UnregisterClass():') print(err) hexchat.hook_unload(unloader) hexchat.hook_print("Channel Action Hilight", process) hexchat.hook_print("Channel Msg Hilight", process) hexchat.hook_print("Private Message", process)
pass elif any(word[2] == stopcmd for stopcmd in stopcommands): mySyntax = " " moreInfoLines = ["Terminates all livestreamer processes"] if len(mySyntax) > 0: haveTopic = True else: haveTopic = False if len(moreInfoLines) > 0: haveMoreInfo = True else: haveMoreInfo = False if haveTopic: print("Usage: /xstream {0} {1}".format(word[2], mySyntax)) if haveMoreInfo: for nextLine in moreInfoLines: print("{0}".format(nextLine)) if not haveTopic and len(word) >= 3: print("Sorry, I don't have any help topics for {0}".format(word_eol[2])) return hexchat.EAT_ALL def unload_xstream(userdata): print("{0} unloaded".format(__module_name__)) hexchat.hook_unload(unload_xstream) hexchat.hook_command("xstream", main, help="Usage: /xstream (<channel>) (<quality>) (<server>)") hexchat.hook_command("livestreamer", main, help="Usage: /livestreamer (<channel>) (<quality>) (<server>)") hexchat.hook_command("xs", main, help="Usage: /xs (<channel>) (<quality>) (<server>)") print("{0} {1} loaded".format(__module_name__, __module_version__))
"@search" : hexserv_search, "!search" : hexserv_search, "@find" : hexserv_find, "!find" : hexserv_find, "@request" : hexserv_request, "!request" : hexserv_request, "!" + hexchat.get_info('nick').lower() : hexserv_get }[a[0].lower()](argv[0],a[1:]) except: pass return hexchat.EAT_NONE def removemenu(dt): hexchat.command('MENU DEL HexServ') hexchat.hook_command("hexserv", hexserv_dispatch, help="/hexserv help for commands.") hexchat.hook_print('Channel Msg Hilight', hexserv_usercommands_dispatch) hexchat.hook_print('Channel Message', hexserv_usercommands_dispatch) hexchat.hook_print('Private Message to Dialog', hexserv_usercommands_dispatch) hexchat.hook_print("Private Action to Dialog", hexserv_usercommands_dispatch) hexchat.hook_unload(removemenu) #Add menu items: hexchat.command('MENU -p-1 ADD HexServ') hexchat.command('MENU -t1 ADD HexServ/Enabled "hexserv start" "hexserv stop"') hexchat.command('MENU ADD HexServ/Menu') hexchat.command('MENU ADD HexServ/-') hexchat.command('MENU ADD HexServ/About "hexserv"') #print("{0} module version {1} by {2} loaded.".format(__module_name__, __module_version__, __module_author__))
Translates the message to the specified language with source language detection ''' def translateDetectLang(word, word_eol, userdata): destLang = word[1] message = word_eol[2] url = makeUrl(message, tgt_lang=destLang) run_id = calendar.timegm(time.gmtime()) thread_pool.submit(worker, run_id, url, useragent) return hexchat.EAT_ALL help_message = '/TR <target language> <message> - translates message into the language specified. This auto detects the source language. This is not threaded.' hexchat.hook_command("TR", translateDetectLang, help=help_message) ''' Shuts down the threads and thread controller when unloading the module. ''' def unload_translator(userdata): thread_pool.shutdown(wait=True) print('Translator is unloaded') hexchat.hook_unload(unload_translator) print('Translator script loaded successfully.')
help_hook = "\"/sakill <nick|hostmask> <public reason> | <private oper reason>\"" \ " AKILLs the specified nick or hostmask for 24 hours." def sakill(word, word_eol, userdata): user = word[1] public_reason = ' '.join(word[2:word.index('|')]) private_reason = ' '.join(word[word.index('|') + 1:]) if len(word) > 1: try: hexchat.command("os akill add %s !T 24h You have violated foo's terms of service. " "%s. If in error, please send an e-mail to [email protected] | %s" % (user, public_reason, private_reason)) return hexchat.EAT_ALL except ValueError: hexchat.prnt("USAGE: /sakill <nick|hostmask> <public reason> | <private oper reason>") return hexchat.EAT_ALL else: hexchat.prnt("USAGE: /sakill <nick|hostmask> <public reason> | <private oper reason>") return hexchat.EAT_ALL def unload_sakill(userdata): print(__module_name__, 'version', __module_version__, 'unloaded.') hexchat.hook_command('sakill', sakill, help = help_hook) hexchat.hook_unload(unload_sakill) print(__module_name__, 'version', __module_version__, 'loaded.')
"Notice", nick, "(%s / %s): %s" % (notice_network, notice_host, noticecontent)) return hexchat.EAT_ALL hexchat.hook_server("NOTICE", processNotice) def getnoticetext(noticedata): current_word = 3 # server, NOTICE, nick notice_content = [] while current_word < len(noticedata): if noticedata[current_word] == "": continue if noticedata[current_word][0] == ":" and current_word == 3: noticedata[current_word] = noticedata[current_word][1:] notice_content.append(noticedata[current_word]) current_word = current_word + 1 return ' '.join(notice_content) def addon_unloaded(userdata): print "\0034 %s (%s) unloaded." % (__module_name__, __module_version__) hexchat.hook_unload(addon_unloaded) print "\0034 %s (%s) loaded." % (__module_name__, __module_version__)
userdata.disconnect_hub(host, port) return hexchat.EAT_ALL def urc_unload_hexchat(userdata): try: userdata.loop.close() except Exception as e: prnt("error unloading urc: {}".format(e)) if hexchat: urcd = URCD(False, 'hexchat', False, False) urcd.gui = hexchat urcd.set_proxy("127.0.0.1", 9150) hexchat.hook_command('', urc_broadcast_hexchat, urcd) hexchat.hook_command('urc', urc_command_hexchat, urcd) hexchat.hook_unload(urc_unload_hexchat, urcd) def runhub(urc): prnt("starting up URC HUB") urc.loop = asyncio.new_event_loop() try: urc.start() urc.loop.run_forever() except Exception as e: prnt("error in urc mainloop: {}".format(e)) threading.Thread(target=runhub, args=(urcd,)).start() def main(): import argparse ap = argparse.ArgumentParser() ap.add_argument('--log', type=str, default='warn')
current_channel = hexchat.get_info('channel') url = CHATTERS_URL_TEMPLATE % current_channel[1:] channel_key = server + current_channel hexchat.hook_timer(RETRIEVE_USERLIST_TIMEOUT, retrieve_userlist_update_callback, (url, channel_key)) start_new_thread(retrieve_userlist_update_thread, url, channel_key) channel = None for channel in hexchat.get_list('channels'): if channel.server == server and channel.channel == current_channel: break # This should never happen... assert channel # Initial userlist update, approximately 3 seconds after starting retrieve_userlist_update_thread. hexchat.hook_timer(INITIAL_UPDATE_USERLIST_TIMEOUT, initial_update_userlist_callback, channel) hexchat.hook_timer(UPDATE_USERLIST_TIMEOUT, update_userlist_callback, channel) return hexchat.EAT_NONE if __name__ == '__main__': hooks = [ hexchat.hook_server('366', end_of_names_callback), hexchat.hook_server('PRIVMSG', privmsg_callback) ] hexchat.hook_unload(unload_callback, hooks) print (__module_name__, __module_version__, 'loaded successfully.')
def load_module(module): hexchat.command("py load " + smileclient_path + module + ".py") hexchat.hook_unload(lambda current_module: hexchat.command("py unload smileclient-" + module))
# And find out what he's listening to user = network.get_user(username) track = user.get_now_playing() hexchat.command('me is listening to ' + str(track.title) + ' by ' + str(track.artist) + '.') except: hexchat.prnt( ">> Something's gone wrong! Are you sure you're scrobbling to lastfm?" ) return hexchat.EAT_ALL # We also want to make it unload nicely def unload_mod(userdata): print(__module_name__ + ' version ' + __module_version__ + ' unloaded. Come back soon!') # Now we just need to hook this to Hexchat. hexchat.hook_command('listening', get_song, help='Use /listening with no arguments') hexchat.hook_command( 'fmlogin', fmlogin, help="/fmlogin <username>, needed to authenticate yourself.") hexchat.hook_unload(unload_mod) print(__module_name__ + ' version ' + __module_version__ + ' loaded. Start scrobbling and type /listening on a channel :)')
else: print ("ChatBash is now disabled") return hexchat.EAT_HEXCHAT def send_message(word, word_eol, userdata): global enabled if not enabled: return hexchat.EAT_NONE message = word_eol[0] print("> {}".format(message)) output = subprocess.Popen(message, stdout=subprocess.PIPE, shell=True).communicate()[0].decode('UTF-8') for line in output.split('\n'): print(line) return hexchat.EAT_ALL def on_unload(userdata): global hooks for hook in hooks: if hook is not None: hexchat.unhook(hook) del hooks[:] print("ChatBash unloaded") hooks.append(hexchat.hook_command("chatbash", chatbash, "Command is /chatbash")) hooks.append(hexchat.hook_command("", send_message, priority=hexchat.PRI_HIGHEST)) hexchat.hook_unload(on_unload) print("ChatBash loaded")
pympris.MediaPlayer(_id).root.Identity for _id in player_ids ] # TODO: commands for next/pause if player_num == 0: print('NP: No player found running.') elif player_num == 1: mp = pympris.MediaPlayer(player_ids[0], session_bus) print_nowplaying(mp) elif len(word) == 2: player = word[1] if player in player_names: index = player_names.index(player) mp = pympris.MediaPlayer(player_ids[index]) print_nowplaying(mp) else: print('NP: Player {} not found.'.format(player)) else: print('You have multple players running please insert a name:\n\t', ' '.join(player_names)) return hexchat.EAT_ALL def unload_cb(userdata): print(__module_name__, 'version', __module_version__, 'unloaded.') hexchat.hook_command('np', np_cb, help=np_help) hexchat.hook_unload(unload_cb)
# 1 is caps lock # 4 is num lock mod = int(word[1]) if (word[0] != "65293" and word[0] != "65421") or (mod != 0 and not bs(mod, 1) and not bs(mod, 4)): return msg = hexchat.get_info('inputbox') if msg is None or len(msg) == 0 or msg[0] == '/' or not '.' in msg: return needs_changing = False for key, val in words.items(): search = '\\.' + key + '\\.' regex = re.compile('(?:^|[^a-zA-Z0-9])%s(?:[^a-zA-Z0-9]|$)' % search) if '.%s.' % key == msg or regex.search(msg): msg = msg.replace('.' + key + '.', val) needs_changing = True if needs_changing: hexchat.command('settext %s' % msg) load() hexchat.hook_print('Key Press', message) hexchat.hook_command("cr", command) hexchat.hook_unload(save) print('%s\tLoaded' % __module_name__)
if nick and noticecontent: notice_network = hexchat.get_info("network") notice_host = hexchat.get_info("host") currenttab_network = current_tab.get_info("network") if notice_network == currenttab_network: current_tab.emit_print("Notice", nick, noticecontent) else: current_tab.emit_print("Notice", nick, "(%s / %s): %s" % (notice_network, notice_host, noticecontent)) return hexchat.EAT_ALL hexchat.hook_server("NOTICE", processNotice) def getnoticetext(noticedata): current_word = 3 # server, NOTICE, nick notice_content = [] while current_word < len(noticedata): if noticedata[current_word] == "": continue if noticedata[current_word][0] == ":" and current_word == 3: noticedata[current_word] = noticedata[current_word][1:] notice_content.append(noticedata[current_word]) current_word = current_word + 1 return ' '.join(notice_content) def addon_unloaded(userdata): print "\0034 %s (%s) unloaded." % (__module_name__, __module_version__) hexchat.hook_unload(addon_unloaded) print "\0034 %s (%s) loaded." % (__module_name__, __module_version__)
if 'color' in prefKey: defaultColors() print('LastFM: %s \002%s\017 removed.' % (keyReadable, prefValue)) else: print('LastFM: Value for setting \002%s\017 not found. %s' % (keyReadable, HELPTEXT)) elif word[1].lower() == 'print': prefValue = hexchat.get_pluginpref(prefKey) if hexchat.get_pluginpref(prefKey): print('LastFM: The value of %s is \002%s\017.' % (keyReadable, prefValue)) else: print('LastFM: Value for setting \002%s\017 not found. %s' % (keyReadable, HELPTEXT)) else: print('LastFM: Unknown setting \002%s\017. %s' % (word[2], HELPTEXT)) else: print('LastFM: Unknown command \002%s\017. %s' % (word[1], HELPTEXT)) except: print('LastFM: Not enough parameters. %s' % HELPTEXT) return hexchat.EAT_ALL cleanOldVer() defaultColors() hexchat.hook_command('lastfm', lastFM, help=genHelp()) hexchat.hook_command('np', nowPlaying, help=genHelp()) def lfm_unloaded(userdata): hexchat.emit_print('Notice', '', '%s v%s by %s unloaded' % (__module_name__, __module_version__, __module_author__)) return hexchat.EAT_ALL hexchat.emit_print('Notice', '', '%s v%s by %s loaded' % (__module_name__, __module_version__, __module_author__)) hexchat.hook_unload(lfm_unloaded)
# 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.')
def decorator(func): wrapper = Wrapper(func, on_error) hookid = hexchat.hook_unload(timeout, wrapper, userdata) wrapper.set_hook(hookid) return wrapper
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] == "#": return string[1:] else:
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 if __module_name__ in hexchat.list_pluginpref(): import ast keys_b64 = hexchat.get_pluginpref(__module_name__) try: keys_string = base64.standard_b64decode(keys_b64) channel_keys = ast.literal_eval(keys_string) except TypeError as ex: pass hexchat.hook_print('Channel Message', decrypt_privmsg) hexchat.hook_command('', encrypt_privmsg) # sending regular message hexchat.hook_command('ACTION', encrypt_privmsg, 'CTCP') hexchat.hook_command('ME', encrypt_privmsg, 'CTCP') hexchat.hook_command('AESKEY', set_aes_key, help='/AESKEY "<key>" Set an encryption key for ' 'the current channel. Blank key to unset.') hexchat.hook_unload(lambda x: hexchat.prnt(__module_name__ + ' unloaded')) hexchat.prnt(__module_name__ + ' loaded')
if not (word == ['43', '8', '+', '1']): return try: tempf = tempfile.NamedTemporaryFile(delete=False) img = ImageGrab.grabclipboard() img.save(tempf, "PNG") except: return tempfn = tempf.name client = ImgurClient(client_id, client_secret) up = client.upload_from_path(tempfn) tempf.close() remove(tempfn) cmd = "say " + up['link'].replace("i.imgur.com", "b.bildgur.de") print("Deletelink: http://bildgur.de/delete/" + up['deletehash']) hexchat.command(cmd) return hexchat.EAT_ALL def unload_imagepaste(userdata): print(__module_name__, "version", __module_version__, "unloaded.") hexchat.hook_print("Key Press", imagepaste) hexchat.hook_unload(unload_imagepaste) print(__module_name__, "version", __module_version__, "loaded.")
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)
def decorator(func): wrapper = Wrapper(func, on_error) hookid = hexchat.hook_unload(timeout, wrapper, userdata) wrapper.set_hook(hookid) return wrapper
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() # Debug: :[email protected] PRIVMSG #RatChat :Derry[PingMeIfNeeded] i Pmed you :P # Debug: :[email protected] PRIVMSG #RatChat :ACTION yawns # Debug: :Edmondson[DeepSpace][email protected] NOTICE Dewin[4kly|coding] :like this? # Format: username PRIVMSG/NOTICE CHANNEL :message print( ("{name} version {version} loaded. Type " + IRC.BOLD + "/alerts help" + IRC.ORIGINAL + " 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)
_blackjackstats[user].ties, _blackjackstats[user].ties/totalplays*100)) else: say("You must play first to have scores!") def savestats(dt): pass #print('Saving Blackjack statistics') def blackjack_dispatch(word, word_eol, userdata): try: a = word[1].split() { ".hit" : blackjack_hit, ".stand" : blackjack_stand, ".scores" : blackjack_scores }[a[0].lower()](word[0], a[1:]) except: pass return hexchat.EAT_NONE hexchat.hook_print('Channel Msg Hilight', blackjack_dispatch) hexchat.hook_print('Channel Message', blackjack_dispatch) hexchat.hook_unload(savestats) print('Starting Blackjack bot v{}'.format(__module_version__))
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.')
lastTime = time.time() limit = 1 return hexchat.EAT_PLUGIN def resetmxtm(userdata): global limit limit = 0 return 1 hexchat.hook_command( 'mxtm', mxtmPrefs, help='/mxtm enable turns mxtm on. /mxtm disable turns mxtm off.') hexchat.hook_print('Channel Message', mxtm) hexchat.hook_timer(2000, resetmxtm) def mxtm_unloaded(userdata): hexchat.emit_print( 'Notice', '', '%s v%s by %s unloaded' % (__module_name__, __module_version__, __module_author__)) return hexchat.EAT_ALL hexchat.emit_print( 'Notice', '', '%s v%s by %s loaded' % (__module_name__, __module_version__, __module_author__)) hexchat.hook_unload(mxtm_unloaded)
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.')
if length == 2 and data['nick'] in ADMIN_ACCESS: set_now_playing_source(command_data[1]) if not on_cooldown(data['nick']): now_playing() if cmd == '!viewers': if not on_cooldown(data['nick']): # channel starts with hash say(Twitch.get_channel_views(data['channel'][1:], data['nick'])) if cmd == "!status": if not on_cooldown(data['nick']): # channel starts with hash response = Twitch.get_hosted_channel(data['channel'][1:], data['nick']) if response: say(response) if cmd == "!bookmark": if not on_cooldown(data['nick']): if length == 1: msg = "{0} -> Usage: !bookmark TITLE | http://www.twitch.tv/low_tier_bot/profile/bookmarks".format(data['nick']) say(msg) elif length > 1 and is_mod(data['nick']): Twitch.create_twitch_bookmark(data['channel'], data['message'], data['nick'], PASS_FILE) hexchat.hook_unload(db_unload) hexchat.hook_server('PRIVMSG', process) hexchat.hook_timer(120000, db_commit) hexchat.prnt(__module_name__ + " v" + __module_version__ + " has been loaded.")
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)
import hexchat import re re = re.compile(r"\bfoo\b") # regex pattern to be matched against in user's nickname check_channels = ["#test", "#fooness"] # channel(s) where script is active net = "freenode" # network where script is active def join_search(word, word_eol, userdata): channel = word[2] user_nickname = "".join(word[0][1 : word[0].index("!")]) user_host = "".join(word[0][word[0].index("@") :]) for x in check_channels: if re.search(user_nickname) != None and channel == x and hexchat.get_info("network") == net: hexchat.command("mode %s +b *!*%s" % (channel, user_host)) hexchat.command("kick %s regex pattern detected" % user_nickname) return hexchat.EAT_ALL def unload_joinkb(userdata): print(__module_name__, "version", __module_version__, "unloaded.") hexchat.hook_server("JOIN", join_search) hexchat.hook_unload(unload_joinkb) print(__module_name__, "version", __module_version__, "loaded.")