def BanTimerGo(newInfo=None,newTime=None,onYouJoin=False): global banTimer,nextBanInfo,nextBanTime if onYouJoin: newInfo = None newTime = None #endif curTime = time() if not newTime: for servChan in banTimes: serv,chan = tuple(servChan.split("/",1)) if xchat.find_context(serv,chan): remove = [] for mask in banTimes[servChan]: thTime = banTimes[servChan][mask] if thTime <= curTime: remove.append((servChan,mask,thTime)) elif not nextBanTime or thTime < nextBanTime: newInfo = (servChan,mask) newTime = thTime #endif #endfor for x in remove: BanTimerTick(x) #endif #endfor #endif if newInfo and newTime and (not nextBanTime or newTime < nextBanTime): nextBanInfo = newInfo nextBanTime = newTime if banTimer: xchat.unhook(banTimer) banTimer = xchat.hook_timer((newTime-int(time()))*1000, BanTimerTick)
def skip_print(self, name): def hook_func(word, word_eol, userdata): return xchat.EAT_XCHAT hook = xchat.hook_print(name, hook_func, priority=xchat.PRI_HIGHEST) yield xchat.unhook(hook)
def stop(): global my_hook if my_hook is not None: xchat.unhook(my_hook) my_hook = None print "EasyXdcc stoped" return xchat.EAT_ALL
def initialize(): print "initialize" global original_nick, timer_begins, timer_ends global uppercase_hook, action_hook, nick_hook, heretic_hook global ACF_BEGIN_TIME, ACF_END_TIME, has_joined has_joined = True hooks = [timer_begins, timer_ends, uppercase_hook, action_hook, nick_hook, heretic_hook] for h in hooks: if h is not None: xchat.unhook(h) h = None timer_begins = xchat.hook_timer(time_to(ACF_BEGIN_TIME), ACF_begin) timer_ends = xchat.hook_timer(time_to(ACF_END_TIME), ACF_end) uppercase_hook = xchat.hook_command("", to_uppercase) action_hook = xchat.hook_command("me", to_uppercase_action) nick_hook = xchat.hook_command("nick", change_nick) heretic_hook = xchat.hook_server("PRIVMSG", heretic_patrol) xchat.hook_command("leave", leave_dc801) original_nick = xchat.get_info("nick") if all_caps_friday() and original_nick.islower(): new_nick = original_nick.upper() cmd = "nick %s" % new_nick xchat.command(cmd) return xchat.EAT_ALL return xchat.EAT_NONE
def launch_dl(userdata): global queue, my_hook if None == xchat.get_info("server"): xchat.unhook(my_hook) my_hook = xchat.hook_timer(10000, server_check) else: for bot in getattr(queue, 'bots'): if len(bot) == 0: queue.del_bot(bot) if not bot.isActive(): delqueue() save() bot_context = xchat.find_context(getattr(bot, 'serv'), getattr(bot, 'chan')) if bot_context is None: if xchat.find_context(getattr(bot, 'serv')) is not None: xchat.command("join " + getattr(bot, 'chan')) else: xchat.command("servchan " + getattr(bot, 'serv') + " 6667 " + getattr(bot, 'chan')) bot_context = xchat.find_context(getattr(bot, 'serv'), getattr(bot, 'chan')) try: bot_context.command('msg ' + getattr(bot, 'name') + ' xdcc send #' + str(bot.pop())) except AttributeError: pass return 1
def steiner(text, text_eol, userdata): ignore = ['swim', 'seventyNexus', 'SeventyTwo', 'Noxialis', 'ChanServ', 'cocaine', 'Ultimation_', 'roofletrain', 'Serpentine', 'hachimitsu-boy', 'whatapath', 'YourImaginaryFriend', 'RocketLauncher', 'Onee-chan', 'Fijou', 'DarkAceLaptop', 'GayServ', 'zingas', 'rpk', 'qb', 'mkillebrew', 'whoapath', 'guymann', 'Doomfag', 'maws', 'cunnelatio', 'DenSaakalte', 'martian', 'irc', 'cyberdynesystems', 'net', 'somberlain', 'PhilKenSebben', 'kyokugen', 'Erotica', 'mechanicalTurk', 'ed', 'anon__', 'E-Pain', 'thenoize', 'skew', 'StoneColdSteveAustin', 'frussif', 'Ultimation', 'charles', 'i7MUSHROOM', 'slamm', 'h**o', 'Hypnotized', 'Dr_Venture', 'AoC', 'Porygon', 'axujen', 'Jax', 'Special-G', 'peopleschampion', 'LtSerge', 'Dwarf', 'pinetreegator', 'Cap', '[^_^]', 'swam', 'Clear', 'takoyaki', 'keret', 'MeanPocket', 'keref', 'hachi', 'vortmax', 'War', 'Hachi-chan', 'JediDachshund', 'BillGates', 'BTDT', 'kk', 'guy9000', 'Erzengel', 'Revived', 'BradPitt', 'Colink', 'ekOz', 'Jynweythek'] steiner = "" nick = xchat.strip(text[0]).translate(str.maketrans("", "", "+%@&~")) if nick in ignore or "ScottSteiner" not in xchat.get_info("nick"): return if text[1] == "nothing gayer": steiner = "than {}".format(nick) elif re.search("nothin(?:g(?:'s|)|)gayer", text[1]): steiner = "{} is a f****t".format(nick) elif re.search("nothin(?:g(?:'s|)|) finer than", text[1]) or text[1] == "no one kinder than": steiner = "Scott Steiner" elif re.search("nothin(?:g(?:'s|)|) finer", text[1]) or text[1] == "no one kinder": steiner = "than Scott Steiner" elif text[1] == "nothing is finer": steiner = "than {} being a dumbfuck inbred retard who still can't into a simple script".format(nick) elif text[1] == "big poppa pump": steiner = "IS YOUR HOOKUP. HOLLER IF YA HEAR ME" if steiner: print("{0}<{1}{0}> {2}".format("\x0307", text[0],text[1])) xchat.get_context().command("say {}".format(steiner)) global steinerhook, steinertimer xchat.unhook(steinerhook) steinertimer = xchat.hook_timer(60000, steinertoggle) steinerhook = None return xchat.EAT_XCHAT
def BanTimerGo(newInfo=None, newTime=None, onYouJoin=False): global banTimer, nextBanInfo, nextBanTime if onYouJoin: newInfo = None newTime = None #endif curTime = time() if not newTime: for servChan in banTimes: serv, chan = tuple(servChan.split("/", 1)) if xchat.find_context(serv, chan): remove = [] for mask in banTimes[servChan]: thTime = banTimes[servChan][mask] if thTime <= curTime: remove.append((servChan, mask, thTime)) elif not nextBanTime or thTime < nextBanTime: newInfo = (servChan, mask) newTime = thTime #endif #endfor for x in remove: BanTimerTick(x) #endif #endfor #endif if newInfo and newTime and (not nextBanTime or newTime < nextBanTime): nextBanInfo = newInfo nextBanTime = newTime if banTimer: xchat.unhook(banTimer) banTimer = xchat.hook_timer((newTime - int(time())) * 1000, BanTimerTick)
def unload_cb(userdata): """Esta funcion debe desconectar todas las funciones del modulo al descargarse el script Argumentos: userdata -- variable opcional que se puede enviar a un hook (ignorado) """ # Desconectamos las funciones xchat.unhook(HOOKEJEMPLO1)
def stop(self, userdata): chan = userdata[0].get_info('channel') if chan in self.scrobblers: xchat.unhook(self.scrobblers[chan]) del self.scrobblers[chan] print "scrobbling ended on " + chan else: print "wheren't scrobbling on " + chan
def enumerate_cb(self, data): try: self.enumerate_tabs() except: pass if self.timerhook: xchat.unhook(self.timerhook) self.timerhook = None
def CheckJoin(word,word_eol,userdata): global dInfo sServ=xchat.get_info("network") if sServ in dInfo and word[0] == dInfo[sServ]["nick"]: dInfo[sServ]["on"] = 5 if "timer" in dInfo[sServ]: xchat.unhook(dInfo[sServ]["timer"]) del dInfo[sServ]["timer"]
def unload_cb(userdata): global timer_hook if timer_hook is not None: xchat.unhook(timer_hook) timer_hook = None #force the nick as away update_away_nick() print "[autoaway] Module Unloads!"
def defab_callback(word, word_eol, user_data): global fab_hook if fab_hook is not None: hexchat.unhook(fab_hook) fab_hook = None hexchat.prnt('Fabulous mode off') return hexchat.EAT_ALL
def join_flood_dis(word, word_eol, userdata): global join_flood_e global join_flood_time if join_flood_e > -1: join_flood_e = -1 join_flood_time = 0 xchat.unhook(join_flood_hook) print("Join flood disabled") return xchat.EAT_ALL
def CheckQuit(word,word_eol,userdata): global dInfo sServ=xchat.get_info("network") if sServ in dInfo and word[0] == dInfo[sServ]["nick"]: xchat.command("nick %s" % dInfo[sServ]["nick"]) if "timer" in dInfo[sServ]: xchat.unhook(dInfo[sServ]["timer"]) #endif del dInfo[sServ]
def check_channel(userdata): global cnh global channel cn = xchat.find_context(channel='#%s' % channel) if cn is not None: xchat.unhook(cnh) else: xchat.command("join #" + channel) return xchat.EAT_ALL
def server_check(userdata = None): global my_hook, no_server if 0 == no_server: print "EasyXdcc : waiting for connection" no_server = 1 if None != xchat.get_info("server"): xchat.unhook(my_hook) my_hook = xchat.hook_timer(10000,launch_dl) no_server = 0 return 1
def on_part(word, word_eol, userdata): global jointimer if jointimer: xchat.unhook(jointimer) jointimer = None triggerchannel = word[2].lower() thecontext = xchat.find_context(channel=triggerchannel) if triggerchannel in option["opin"]: if triggerchannel in option["limitchannels"] and option["limitjoins"] == True: jointimer = xchat.hook_timer(option["limittime"], part_limit, userdata=thecontext)
def hookShowMenus(*args): if hasattr(hookShowMenus, 'handler'): xchat.unhook(hookShowMenus.handler) next, meal_type = min((secondsToTime(hour, minute), meal_type) for hour, minute, meal_type in ((8, 0, 'Breakfast'), (11, 45, 'Lunch'), (17, 0, 'Happy Hour'), (17, 45, 'Dinner'))) hookShowMenus.handler = xchat.hook_timer( next * 1000, onTimer, args[:2] + (meal_type,))
def on_join(word, word_eol, userdata): global thecontext global jointimer triggernick = word[0].lower() triggerchannel = word[1].lower() triggerhost = word[2].lower() thecontext = xchat.get_context() if triggerchannel in option["opin"]: xchat.command("whois " + triggernick) if option["clonescan"] == True: clonescan() if triggerchannel in option["limitchannels"] and option[ "limitjoins"] == True: if jointimer: xchat.unhook(jointimer) jointimer = None jointimer = xchat.hook_timer(option["limittime"], join_limit, userdata=thecontext) if option["antiflood"] == False and option[ "autovoice"] == True and triggerchannel in option["voicein"]: thecontext.command("voice " + triggernick) elif option["antiflood"] == True: #Check if the user is in the dictionary if not check if their host matches any if not add it if triggernick not in users[triggerchannel]: for user in users[triggerchannel]: if users[triggerchannel][user].host == triggerhost: users[triggerchannel][triggernick] = users[ triggerchannel][user] break #check the dictionary again as we may have added during the host check if triggernick not in users[triggerchannel]: users[triggerchannel][triggernick] = User(host=triggerhost) else: users[triggerchannel][triggernick].joined += 1 if users[triggerchannel][triggernick].joined >= option[ "antifloodlimit"]: thecontext.command("ban " + "*!" + triggerhost) thecontext.command("kick " + triggernick + " " + option["msgjoinflood"]) if triggerchannel in option["voicein"] and option[ "autovoice"] == True: for user in users[triggerchannel]: if users[triggerchannel][ user].host == triggerhost and users[ triggerchannel][user].devoiced == False: thecontext.command("voice " + triggernick) break
def unload_cb(userdata): """Esta funcion debe desenlazar todas las funciones del modulo al descargarse el script. Argumentos: userdata -- variable opcional que se puede enviar a un hook (ignorado) """ # Desconectamos los comandos # Controles remotos xchat.unhook(HOOKREMOTO) # Descarga xchat.unhook(HOOKREMOTOS)
def _xchatHookTest(self, timeout): print 'hooked timer' print time.time() print self._hook_wait print timeout if time.time() >= self._hook_wait + timeout: if self.hooked_timer: print 'hooked timer unhooked' xchat.unhook(self.hooked_timer) self.hooked_timer = None self.xchatHook()
def unload_cb(userdata): xchat.unhook(HOOKGHELP) for entry in dir(gmodules): if "__" not in entry: command = ''.join(["gmodules.", entry, ".unload()"]) messages = eval(command) if messages is not None: for message in messages: print(message) xchat.unhook(HOOKUNLOAD) xchat.command('menu del GatoScript') print("".join(["GatoScript ", __module_version__, " has been unloaded"]))
def SendMessage(userdata): global dTimers,lSent # Is user still around? if userdata[0] in map((lambda x: x.nick),userdata[1].get_list("users")): method = GetOpt(0,userdata[1]) if method != "say": lSent.append(userdata[0]) xchat.command("%s %s %s" % (method,userdata[0],GetOpt(2,userdata[1]))) #xchat.prnt("Sent %s the message." % userdata[0]) #else: #xchat.prnt("%s left early." % userdata[0]) #endif xchat.unhook(dTimers[userdata[0]])
def unload_plugin(userdata): global TIMEOUT_HOOK global CONN if TIMEOUT_HOOK is not None: xchat.unhook(TIMEOUT_HOOK) TIMEOUT_HOOK = None if CONN is not None: Translator.closeConnection() xchat.prnt("Translator is unloaded.") return None
def on_part(word, word_eol, userdata): global jointimer if jointimer: xchat.unhook(jointimer) jointimer = None triggerchannel = word[2].lower() thecontext = xchat.find_context(channel=triggerchannel) if triggerchannel in option["opin"]: if triggerchannel in option["limitchannels"] and option[ "limitjoins"] == True: jointimer = xchat.hook_timer(option["limittime"], part_limit, userdata=thecontext)
def unload_cb(userdata): xchat.unhook(HOOKGHELP) for entry in dir(gmodules): # Since helper module isn't directly loaded, it doesn't neet to be # directly unloaded either if "__" not in entry and entry is not "helper": command = ''.join(["gmodules.", entry, ".unload()"]) messages = eval(command) if messages: for message in messages: print(message) xchat.unhook(HOOKUNLOAD) xchat.command('menu del GatoScript') print("".join(["GatoScript ", __module_version__, " has been unloaded"]))
def joiner(self, word, word_eol, userdata): nick = xchat.get_info('nick') if word[0].find(nick) > -1: timeout = 3 if len(self.hooked): for handler in self.hooked: xchat.unhook(handler) self.hooked = [] self._hook_wait = time.time() if not self.hooked_timer: print 'register hook timer' self.hooked_timer = xchat.hook_timer(timeout * 1000, self._xchatHookTest, (timeout))
def noticecb(word, word_eol, userdata): match = NICKPATTERN.match(word[0]) matchtxt = 'Ghost with your nick has been killed.' if not match or xchat.nickcmp(match.group(1), 'NickServ') != 0: return xchat.EAT_NONE if word_eol[-2][1:] == 'Access denied.': xchat.unhook(userdata["hook"]) elif len(word_eol) > 7 and word_eol[-7][1:] == matchtxt: u = {} u.update(userdata) c = u["context"] c.command("nick " + u["nick"]) u["hook"] = xchat.hook_server("", identifycb, userdata=u) xchat.unhook(userdata["hook"]) return xchat.EAT_NONE
def on_join(word, word_eol, userdata): global thecontext global jointimer triggernick = word[0].lower() triggerchannel = word[1].lower() triggerhost = word[2].lower() thecontext = xchat.get_context() if triggerchannel in option["opin"]: xchat.command("whois " + triggernick) if option["clonescan"] == True: clonescan() if triggerchannel in option["limitchannels"] and option["limitjoins"] == True: if jointimer: xchat.unhook(jointimer) jointimer = None jointimer = xchat.hook_timer(option["limittime"], join_limit, userdata=thecontext) if option["antiflood"] == False and option["autovoice"] == True and triggerchannel in option["voicein"]: thecontext.command("voice " + triggernick) elif option["antiflood"] == True: # Check if the user is in the dictionary if not check if their host matches any if not add it if triggernick not in users[triggerchannel]: for user in users[triggerchannel]: if users[triggerchannel][user].host == triggerhost: users[triggerchannel][triggernick] = users[triggerchannel][user] break # check the dictionary again as we may have added during the host check if triggernick not in users[triggerchannel]: users[triggerchannel][triggernick] = User(host=triggerhost) else: users[triggerchannel][triggernick].joined += 1 if users[triggerchannel][triggernick].joined >= option["antifloodlimit"]: thecontext.command("ban " + "*!" + triggerhost) thecontext.command("kick " + triggernick + " " + option["msgjoinflood"]) if triggerchannel in option["voicein"] and option["autovoice"] == True: for user in users[triggerchannel]: if ( users[triggerchannel][user].host == triggerhost and users[triggerchannel][user].devoiced == False ): thecontext.command("voice " + triggernick) break
def rename_name(word, word_eol, userdata): # get the facebook name from whois, decode with string-escape, decode as utf-8, # encode to ascii and trim all spaces so you get the final name name = word[3].decode('string-escape').decode("utf-8").encode("ascii","ignore").replace(" ", "") # issue a command on channel &bitlbee to rename the ugly name to the new name xchat.command("msg &bitlbee rename %s %s" % (word[0], name)) # unhooking (use global variable) global rename_hook # if there is a hook if rename_hook is not None: # unhook xchat.unhook(rename_hook) # and set to None rename_hook = None # catch this print in other windows or something return xchat.EAT_ALL
def unload(): """This function disconects all module functions""" # Store all pending changes to the database helper.gatodb_commit() # Disconnect everything else xchat.unhook(HOOKANTISPAM) xchat.unhook(HOOKANTIADD) xchat.unhook(HOOKANTILIST) xchat.unhook(HOOKANTIDEL)
def steiner(text, text_eol, userdata): ignore = [ 'swim', 'seventyNexus', 'SeventyTwo', 'Noxialis', 'ChanServ', 'cocaine', 'Ultimation_', 'roofletrain', 'Serpentine', 'hachimitsu-boy', 'whatapath', 'YourImaginaryFriend', 'RocketLauncher', 'Onee-chan', 'Fijou', 'DarkAceLaptop', 'GayServ', 'zingas', 'rpk', 'qb', 'mkillebrew', 'whoapath', 'guymann', 'Doomfag', 'maws', 'cunnelatio', 'DenSaakalte', 'martian', 'irc', 'cyberdynesystems', 'net', 'somberlain', 'PhilKenSebben', 'kyokugen', 'Erotica', 'mechanicalTurk', 'ed', 'anon__', 'E-Pain', 'thenoize', 'skew', 'StoneColdSteveAustin', 'frussif', 'Ultimation', 'charles', 'i7MUSHROOM', 'slamm', 'h**o', 'Hypnotized', 'Dr_Venture', 'AoC', 'Porygon', 'axujen', 'Jax', 'Special-G', 'peopleschampion', 'LtSerge', 'Dwarf', 'pinetreegator', 'Cap', '[^_^]', 'swam', 'Clear', 'takoyaki', 'keret', 'MeanPocket', 'keref', 'hachi', 'vortmax', 'War', 'Hachi-chan', 'JediDachshund', 'BillGates', 'BTDT', 'kk', 'guy9000', 'Erzengel', 'Revived', 'BradPitt', 'Colink', 'ekOz', 'Jynweythek' ] steiner = "" nick = xchat.strip(text[0]).translate(str.maketrans("", "", "+%@&~")) if nick in ignore or "ScottSteiner" not in xchat.get_info("nick"): return if text[1] == "nothing gayer": steiner = "than {}".format(nick) elif re.search("nothin(?:g(?:'s|)|)gayer", text[1]): steiner = "{} is a f****t".format(nick) elif re.search("nothin(?:g(?:'s|)|) finer than", text[1]) or text[1] == "no one kinder than": steiner = "Scott Steiner" elif re.search("nothin(?:g(?:'s|)|) finer", text[1]) or text[1] == "no one kinder": steiner = "than Scott Steiner" elif text[1] == "nothing is finer": steiner = "than {} being a dumbfuck inbred retard who still can't into a simple script".format( nick) elif text[1] == "big poppa pump": steiner = "IS YOUR HOOKUP. HOLLER IF YA HEAR ME" if steiner: print("{0}<{1}{0}> {2}".format("\x0307", text[0], text[1])) xchat.get_context().command("say {}".format(steiner)) global steinerhook, steinertimer xchat.unhook(steinerhook) steinertimer = xchat.hook_timer(60000, steinertoggle) steinerhook = None return xchat.EAT_XCHAT
def BanTimerTick(userdata=None): global banTimer,banTimes,nextBanInfo,nextBanTime if banTimer: xchat.unhook(banTimer) banTimer = None #endif banTime = nextBanTime if userdata: servChan,mask,banTime = userdata else: servChan,mask = nextBanInfo serv,chan = tuple(servChan.split("/",1)) context = xchat.find_context(serv,chan) if context: context.command("mode %s -b %s" % (chan,mask)) try: del banTimes[servChan][mask] except KeyError: pass #endif if not userdata: nextBanInfo = nextBanTime = None BanTimerGo()
def initialize(word, word_eol, userdata): global CONN global ACTIVE_JOBS global WATCHLIST global TIMEOUT_HOOK if TIMEOUT_HOOK is not None: xchat.unhook(TIMEOUT_HOOK) TIMEOUT_HOOK = None if CONN is not None: CONN.close() CONN = None ACTIVE_JOBS = 0 WATCHLIST = {} xchat.prnt("Translator reinitialized") return xchat.EAT_ALL
def BanTimerTick(userdata=None): global banTimer, banTimes, nextBanInfo, nextBanTime if banTimer: xchat.unhook(banTimer) banTimer = None #endif banTime = nextBanTime if userdata: servChan, mask, banTime = userdata else: servChan, mask = nextBanInfo serv, chan = tuple(servChan.split("/", 1)) context = xchat.find_context(serv, chan) if context: context.command("mode %s -b %s" % (chan, mask)) try: del banTimes[servChan][mask] except KeyError: pass #endif if not userdata: nextBanInfo = nextBanTime = None BanTimerGo()
def got_319(self, word, word_eol, userdata): user = word[3] channel = word_eol[4].lstrip(":") channel = channel.split(" ") print "removing.. %s aus %r" % (user,channel) for chan in channel: xchat.command("QUOTE sapart %s %s" % (user, chan.lstrip("+%@&~"))) if self.whoishook: xchat.unhook(self.whoishook) self.whoishook = None if self.timer: xchat.unhook(self.timer) self.timer = None def reset(self, userdata): if self.whoishook: xchat.unhook(self.whoishook) self.whoishook = None self.timer = None return False
def bot_cb(word, word_eol, userdata): global counter global timeless global h_timer if len(word) == 1: fire(0) elif word[1] == 'start': timeless = True fire(0) elif word[1] == 'stop': timeless = False counter = 0 XC.unhook(h_timer) game.prnt('-= hangman game stoped =-') elif word[1] == 'status': game.prnt('-= hangman bot status =-') game.prnt('timeless mode: ' + str(timeless)) game.prnt('games left: ' + str(counter)) else: counter = int(word[1]) fire(0)
def __del__(self): for hook in self.hooks: xchat.unhook(hook)
def stop_timer(word, word_eol, userdata): global myhook if myhook is not None: xchat.unhook(myhook) myhook = None print 'Timer removed!'
def on_stop(self, word, word_eol, userdate): if self._hook is not None: xchat.unhook(self._hook) xchat.prnt('%s deactivated' % __module_name__) self._hook = None return xchat.EAT_ALL
def sasl_90x_cb(word, word_eol, userdata): # Remove timer xchat.unhook(saslTimers[xchat.get_info('network')]) xchat.command('CAP END') return xchat.EAT_NONE
def reset(): global answer, counter xchat.unhook(xchat_timer) answer = None counter = 0
def unload_cb(arg): for hook in hooks: xchat.unhook(hook) numerator.log("successfully unloaded")
def not_msg_color(word, word_eol, userdata): global color_hook xchat.unhook(color_hook) color_hook = "OFF" print("uncoloring") return xchat.EAT_ALL
def disable(self, *args): dprint("disable()") if self.privmsg_hook: xchat.unhook(self.privmsg_hook) self.privmsg_hook = None
def stop(self, *args): self.disable() xchat.unhook(self.control_hook)
def readResults(cls, userdata=None): global TIMEOUT_HOOK global WATCHLIST global IGNORELIST global ACTIVE_JOBS request = dict(Outgoing=None, Channel=None, User=None, Srctxt=None, Srclang=None, Tgttxt=None, Tgtlang=None, Echotxt=None, Echo=False, Kill=False, Read=True) jsonStr = json.dumps(request).encode("utf-8") CONN.send(jsonStr) result = json.loads(CONN.recv(BUFFER_SIZE).decode("utf-8")) key = result["Channel"] + " " + result["User"] user = result["User"] if type(result) == dict: if result["Outgoing"]: pruser = "******" + user txt = pruser + result["Tgttxt"] xchat.command("say " + txt) if ECHO: context = xchat.find_context(channel=result["Channel"]) txt = result["Echotxt"] context.emit_print("Channel Message", "_[echo]", txt) if WATCHLIST is not None and key in WATCHLIST: dest, src, cnt = WATCHLIST[key] cnt = cnt - 1 if src == "auto" and ENABLE_UPDATELANG: src = result["Srclang"] WATCHLIST[key] = (dest, src, cnt) elif user is not None and user != "" and ENABLE_UPDATELANG: dest = DEFAULT_LANG src = result["Srclang"] cnt = 0 WATCHLIST[key] = (dest, src, cnt) pass elif result["Srclang"] != result[ "Tgtlang"] and user is not None and user != "": context = xchat.find_context(channel=result["Channel"]) txt = result["Tgttxt"] context.emit_print("Channel Message", "_[%s]" % (result["User"]), txt) if WATCHLIST is not None and key in WATCHLIST: dest, src, cnt = WATCHLIST[key] cnt = cnt - 1 if src == "auto" and ENABLE_UPDATELANG: src = result["Srclang"] WATCHLIST[key] = (dest, src, cnt) pass if result["Srclang"] == result[ "Tgtlang"] and user is not None and user != "": cnt = 1 if key in WATCHLIST: dest, src, cnt = WATCHLIST[key] cnt = cnt + 1 WATCHLIST[key] = (dest, src, cnt) else: dest = DEFAULT_LANG src = result["Srclang"] cnt = 1 WATCHLIST[key] = (dest, src, cnt) if cnt >= MAX_ERROR: WATCHLIST.pop(key, None) IGNORELIST[key] = (dest, src) ACTIVE_JOBS -= 1 if ACTIVE_JOBS <= 0: xchat.unhook(TIMEOUT_HOOK) TIMEOUT_HOOK = None cls.closeConnection() return None
def unload(user_data): xchat.unhook(media_hook)
def hook_func(userdata_): func(*args, **kwargs) xchat.unhook(hook)