def shorten(word, word_eol, userdata): params = { 'version': '2.0.1', 'login': USERNAME, 'apiKey': API_KEY, 'longUrl': word[1], 'format': 'json', } urlparts = ('https', 'api-ssl.bit.ly', '/shorten', urllib.parse.urlencode(params), '') url = urllib.parse.urlunsplit(urlparts) request = urllib.request.Request(url) response = urllib.request.urlopen(request) data = json.loads(response.read().decode('utf-8')) if data['errorCode'] != 0 or data['errorMessage']: hexchat.emit_print('Generic Message', '*', '\x0304An error occured:') hexchat.emit_print('Generic Message', '*', '\x0304({}) {}'.format( data['errorCode'], data['errorMessage'])) return hexchat.EAT_HEXCHAT short_url = None for url in data['results']: short_url = data['results'][url].get('shortUrl', None) if short_url is not None: hexchat.prnt('Shortened URL: {}'.format(short_url)) return hexchat.EAT_HEXCHAT hexchat.prnt('Shortening failed!') return hexchat.EAT_HEXCHAT
def emote_cb(word, word_eol, event): word = [(word[i] if len(word) > i else "") for i in range(4)] global edited if edited: return if is_twitch(): word[1] = word[1] \ .replace(":)", "😊") \ .replace(":(", "☹") \ .replace(":z", "😴") \ .replace("B)", "😎") \ .replace(";)", "😉") \ .replace(";p", "😜") \ .replace(":p", "😛") \ .replace(":D", "😄") \ .replace(">(", "😠") \ .replace("<3", "♥") \ .replace("BionicBunion", "😺") \ .replace("FrankerZ", "�") \ .replace("ItsBoshyTime", "⚠") \ .replace("Kappa", "�") \ .replace("KZskull", "💀") edited = True hexchat.emit_print(event, *word) edited = False return hexchat.EAT_ALL
def whoischan_cb(word, word_eol, userdata): global Halt if Halt: return hexchat.EAT_NONE chans = {} watwat = "" if word[1].lower() == "is an IRC Operator".lower(): return hexchat.EAT_NONE words = word[1][:-1].split(" ") mchans = getchannels() for i in words: if i[0] != "#": chans[i[1:]] = i[0] else: chans[i] = "" for i in chans: if i in mchans: watwat += chans[i]+"\003"+colour+i + "\017 " else: watwat += chans[i]+i + " " Halt = True hexchat.emit_print("WhoIs Channel/Oper Line", word[0], watwat, "") #print(watwat) Halt = False return hexchat.EAT_ALL
def choder_cb(word, word_eol, userdata, attr): text = RE_cocks.search(word[1]) if not text: return hexchat.EAT_NONE message = text.group(0) if message.startswith(choder.START) or message.startswith(choder.MARK): history = '' if word[0] in buffer: history = buffer[word[0]] if message.endswith(choder.STOP): if message.startswith( choder.START): # we have a single line enchoded message dechoded, _ = choder.dechode(message) formatted = RE_cocks.sub(dechoded, word[1]) hexchat.emit_print("Channel Message", nick_format % word[0], formatted, "") return hexchat.EAT_HEXCHAT else: enchoded = "{} {}".format(history, message) if history else message dechoded, _ = choder.dechode(enchoded) formatted = RE_cocks.sub(dechoded, word[1]) del buffer[word[0]] hexchat.emit_print("Channel Message", nick_format % word[0], formatted, "") return hexchat.EAT_HEXCHAT else: buffer[word[0]] = "{} {}".format(history, message) if history else message return hexchat.EAT_HEXCHAT
def hosttarget_cb(word, word_eol, userdata): source = word[2].replace('#', '', 1) targchan = word[3].replace(':', '#', 1) if targchan != '#-': hexchat.emit_print('Invited', targchan, source, hexchat.get_info('server')) return hexchat.EAT_ALL
def shorten(word, word_eol, userdata): params = { 'version': '2.0.1', 'login': USERNAME, 'apiKey': API_KEY, 'longUrl': word[1], 'format': 'json', } urlparts = ('https', 'api-ssl.bit.ly', '/shorten', urllib.parse.urlencode(params), '') url = urllib.parse.urlunsplit(urlparts) request = urllib.request.Request(url) response = urllib.request.urlopen(request) data = json.loads(response.read().decode('utf-8')) if data['errorCode'] != 0 or data['errorMessage']: hexchat.emit_print('Generic Message', '*', '\x0304An error occured:') hexchat.emit_print( 'Generic Message', '*', '\x0304({}) {}'.format(data['errorCode'], data['errorMessage'])) return hexchat.EAT_HEXCHAT short_url = None for url in data['results']: short_url = data['results'][url].get('shortUrl', None) if short_url is not None: hexchat.prnt('Shortened URL: {}'.format(short_url)) return hexchat.EAT_HEXCHAT hexchat.prnt('Shortening failed!') return hexchat.EAT_HEXCHAT
def new_msg(word, word_eol, event, attrs): """Handles normal messages. Unless this is the first user's message since he joined, the message will not be altered. Otherwise, a '(logged in Xs ago)' message will be appended. """ global halt if halt is True: return user = hexchat.strip(word[0]) # If the user logged in before we did (which means the Join part of # filter_msg didn't take effect), add him to the dict. if user not in last_seen: last_seen[user] = [time(), 1] # If the user has never spoken before, let us know when he logged in. if last_seen[user][1] == 0: time_diff = time() - last_seen[user][0] word[1] += " \00307(logged in %s ago)" % human_readable(time_diff) halt = True hexchat.emit_print(event, *word) halt = False last_seen[user] = [time(), 1] return hexchat.EAT_ALL else: last_seen[user] = [time(), 1]
def _emit_print(event_name, *args): p = hexchat.get_info('event_text {}'.format(event_name)) # replacing these thingies p = p.replace('%C', '\x03') p = p.replace('%B', '\x02') p = p.replace('%O', '\x0F') p = p.replace('%U', '\x1F') p = p.replace('%I', '\x1D') p = re.sub(r'\$(\d+)', r'{\1}', p) # $1 => {1} # event_text starts with $1, str.format with {0} so add an empty # {0} element at the beginning args = [''] + list(args) # raises an error if "{N}" refers to an index # out of range of "args' (N >= len(word) + 1 + 10) try: args += ['']*10 # welp p = p.format(*args) except IndexError: p += ' \x0F\x02\x034(IndexError)\x0F' if '$t' in p: leftp, rightp = p.split('$t', 1) hexchat.emit_print("Generic Message", leftp, rightp)
def printMessage(mode, nick, msg, time): hexchat.emit_print( 'Generic Message', MSG_HEADER % (mode, nick_color(nick), nick), MSG_FORMAT % msg, time = time )
def privmsg_cb(word, word_eol, userdata): if word[0][1:].split("!")[0] == "jtv": for chan in hexchat.get_list("channels"): if chan.type == 1 and chan.id == hexchat.get_prefs("id"): chan.context.set() hexchat.emit_print("Server Text", word_eol[3][1:]) return hexchat.EAT_ALL
def truncate_cb(word, word_eol, userdata): nickname = word[0] if len(nickname) > cutoff: new_nick = nickname[0:cutoff - 1] + "~" hexchat.emit_print(userdata, new_nick, word[1]) return hexchat.EAT_ALL
def modifyKickData(word,word_eol,userdata): if word[1][-1:] == '\xA0': # we need to modify this! kicknick = word[1][:-1].replace(' ','\xA0') hexchat.emit_print('Kick',word[0],kicknick+'@'+OMNOMIDENTSTR,word[2],word_eol[3]) if hexchat.nickcmp(kicknick,hexchat.get_info('nick'))!=0: hexchat.command('RECV :'+kicknick+'!()\xA0'+kicknick+'@'+OMNOMJOINIGNORE+' PART '+word[2]) return hexchat.EAT_ALL
def send_message(word, word_eol, userdata): message = word_eol[0] if message.startswith('>') and not (preferences.ignore_emoticons and len(message) > 1 and message[1] != ' ' and not message[1].isalpha()): message = hexstuff.color_text(message, hexstuff.COLOR_GREEN) hexchat.command('PRIVMSG %s :%s' % (hexchat.get_info('channel'), message)) hexchat.emit_print('Your Message', hexchat.get_info('nick'), message) return hexchat.EAT_HEXCHAT
def privmsg_cb(word, word_eol, userdata): if word[0][1:].split('!')[0] == 'jtv': for chan in hexchat.get_list('channels'): if chan.type == 1 and chan.id == hexchat.get_prefs('id'): chan.context.set() hexchat.emit_print('Server Text', word_eol[3][1:]) return hexchat.EAT_ALL
def send(word, word_eol, userdata): ctxt = hexchat.get_context() """ Only encrypt outgoing message if channel/server is added to DIALOGS list """ if channelServer(ctxt) in DIALOGS: try: message = word_eol[0] """ To avoid the encrypted text gets cut off during transmission encrypt and send the message in chunks of MCHARSIZE character- length . """ for x in range(0, len(message), MCHARSIZE): """ To mark the message as encrypted, 'HEXCHATENC:' is concatenated to the encrypted message. """ hexchat.command('PRIVMSG %s :%s' % (ctxt.get_info('channel'), "HEXCHATENC:" + encrypt(message[x:x + MCHARSIZE]))) """ Message sent, print to dialog window""" hexchat.emit_print('Your Message', hexchat.get_info('nick'), textPos(message)) return hexchat.EAT_HEXCHAT except Exception as e: ctxt.prnt(textNeg("Could not encrypt!")) if DEBUG: ctxt.prnt(str(e)) return hexchat.EAT_ALL return hexchat.EAT_NONE
def new_msg(word, word_eol, event, attrs): """Handles normal messages. Unless this is the first user's message since he joined, the message will not be altered. Otherwise, a '(logged in Xs ago)' message will be appended. """ global halt if halt is True: return user = hexchat.strip(word[0]) # If the user logged in before we did (which means the Join part of # filter_msg didn't take effect), add him to the dict. if user not in last_seen: last_seen[user]= [time(), 1] # If the user has never spoken before, let us know when he logged in. if last_seen[user][1] == 0: time_diff = time() - last_seen[user][0] word[1] += " \00307(logged in %s ago)" % human_readable(time_diff) halt = True hexchat.emit_print(event, *word) halt = False last_seen[user]= [time(), 1] return hexchat.EAT_ALL else: last_seen[user]= [time(), 1]
def hide_hints(network, channel): global halt hexchat.command("clear") halt = True for msg in networks[network][channel]: hexchat.emit_print(msg['event'], *msg['data'], time=msg['time']) halt = False
def enchode(word, word_eol, userdata): # Usage # /enchode [-flags] [/me] # Flags # sN: strokes, where N is the number of strokes to apply # lN: length, where N is the maximum length message to output # The following three flags are mutually exclusive: # m: mixed chodes # t: thin chodes # w: wide chodes cmds = { b'say ': { b'event': b'Channel Message', b'fmt': b'QUOTE PRIVMSG {} :{}' }, b'me ': { b'event': b'Channel Action', b'fmt': b'QUOTE PRIVMSG {} :\x01ACTION {}\x01' } } cmd = b'say ' flags = {b'strokes': 2, 'mode': b't', b'length': 340} modes = { b'm': cpi.CyphallicMethod.MIXED_CHODE, b't': cpi.CyphallicMethod.THIN_CHODE, b'w': cpi.CyphallicMethod.WIDE_CHODE } args = word_eol[1] if args[0:2] == b'--': args = args[1:] else: matches = RE_CMD.match(args) if matches: groups = matches.groupdict() for key in set(groups).intersection(flags): val = groups[key] if val is not None: flags[key] = int(val) if val.isdigit() else val args = args[matches.end(0):] if args[0:2] == b'//': args = args[1:] elif args[0] == b'/': if args[0:4] == b'/me ': args = args[4:] cmd = b'me ' else: hexchat.prnt( b'"{0}" not allowed here. Did you mean "/{0}"?'.format( args[:args.find(b' ')])) return None text = api.enchode(bytearray(args), flags[b'strokes'], modes[flags[b'mode']], flags[b'length']) target = hexchat.get_info('channel') for line in text.splitlines(): hexchat.command(cmds[cmd][b'fmt'].format(target, line)) hexchat.emit_print(cmds[cmd][b'event'], sformat(hexchat.get_info(b'nick'), flags[b'strokes']), args) return hexchat.EAT_HEXCHAT
def printAction(mode, nick, msg, time): color = nick_color(nick) hexchat.emit_print( 'Generic Message', ACTION_HEADER % color, ACTION_FORMAT % (mode, color, nick, msg), time = time )
def coloredmakula(word, word_eol, userdata): file = open(makulafile,'r') data = file.readlines() if word[0] == data[0]: nick = "\002\00304" + word[0] + "\002\003" message = word[1] hexchat.emit_print("Channel Message", nick, message) return hexchat.EAT_ALL
def handle(self, channel, event, words, current, focused, nickname, is_channel): if len(words) < 2: # Blank ACTIONs can cause this. return False if not self.enabled: # Skip disabled events return False if not self.regex.search(words[1]): # Skip non-matching events return False is_pm = not is_channel if self.strip: words[1] = hexchat.strip(words[1], -1, self.strip) if self.replacement is not None: words[1] = self.regex.sub(self.replacement, words[1]) if self.wrap_line is not None: words[1] = self.wrap_line[0] + words[1] + self.wrap_line[1] words[0] = self.wrap_line[0] + words[0] + self.wrap_line[1] hexchat.emit_print(event, *words) if self.abs_sound is not None and not self.mute: playsound(self.abs_sound) if self.copy: copy_to = '>>alerts<<' if self.copy is True else self.copy copy_context = Context.find(current.network, copy_to, current.id) if not copy_context: current.command("QUERY -nofocus " + copy_to) copy_context = Context.find(current.network, copy_to, current.id) if not copy_context: print(IRC.bold("** Unable to open/create query window **")) else: if is_pm: name = nickname + ":(PM)" else: name = nickname + ":" + channel copy_context.emit_print("Channel Message", name, words[1]) if focused != current: if self.focus and (self.focus is self.FORCE or not focused.inputbox): current.command("GUI FOCUS") elif self.notify: if current.network == focused.network: network = "" else: network = "/" + focused.network if is_pm: prefix = "[PM from {nickname}{network}]: ".format(nickname=nickname, network=network) else: prefix = "[{nickname} on {channel}{network}]: ".format( nickname=nickname, channel=channel, network=network ) focused.print(prefix + words[1]) if self.flash: hexchat.command("GUI FLASH") return True
def whispercmd_cb(word, word_eol, userdata): try: log.debug("Got /w: %s", word_eol) hexchat.command("PRIVMSG #jtv :/w %s" % word_eol[1]) hexchat.emit_print('Message Send', word[1], word_eol[2]) return hexchat.EAT_ALL except: log.exception("Unhandled exception in twitch.whispercmd_cb") return hexchat.EAT_ALL
def new_msg(word, word_eol, event, attrs): #handles normal messages global last_seen global halt if halt: return #get username from message user_name = hexchat.strip(word[0]) users = hexchat.get_list("users") #Try to find the user based on the users list user = "******" user_host = "NULL" user_ip = "NULL" for u in users: if(u.nick == user_name): user = u.host user_host = ''.join(user.split('@')[1:]) user_ip = get_ip(user) break #user was logged in before script started if user_host not in last_seen: last_seen[user_host] = [time(), True, user_name, user_ip] #invalid user case (typically user is no longer connected) if user_host == "NULL" or user == "NULL": halt = True hexchat.emit_print(event, *word) halt = False if debug_output: print("\00315Supressed invalid user case") return hexchat.EAT_ALL #user never spoke before if not last_seen[user_host][1]: time_diff = time() - last_seen[user_host][0] #get geoip geoip = get_geoip(user_ip) #add information to message if user_name == last_seen[user_host][2]: word[1] += " \00307(logged in %s ago from \00302%s \00310%s\00307)" % (human_readable(time_diff),user.split('@')[0] + '@' + user_ip,geoip) else: word[1] += " \00307(logged in %s ago. Formerly \00302%s\00307 from \00302%s \00310%s\00307)" % (human_readable(time_diff),last_seen[user_host][2],user.split('@')[0] + '@' + user_ip,geoip) #added host for debug purposes last_seen[user_host][2] = user_name #print message halt = True hexchat.emit_print(event, *word) halt = False last_seen[user_host][1] = True return hexchat.EAT_ALL else: last_seen[user_host][0] = time()
def chgcooldown(word, word_eol, userdata): if len(word) == 1: hexchat.emit_print("Notice", "AutoUB [PL]", "Current cooldown is %s seconds." % str( hexchat.get_pluginpref('aub_cooldown'))) return hexchat.EAT_ALL hexchat.set_pluginpref('aub_cooldown', word[1]) hexchat.emit_print("Notice", "AutoUB [PL]", "Cooldown set to %s seconds." % str( hexchat.get_pluginpref('aub_cooldown')))
def unlock(word, word_eol, userdata): global chan global locked chan = "" locked = 0 if hexchat.get_pluginpref('aub_alertsenabled') == 1: hexchat.emit_print( "Notice", "AutoUB [PL]", "You will be automatically unbanned from channels again. [To turn these alerts off, /noaubalerts]") return hexchat.EAT_ALL
def unload(userdata): "Runs when plugin is unloaded. Not exactly necessary, but..." hexchat.unhook("Channel Message") hexchat.unhook("Private Message") hexchat.unhook("Private Message to Dialog") hexchat.unhook(hook_gpg) hexchat.emit_print( "Channel Message", __module_name__, __module_name__ + " unloaded!" )
def xxmessage_callback(word, word_eol, userdata, attributes): """"This function is called every time a new 'Channel Message' or 'Channel Action' (like '/me hugs elhaym') event is going to occur. Here, we change the event in the way we desire then pass it along.""" global chancolortable global defaultcolortable if playbychat_enabled: event_name = userdata nick = word[0] nick = hexchat.strip(nick, -1, 1) # remove existing colours # This bit prevents infinite loops. # Assumes nicks will never normally begin with "\017". if nick.startswith(ec["o"]): # We already did this event and are seeing it again, because this function gets triggered by events that even it generates. dmsg("Already-processed nick found: " + repr(nick), "LOOP") return hexchat.EAT_NONE dmsg("The time attribute for this event is {}".format(attributes.time), "PRINTEVENT") dmsg("COLORTABLE length = %d" % len(chancolortable), "PRINTEVENT") chan = hexchat.get_info("channel") net = hexchat.get_info("network") ctx = hexchat.get_context() if net not in chancolortable: # create an empty network entry dmsg("Making new network " + net, "COLORTABLE") chancolortable[net] = {} dmsg("chancolortable: %s" % (chancolortable)) if chan not in chancolortable[net]: # make new color table dmsg("Making new color table for " + chan, "COLORTABLE") chancolortable[net][chan] = defaultcolortable[:] dmsg("chancolortable: %s" % (chancolortable)) else: dmsg( "Found COLORTABLE of length " + str(len(chancolortable[net][chan])) + " for channel " + chan + " on network " + net, "COLORTABLE") ctable = chancolortable[net][chan] dmsg("COLORTABLE for " + chan + " on " + net + " = " + str(ctable), "COLORTABLE") color = get_color(ctable, nick) newnick = ecs('o') + col(color) + nick word[0] = newnick #word[1] = "\002\026{0}{1}".format(col(color), word[1]) word[1] = "\002\026{0}{1}".format(col(color), word[1]) dmsg('Old nick: %s - New Nick: %s' % (nick, newnick)) hexchat.emit_print(event_name, *word, time=attributes.time) #hexchat.emit_print(event_name, "\002\026{0}{1}".format(color, word_eol)) if not is_color3_tab(ctx): hexchat.command("gui color 2") # required since HexChat 2.12.4 return hexchat.EAT_ALL else: return hexchat.EAT_NONE
def enchode_cb(word, word_eol, userdata): input = word_eol[1][:150] s = choder.enchode(input,2,340) buffer["input"] = s.splitlines() for dongs in buffer["input"]: hexchat.get_context().command('say ' + dongs) del buffer["input"] hexchat.emit_print("Channel Message", nick_format % hexchat.get_info('nick'), input, "") return hexchat.EAT_HEXCHAT
def greentext_callback(word, word_eol, user_data): word = [word[i] if len(word) > i else '' for i in range(4)] result = hexchat.EAT_NONE if word[1][0] == '>': hexchat.emit_print(user_data, word[0], '\003' + '09' + word[1], word[2], word[3]) result = hexchat.EAT_ALL return result
def youract_cb(word, word_eol, userdata): global yactEdited if yactEdited: return yactEdited = True hexchat.emit_print('Your Action', word[0], strip_cchars(word[1]), '' if len(word) < 3 else word[2]) yactEdited = False return hexchat.EAT_ALL
def togglealerts(word, word_eol, userdata): setting = hexchat.get_pluginpref('aub_alertsenabled') if setting: hexchat.emit_print( "Notice", "AutoUB [PL]", "You have disabled alerts. To turn them on, /aubtogglealerts") else: hexchat.emit_print( "Notice", "AutoUB [PL]", "You have enabled alerts. To turn them off, /aubtogglealerts") hexchat.set_pluginpref('aub_alertsenabled', str(1 - setting)) return hexchat.EAT_ALL
def on_msg(word, word_eol, event): erro = [] global ignores host = word[0] for x in ignores: if fnmatch.fnmatch(host, x): for x in word: erro.append(hexchat.strip(x, flags=1)) hexchat.emit_print(event, *erro) return hexchat.EAT_ALL return hexchat.EAT_NONE
def msg_cb(words, word_eol, print_type): capwords = 0 split_words = words[1].split(' ') for word in split_words: if word.isupper(): capwords = capwords + 1 if capwords / len(split_words) > cap_percentage: hexchat.emit_print(print_type, words[0], words[1].lower()) return hexchat.EAT_ALL
def chanmessage(word, word_eol, userdata, attr): nick = word[0] message = word[1] if (hexchat.nickcmp(hexchat.strip(nick), "B") == 0 or hexchat.nickcmp(hexchat.strip(nick), "BridgeBabe") == 0) and message.startswith("("): name = "." + message[1:message.index(')')] message = message[message.index(')') + 2:] mode = name[1] if name[1] in "@+&~%" else "" hexchat.emit_print(userdata, name, message, mode, time = attr.time) return hexchat.EAT_ALL return hexchat.EAT_NONE
def on_msg(word, word_eol, event): erro = [] global ignores host = word[0] for x in ignores: if fnmatch.fnmatch(host, x): for x in word: erro.append(hexchat.strip(x,flags=1)) hexchat.emit_print(event, *erro) return hexchat.EAT_ALL return hexchat.EAT_NONE
def on_message(word, word_eol, userdata): if hexchat.get_info('channel') == '##crawl': msg_nick, msg_text = word[:2] if msg_nick in BOTS: msg_nick = "\x02\x03{}{}\x02".format( BOTS[msg_nick][1], BOTS[msg_nick][0] ) msg_text = reduce(lambda s, rx: rx[0].sub(rx[1], s), REPLACEMENTS, msg_text) hexchat.emit_print("Channel Message", msg_nick, msg_text, "@") return hexchat.EAT_ALL
def whisper_cb(word, word_eol, userdata): whisper = word_eol[3].replace(':', '', 1) nick = word[0][1:].split('!')[0] context = hexchat.find_context(channel=nick) if context: context.command('recv {} PRIVMSG {}'.format(word[0], word_eol[2])) else: # hexchat.command('recv {} NOTICE {}'.format(word[0], word_eol[2])) # 'Private Message' produces a beep so is preferable hexchat.emit_print('Private Message', nick, whisper) return hexchat.EAT_ALL
def onChannelMessage(params, data, userdata): global emitting parse_incoming = hexchat.get_pluginpref(config_prefix + 'parse_incoming') parse_incoming = True if parse_incoming == None else parse_incoming in positive_input if emitting or not parse_incoming: return hexchat.EAT_NONE emitting = True params[1] = parse(params[1]) hexchat.emit_print('Channel Message', params[0], params[1]) emitting = False return hexchat.EAT_ALL
def whisper_cb(word, word_eol, msgtype): try: nick = twitch.normalize.nick((word[0][1:].split('!')[0])) dest = word[2] msg = word_eol[3][1:] log.debug("Got WHISPER: %s", word) hexchat.emit_print('Notice', nick, msg) except: log.exception("Unhandled exception in twitch.whisper_cb") finally: return hexchat.EAT_ALL
def clearchat_cb(word, word_eol, userdata): if len(word) == 4: hexchat.emit_print( 'Server Text', 'User \00318' + word[3].replace(':', '', 1) + '\017 has been timed out.') elif len(word) == 3: hexchat.emit_print('Server Text', 'Chat has been cleared by a moderator.') else: return hexchat.EAT_NONE return hexchat.EAT_ALL
def privmsg_cb(word, word_eol, userdata): nick = word[0][1:].split('!')[0] if nick == 'jtv' or nick == 'twitchnotify': if word[2][0] != '#': for chan in hexchat.get_list('channels'): if chan.type == 1 and chan.id == hexchat.get_prefs('id'): chan.context.emit_print('Server Text', word_eol[3][1:]) return hexchat.EAT_ALL else: hexchat.emit_print('Server Text', word_eol[3][1:]) return hexchat.EAT_ALL
def sendFilter(word, word_eol, userdata): channel = hexchat.get_info("channel")#get channel to privmsg if word_eol[0][:3]!="+OK" and word_eol[0][:1]!="\\":#if it isn't your new encrypted one or an escaped one hexchat.emit_print("Channel Message", userNickColor + hexchat.get_info("nick"), encryptedTextColor + word_eol[0])#makes it look to you like you spoke in plain text hexchat.command("PRIVMSG "+channel+" :"+crypto(word_eol[0], "e"))#encrypt it if word_eol[0][:1]==escapeCharacter:#if it's escaped hexchat.emit_print("Channel Message", userNickColor + hexchat.get_info("nick"), word_eol[0][1:])#prints it with a stripped \ endCrypto()#makes the sendFilter hook not catch it hexchat.command("PRIVMSG "+channel+" :"+word_eol[0][1:])#dont encrypt it beginCrypto() return hexchat.EAT_HEXCHAT
def check_for_highlight(word, word_to_eol, userdata): global _lastresponder channelname = hexchat.get_context().get_info('channel') windowname = hexchat.find_context().get_info('channel') if channelname in _lastresponder and _lastresponder[channelname] == hexchat.get_info('nick') and windowname != channelname: if len(word) == 2: word.append('') hexchat.emit_print('Channel Msg Hilight', word[0], word[1], word[2]) return hexchat.EAT_ALL update_responder(word, word_to_eol, userdata) return hexchat.EAT_NONE
def receive_message(word, word_eol, userdata): result = re.search("\A>[^\W_].+", word[1]) if result is not None: try: prefix = word[2] except IndexError: prefix = "" hexchat.emit_print("Channel Message", word[0], "\0033"+word[1], prefix) return hexchat.EAT_ALL else: return hexchat.EAT_NONE
def modifyPartData(word,word_eol,userdata): if '\xA0' in word_eol[1]: # we need to modify this! if word[1][-len(OMNOMJOINIGNORE):] == OMNOMJOINIGNORE: return hexchat.EAT_ALL reason = '' if len(word) > 3: p_type = 'Part with Reason' reason = word[3] else: p_type = 'Part' hexchat.emit_print(p_type,word[1][:-len('@'+OMNOMIDENTSTR)],word[0].replace(' ','\xA0')+'@'+OMNOMIDENTSTR,word[2],reason) return hexchat.EAT_ALL
def preprint(words, word_eol, userdata): txt = word_eol[1] replaced = emoji.emojize(txt, use_aliases=True) if replaced != txt: hexchat.emit_print( userdata["msgtype"], words[0], replaced.encode('utf-8'), ) return hexchat.EAT_HEXCHAT else: return hexchat.EAT_NONE
def chanmessage(word, word_eol, userdata): nick = word[0] message = word[1] if hexchat.nickcmp(hexchat.strip(nick), "B") == 0 and message.startswith("("): name = "." + message[1:message.index(')')] message = message[message.index(')') + 2:] mode = name[1] if name[1] in "@+&~%" else "" hexchat.emit_print(userdata, name, message, mode) return hexchat.EAT_HEXCHAT return hexchat.EAT_NONE
def truncate_cb(word, word_eol, userdata): global edited if edited: return nickname = word[0] if len(nickname) > cutoff: edited = True new_nick = nickname[0:cutoff] + "~" hexchat.emit_print(userdata, new_nick, word[1]) edited = False return hexchat.EAT_ALL
def chanmessage(word, word_eol, userdata, attr): nick = word[0] message = word[1] if (hexchat.nickcmp(hexchat.strip(nick), "S") == 0 or hexchat.nickcmp(hexchat.strip(nick), "SpagtBridge") == 0) and message.startswith("<"): name = message[1:message.index('>')] + ":" message = message[message.index('>') + 2:] mode = name[1] if name[1] in "@+&~%" else "" name = name if mode == "" else name[1:] hexchat.emit_print(userdata, name, message, mode, time = attr.time) return hexchat.EAT_ALL return hexchat.EAT_NONE
def disablechan(word, word_eol, userdata): chan = hexchat.get_info('channel') action = userdata if action == "disabled": hexchat.command('RAW PRIVMSG *status :disablechan %s' % chan) if len(word) == 1: hexchat.command('raw PART %s' % chan) elif len(word) >= 2: hexchat.command('raw PART %s :%s' % (chan, word_eol[1])) hexchat.emit_print('Notice', '%s [S]' % __module_name__, 'Parted %s and %s it in ZNC.' % (chan, action)) return hexchat.EAT_ALL
def print_event_callback(word, word_eol, event_name): global emitting if emitting: return hexchat.EAT_NONE message = word[1] if 'http://' in message or 'https://' in message: thread_pool_executor.submit(process_text_event, word, hexchat.get_context()) emitting = True hexchat.emit_print(event_name, *word) emitting = False return hexchat.EAT_HEXCHAT