Exemplo n.º 1
0
def hook_print_message(word, word_eol, userdata):
    nick = hexchat.strip(word[0])
    message = hexchat.strip(word[1])
    channel = hexchat.get_info('channel')
    context = hexchat.get_context()

    # AUTOCHANNEL Check
    key = hexchat.get_info('network') + ' ' + channel.lower()

    if key in AUTOCHANNEL:
        dest_lang, src_lang = AUTOCHANNEL[key]
        threading.Thread(target=worker_hook_print_message,
                         args=(context, message, nick, src_lang,
                               dest_lang)).start()
        #worker_hook_tr(message,'de','en')
        #worker_hook_print_message(context, message, nick, src_lang, dest_lang)
        return hexchat.EAT_NONE

    # AUTOUSER Check
    key_user = hexchat.get_info('network') + ' ' + channel + ' ' + nick.lower()

    if key in AUTOUSER:
        dest_lang, src_lang = AUTOUSER[key_user]
        worker_hook_tr(message, src_lang, dest_lang)
    return hexchat.EAT_NONE
Exemplo n.º 2
0
def _SplitPattern(pattern):
    # Effective pattern for current checking.  This gets modified as we go,
    # so we can't use the 'pattern' variable for this safely...
    ePattern = pattern
    
    # Build a list of [pNick, pIdent, pHost, pRealname] from
    # nick!ident@host#realname.
    
    # Nickname
    pNick = hexchat.strip(ePattern.split('!')[0], -1, 3)
    ePattern = ePattern.split('!')[1]
    
    # Ident
    pIdent = hexchat.strip(ePattern.split('@')[0], -1, 3)
    ePattern = ePattern.split('@')[1]
    
    # This is where it gets tricky...
    # Check if '#' (for realname) exists first
    if ('#' in pattern):
        # Host
        pHost = hexchat.strip(ePattern.split('#')[0], -1, 3)
        
        # Realname
        pRealname = hexchat.strip(ePattern.split('#')[1], -1, 3)

    else:
        # Host
        pHost = hexchat.strip(ePattern, -1, 3)
        
        # Realname not defined, assume "any"
        pRealname = '*'
        
    pattern_raw_segments = [pNick,pIdent,pHost,pRealname]
    return pattern_raw_segments
Exemplo n.º 3
0
def filter_msg(word, word_eol, event, attrs):
    """Filters join and part messages"""
    user = hexchat.strip(word[0])
    # If the user just joined, add him to the dict and mark him as such
    #if 'Join' in userdata:
    if event == "Join":
        if user not in last_seen:
            last_seen[user] = [time(), 0]
            return hexchat.EAT_ALL
    # If the user changed his nick, check if we've been tracking him before
    # and transfer his stats if so. Otherwise, add him to the dict.
    #elif 'Nick' in userdata:
    elif event == "Change Nick":
        user = hexchat.strip(word[1])
        old = hexchat.strip(word[0])
        if old in last_seen:
            last_seen[user] = last_seen[old]
            del last_seen[old]
        else:
            last_seen[user] = [time(), 0]
    # If the user logged in before we did (no entry of him yet), don't display
    # his part messages
    if user not in last_seen:
        return hexchat.EAT_ALL
    # If the user has never spoken, or has spoken too long ago, eat his part
    # or join messages.
    if last_seen[user][1] == 0 or last_seen[user][0] + user_timeout < time():
        return hexchat.EAT_ALL
Exemplo n.º 4
0
def filter_msg(word, word_eol, event, attrs):
    """Filters join and part messages"""
    user = hexchat.strip(word[0])
    # If the user just joined, add him to the dict and mark him as such
    #if 'Join' in userdata:
    if event == "Join":
        if user not in last_seen:
            last_seen[user] = [time(), 0]
            return hexchat.EAT_ALL
    # If the user changed his nick, check if we've been tracking him before
    # and transfer his stats if so. Otherwise, add him to the dict.
    #elif 'Nick' in userdata:
    elif event == "Change Nick":
        user = hexchat.strip(word[1])
        old = hexchat.strip(word[0])
        if old in last_seen:
            last_seen[user] = last_seen[old]
            del last_seen[old]
        else:
            last_seen[user] = [time(), 0]
    # If the user logged in before we did (no entry of him yet), don't display
    # his part messages
    if user not in last_seen:
        return hexchat.EAT_ALL
    # If the user has never spoken, or has spoken too long ago, eat his part
    # or join messages.
    if last_seen[user][1] == 0 or last_seen[user][0] + user_timeout < time():
        return hexchat.EAT_ALL
Exemplo n.º 5
0
def _cb(word, word_eol, userdata):
	if hexchat.strip(word[0]) in ["gonzobot"]:
		duckDetect = re.search("o<|o​<", hexchat.strip(word[1]))
		if duckDetect is not None:
			print("quack")
			context = hexchat.get_context()	
			hexchat.hook_timer(randint(3000,7000), duck, context)
Exemplo n.º 6
0
def define(word, word_eol, userdata):

    if len(word) >= 2:
        define_word = hexchat.strip(word[1])
        definition_number = 1
        if len(word) >= 3:
            definition_number = int(hexchat.strip(word[2]))
    else:
        print(help_str)
        return hexchat.EAT_ALL

    url = 'http://www.google.com/dictionary/json?callback=s&q={}&sl=en&tl=en&restrict=pr,de&client=te'.format(
        escape(define_word))
    response = request.urlopen(url)
    content = response.read()[2:-10].decode('utf-8')
    ascii = re.compile(r'\\x(\w{2})')
    content = ascii.sub(asciirepl, content)
    response.close()

    parser = htmlparser.HTMLParser()
    dic = json.loads(content)
    if 'webDefinitions' in dic:
        try:
            entry = dic['webDefinitions'][0]['entries'][definition_number - 1]
            if entry['type'] == 'meaning':
                definition = entry['terms'][0]['text']
                print('\002{}\017: {}'.format(define_word,
                                              parser.unescape(definition)))
        except IndexError:
            print('Alternate definition {} unavailable for {}'.format(
                definition_number, define_word))
    else:
        print('Definition unavailable for {}'.format(define_word))

    return hexchat.EAT_ALL
Exemplo n.º 7
0
Arquivo: qc.py Projeto: SoniEx2/Stuff
def qcbot_msg(word, word_eol, userdata, attributes):
    ctx = hexchat.get_context()
    if is_qcbot(ctx, word):
        match = userdata[1].match(word[1])
        if match:
            badge, nick, text = match.groups()

            if _badge:
                # to see this, see http://tinyurl.com/hexchatbadge
                if "Mod" in badge:
                    badge = "%B%C07&%C%B"
                elif "Op" in badge:  # or "SrOp" in badge:  # redundant :P
                    badge = "%B%C04@%C%B"
                elif "Owner" in badge or "Admin" in badge:
                    badge = "%B%C02~%C%B"
                elif "Newbie" in badge:
                    badge = "%B%C06?%C%B"
                else:  # for members
                    badge = ""
                badge = hexchat_parse(badge)

            # strip colors
            if not _cols:
                badge = hexchat.strip(badge)
                nick = hexchat.strip(nick)
            else:
                # TODO cache
                evt = hexchat_parse(
                    hexchat.get_info("event_text {}".format(userdata[0])))
                format = Formatting.RESET
                pevt = parse(evt)
                for pos, obj in enumerate(pevt):
                    if isinstance(obj, str):
                        for event_param in hexchat_event_param.finditer(obj):
                            tag = event_param.group()[1]
                            if tag == "1":
                                targetfmt = parse(nick, True, format) - format
                                fmtstr = str(targetfmt)
                                nick = nick + fmtstr
                            elif tag == "2":
                                targetfmt = parse(text, True, format) - format
                                fmtstr = str(targetfmt)
                                text = text + fmtstr
                            elif tag == "3":
                                targetfmt = parse(badge, True, format) - format
                                fmtstr = str(targetfmt)
                                badge = badge + fmtstr
                    else:
                        format = format + obj

            if attributes.time:
                ctx.emit_print(userdata[0],
                               compress_colors(nick),
                               text,
                               badge,
                               time=attributes.time)
            else:
                ctx.emit_print(userdata[0], compress_colors(nick), text, badge)
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE
Exemplo n.º 8
0
def checkStreams():
	global firstRun
	if(firstRun):
		hexchat.unhook(timerHook)
		hexchat.hook_timer(300000, checkStreams_cb)
		firstRun = False

	channels = hexchat.get_list("channels")
	realChannels = []
	channelObjects = {}
	for channel in channels:
		if(channel.server == "tmi.twitch.tv" and channel.channel[0] == '#'):
			realChannels.append(channel.channel.strip('#'))
			channelObjects[channel.channel.strip('#')] = channel
	if len(realChannels) > 0:
		streams = ",".join(realChannels)
		obj = loadJSON('https://api.twitch.tv/kraken/streams?channel=' + streams)
		# Returns only streams that are currently live, but returns them all in one go.
		if (obj is not None):
			streamData = {}
			for stream in obj["streams"]:
				streamData[stream["channel"]["name"]] = stream
			for channel in realChannels:
				newTopic = "\00318{0}\00399 - \00320\002OFFLINE\002\00399 | \035Stream is offline\017".format(channel)
				if (channel in streamData):
					newTopic = "\00318{0}\00399 - \00319\002LIVE\002\00399 for {1} viewers | Now playing: \00318{2}\00399 | {3}".format(streamData[channel]["channel"]["display_name"], streamData[channel]["viewers"], streamData[channel]["channel"]["game"], streamData[channel]["channel"]["status"])
				if (get_topic(channelObjects[channel]) is not None):
					if (hexchat.strip(newTopic) != hexchat.strip(get_topic(channelObjects[channel]))):
						set_topic(channelObjects[channel], newTopic)
				else:
					set_topic(channelObjects[channel], newTopic)
Exemplo n.º 9
0
def define(word, word_eol, userdata):

	if len(word) >= 2:
		define_word = hexchat.strip(word[1])
		definition_number = 1
		if len(word) >= 3:
			definition_number = int(hexchat.strip(word[2]))
	else:
		print(help_str)
		return hexchat.EAT_ALL

	url = 'http://www.google.com/dictionary/json?callback=s&q={}&sl=en&tl=en&restrict=pr,de&client=te'.format(escape(define_word))
	response = request.urlopen(url)
	content = response.read()[2:-10].decode('utf-8')
	ascii = re.compile(r'\\x(\w{2})')
	content = ascii.sub(asciirepl, content)
	response.close()
	
	parser = htmlparser.HTMLParser()
	dic = json.loads(content)
	if 'webDefinitions' in dic:
		try:
			entry = dic['webDefinitions'][0]['entries'][definition_number - 1]
			if entry['type'] == 'meaning':
				definition = entry['terms'][0]['text']
				print('\002{}\017: {}'.format(define_word, parser.unescape(definition)))
		except IndexError:
			print('Alternate definition {} unavailable for {}'.format(definition_number, define_word))
	else:
		print('Definition unavailable for {}'.format(define_word))
	
	return hexchat.EAT_ALL
Exemplo n.º 10
0
def notify(title, message):
	if hexchat.get_prefs('away_omit_alerts') and hexchat.get_info('away'):
		return

	if hexchat.get_prefs('gui_focus_omitalerts') and hexchat.get_info('win_status') == 'active':
		return
	
	Notifier.notify(hexchat.strip(message), title=hexchat.strip(title), sender='org.hexchat', sound='default')
Exemplo n.º 11
0
def nickchange(word, word_eol, userdata):
    oldnick = hexchat.strip(word[0])
    newnick = hexchat.strip(word[1])
    for nick, channel in list(userdata.keys()):
        if hexchat.nickcmp(oldnick, nick) == 0:
            userdata[(newnick, channel)] = userdata[(nick, channel)]
            del userdata[(nick, channel)]
    return hexchat.EAT_NONE
Exemplo n.º 12
0
def nick_cb(word, word_eol, userdata):
    source_nick = hexchat.strip(word[0])
    target_nick = hexchat.strip(word[1])

    tmap.rename(source_nick, target_nick)
    jmap.rename(source_nick, target_nick)
    if check_notify(source_nick) or check_notify(target_nick):
        return hexchat.EAT_NONE

    return check_lasttalk(target_nick)
Exemplo n.º 13
0
Arquivo: qc.py Projeto: SoniEx2/Stuff
def qcbot_msg(word, word_eol, userdata, attributes):
    ctx = hexchat.get_context()
    if is_qcbot(ctx, word):
        match = userdata[1].match(word[1])
        if match:
            badge, nick, text = match.groups()

            if _badge:
                # to see this, see http://tinyurl.com/hexchatbadge
                if "Mod" in badge:
                    badge = "%B%C07&%C%B"
                elif "Op" in badge:  # or "SrOp" in badge:  # redundant :P
                    badge = "%B%C04@%C%B"
                elif "Owner" in badge or "Admin" in badge:
                    badge = "%B%C02~%C%B"
                elif "Newbie" in badge:
                    badge = "%B%C06?%C%B"
                else:  # for members
                    badge = ""
                badge = hexchat_parse(badge)

            # strip colors
            if not _cols:
                badge = hexchat.strip(badge)
                nick = hexchat.strip(nick)
            else:
                # TODO cache
                evt = hexchat_parse(hexchat.get_info("event_text {}".format(userdata[0])))
                format = Formatting.RESET
                pevt = parse(evt)
                for pos, obj in enumerate(pevt):
                    if isinstance(obj, str):
                        for event_param in hexchat_event_param.finditer(obj):
                            tag = event_param.group()[1]
                            if tag == "1":
                                targetfmt = parse(nick, True, format)-format
                                fmtstr = str(targetfmt)
                                nick = nick + fmtstr
                            elif tag == "2":
                                targetfmt = parse(text, True, format)-format
                                fmtstr = str(targetfmt)
                                text = text + fmtstr
                            elif tag == "3":
                                targetfmt = parse(badge, True, format)-format
                                fmtstr = str(targetfmt)
                                badge = badge + fmtstr
                    else:
                        format = format + obj

            if attributes.time:
                ctx.emit_print(userdata[0], compress_colors(nick), text, badge, time=attributes.time)
            else:
                ctx.emit_print(userdata[0], compress_colors(nick), text, badge)
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE
Exemplo n.º 14
0
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
Exemplo n.º 15
0
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
Exemplo n.º 16
0
def notify(title, message):
    if hexchat.get_prefs('away_omit_alerts') and hexchat.get_info('away'):
        return

    if hexchat.get_prefs('gui_focus_omitalerts') and hexchat.get_info(
            'win_status') == 'active':
        return

    Notifier.notify(hexchat.strip(message),
                    title=hexchat.strip(title),
                    sender='org.hexchat',
                    sound='default')
Exemplo n.º 17
0
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 ""

        hexchat.emit_print(userdata, name, message, mode, time=attr.time)
        return hexchat.EAT_ALL
    return hexchat.EAT_NONE
def hook_print_message(word, word_eol, userdata):
    nick = hexchat.strip(word[0])
    message = hexchat.strip(word[1])
    channel = hexchat.get_info('channel')
    context = hexchat.get_context()

    key = hexchat.get_info('network') + ' ' + channel + ' ' + nick.lower()

    if key in AUTOUSER:
        dest_lang, src_lang = AUTOUSER[key]
        threading.Thread(target=worker_hook_print_message, args=(context, message, nick, src_lang, dest_lang)).start()

    return hexchat.EAT_NONE
Exemplo n.º 19
0
def filter_msg(word, word_eol, event, attrs):
    """Filters join and part messages"""
    user = hexchat.strip(word[0]) + "@" +  hexchat.get_info("network")
    # If the user just joined, add
    if event != "Change Nick":
        if user not in last_seen:
            last_seen[user] = [time(), 0, 0]
            return hexchat.EAT_NONE
        elif last_seen[user][0] + user_timeout < time():
            # it has aged off so reset
            last_seen[user] = [time(), 0, last_seen[user][2]] # do not reset special case, it has no expire)
            # now, is special case enabled? if so, check if above special case number.
            if user_sptoomany > -1:
              if last_seen[user][2] >= user_sptoomany:
		last_seen[user] = [time(), last_seen[user][1] + 1, last_seen[user][2] + 1]
		#print("now blocked special case: ", user)
                return hexchat.EAT_ALL

    # If the user changed his nick, check if we've been tracking before
    # and transfer the stats if so. Otherwise, add to the dict.
    if event == "Change Nick":
        user = hexchat.strip(word[1]) + "@" +  hexchat.get_info("network")
        old = hexchat.strip(word[0]) + "@" +  hexchat.get_info("network")
        if old in last_seen:
            # first, check age
            if last_seen[old][0] + user_timeout < time():
                # it has aged off so reset
                last_seen[user] = [time(), 0, last_seen[old][2]] # dont reset special case
	    else:
	        # reset time but not how many times nor special case
	        last_seen[user] = [time(), last_seen[old][1], last_seen[old][2]]
	    # bye old
            del last_seen[old]
            return hexchat.EAT_NONE
        else:
            last_seen[user] = [time(), 0, 0]
            return hexchat.EAT_NONE

    # Not many yet, count and set time again
    if last_seen[user][1] <= user_toomany:
        last_seen[user][0] = time()
        last_seen[user][1] += 1
        last_seen[user][2] += 1
        return hexchat.EAT_NONE
    # too many times join/leave? no spam! (also count and set time again)
    elif last_seen[user][1] > user_toomany:
        last_seen[user][0] = time()
        last_seen[user][1] += 1
        last_seen[user][2] += 1
        #print("now blocked 20 min for join/leave: ", user)
        return hexchat.EAT_ALL
Exemplo n.º 20
0
def msg_cb(word, word_eol, event_name, attrs):
    # Trailing empty words are not included in the word list (here: mode_char, identified_text).
    # For our custom print event, we don't care about the mode_char
    # because we either override it mode char or don't do anything.
    colored_nick, text, _, identified_text = iter_fill(word, 4, "")
    nick = hexchat.strip(colored_nick)

    channel = hexchat.get_info('channel')
    bot_regex = BOT_MAP.get(channel)
    if not bot_regex or not re.search(bot_regex, hexchat.strip(nick), re.IGNORECASE):
        return hexchat.EAT_NONE

    match = re.match(r"^<([^>]+)> (.*)", text)
    if not match:
        return hexchat.EAT_NONE
    original_nick, message = match.groups()
    spaceless_nick = original_nick.replace(" ", "_")  # IRC doesn't like spaces in nicks at all

    gui_color = 2
    if spaceless_nick == hexchat.get_info('nick'):
        event_name = 'Your Message'
        gui_color = 0
    else:
        if not is_user_in_channel(spaceless_nick):
            # TODO test if emit_print also works
            # TODO cannot specify timestamp of msg event
            hexchat.command("RECV :{nick}[email protected] JOIN {channel}"
                            .format(nick=spaceless_nick, channel=channel))
        if "Hilight" in event_name:
            gui_color = 3

    # Manually mark channel as having activity (or highlight)
    # because we consume the original event.
    if gui_color:
        hexchat.command("GUI color {}".format(gui_color))

    # try to decect actions
    if message.startswith(REVERSE_COLOR) and message.endswith(REVERSE_COLOR):
        message = message.strip(REVERSE_COLOR)
        event_name = event_name.replace("Message", "Action").replace("Msg", "Action")

    # replace with proper escape code
    message = message.replace(REVERSE_COLOR, ITALICS)

    hexchat.emit_print(event_name, spaceless_nick, message, MODE_CHAR, identified_text,
                       time=attrs.time)

    return hexchat.EAT_ALL
Exemplo n.º 21
0
def trig_chan(word, word_eol, userdata):
	# Strip input word
	for i in range(len(word)):
		word[i] = hexchat.strip(word[i], -1, 3)
	# Telegram bridge
	IRC_to_Telegram(hexchat.get_context(), word[0], word[1])
	return hexchat.EAT_NONE
Exemplo n.º 22
0
Arquivo: qc.py Projeto: SoniEx2/Stuff
def qcbot_disconnect(word, word_eol, userdata, attributes):
    ctx = hexchat.get_context()
    if is_qcbot(ctx, word):
        match = qc_disconnect_mask.match(word[1])
        if match:
            nick = match.group(1)
            if not _cols:
                nick = hexchat.strip(nick)
            else:
                # TODO cache
                evt = hexchat_parse(hexchat.get_info("event_text Part"))
                format = Formatting.RESET
                pevt = parse(evt)
                for pos, obj in enumerate(pevt):
                    if isinstance(obj, str):
                        for event_param in hexchat_event_param.finditer(obj):
                            tag = event_param.group()[1]
                            if tag == "1":
                                targetfmt = parse(nick, True, format) - format
                                fmtstr = str(targetfmt)
                                nick = nick + fmtstr
                    else:
                        format = format + obj

            if attributes.time:
                ctx.emit_print("Part",
                               compress_colors(nick),
                               qc_player_host,
                               ctx.get_info("channel"),
                               time=attributes.time)
            else:
                ctx.emit_print("Part", compress_colors(nick), qc_player_host,
                               ctx.get_info("channel"))
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE
Exemplo n.º 23
0
def leftjoin(word, word_eol, userdata):

    ctx = hexchat.get_context()
    channel = ctx.get_info('channel')

    # we need the channel object to get the flags
    chanobj = None
    for chan in hexchat.get_list('channels'):
        if hexchat.nickcmp(chan.channel, channel) == 0:
            chanobj = chan
            break

    if chanobj is None:
        return hexchat.EAT_NONE

    # if is this isn't a channel with the "Hide Join/Left" option, just return.
    if chanobj.flags & 0x40 == 0:
        return hexchat.EAT_NONE

    cleanup(userdata['nicks'])

    lnick = hexchat.strip(word[0])
    channel = chan.channel

    for dnick, dchannel in userdata['nicks']:
        if hexchat.nickcmp(lnick, dnick) == 0 \
                and hexchat.nickcmp(dchannel, channel) == 0:
            if time.time() <= userdata['nicks'][(dnick, dchannel)]:
                _emit_print(userdata['type'], *word)
                return hexchat.EAT_ALL
            else:
                del userdata['nicks'][(dnick, dchannel)]

    return hexchat.EAT_NONE
Exemplo n.º 24
0
def shign_shade(word,word_eol,userdata):
    #print(hexchat.strip(word[0]))
    #print(hexchat.get_info('network'))
    nick_color = word[0]
    nick = hexchat.strip(word[0])
    text = hexchat.strip(word[1])
    current_network = hexchat.get_info('network')
    if hexchat.strip(word[0]).lower() in [i.lower() for i in shign_list[0][2:]]:
        print(nick_color + '\t\0031,1' + text)
        return hexchat.EAT_ALL
    else:
        for item in shign_list[1:]:
            if current_network.lower() == item[1].lower() and nick.lower() in [i.lower() for i in item[2:]]:
                print(nick_color + '\t\0031,1' + text)
                return hexchat.EAT_ALL
                break
Exemplo n.º 25
0
    def set_topic(self):
        """
        Set the channel topic (no formatting) and print the topic locally with formatting
        """

        #statusLong = "\00320\002OFF\002\00399"
        statusShort = get_pref("bullet_offline")
        if self.status == 1:
            #statusLong = "\00319\002ON\002\00399"
            statusShort = get_pref("bullet_online")


        if get_pref("modify_topic") == 1:
            msg = "{1}\00318{0}\00399 | {3} | \00318{2}\00399"\
                .format(self.display_name, statusShort, self.game, self.title)

            # HexChat doesn't support hiding characters in the topic bar (Windows), so strip the formatting until it's fixed
            if sys.platform == "win32":
                msg = hexchat.strip(msg, -1, 3)

            if hexchat.get_info("topic") != msg:
                hexchat.command("RECV :[email protected] TOPIC #{0} :{1}".format(self.channel, msg))


        if get_pref("modify_tab") == 1:
            # Set the tab title to the properly capitalized form of the name
            settabCommand = "SETTAB {0}{1}"\
                .format(statusShort, self.display_name)
            hashChannel = "#{0}".format(self.channel)

            cxt = hexchat.find_context(hexchat.get_info("server"), hashChannel)
            if not cxt == None:
                cxt.command(settabCommand)
Exemplo n.º 26
0
def getNick(prefix,nick):
	if bool(hexchat.get_prefs('text_color_nicks')):
		nick = addColor(nick)
	else: # as omnomirc can color nicks on itself
		nick = hexchat.strip(nick)
	nick = nick.replace(' ','\xA0')
	return '\x0F'+prefix+'\x0F\xA0'+nick
Exemplo n.º 27
0
def addColor(s):
	s = hexchat.strip(s)
	rcolors = ['03','04','06','08','09','10','11','12','13']
	i = 0
	for c in s:
		i += ord(c)
	return '\x03'+rcolors[i % 9]+s+'\x0F'
Exemplo n.º 28
0
def whatabot_parser(word, word_eol, userdata):
	if hexchat.strip(word[0]) == "whatabot":
		nick = get_current_nick()
		split = word[1].split(' ')
		ohayous = split[len(split)-3] if len(split) > 2 else ""

		if word[1].find(nick) > -1 and ohayous.isdigit():
			ohayous = int(ohayous)

			while ohayous >= 10:
				if ohayous >= 650:
					say(".buy dragondildo", 1)
					ohayous -= 650
				elif ohayous >= 500:
					say(".buy catnip", 1)
					ohayous -= 500
				elif ohayous >= 300:
					say(".buy godzilla", 1)
					ohayous -= 300
				elif ohayous >= 100:
					say(".buy bag", 1)
					ohayous -= 100
				elif ohayous >= 45:
					say(".buy waifufig", 1)
					ohayous -= 45
				else:
					say(".buy cat", 1)
					ohayous -= 10

	return hexchat.EAT_NONE
Exemplo n.º 29
0
Arquivo: qc.py Projeto: SoniEx2/Stuff
def qcbot_disconnect(word, word_eol, userdata, attributes):
    ctx = hexchat.get_context()
    if is_qcbot(ctx, word):
        match = qc_disconnect_mask.match(word[1])
        if match:
            nick = match.group(1)
            if not _cols:
                nick = hexchat.strip(nick)
            else:
                # TODO cache
                evt = hexchat_parse(hexchat.get_info("event_text Part"))
                format = Formatting.RESET
                pevt = parse(evt)
                for pos, obj in enumerate(pevt):
                    if isinstance(obj, str):
                        for event_param in hexchat_event_param.finditer(obj):
                            tag = event_param.group()[1]
                            if tag == "1":
                                targetfmt = parse(nick, True, format)-format
                                fmtstr = str(targetfmt)
                                nick = nick + fmtstr
                    else:
                        format = format + obj

            if attributes.time:
                ctx.emit_print("Part", compress_colors(nick), qc_player_host, ctx.get_info("channel"),
                    time=attributes.time)
            else:
                ctx.emit_print("Part", compress_colors(nick), qc_player_host, ctx.get_info("channel"))
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE
Exemplo n.º 30
0
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]
Exemplo n.º 31
0
def recv_notice_cb(word, word_eol, userdata):
	global last_context_name
	context_name = None
	nick = word[0][1:].split('!')[0]
	to = word[2]
	if to.startswith('#'):
		return hexchat.EAT_NONE
	if nick == 'ChanServ':
		if word[3].startswith(':[#') and word[3].endswith(']'):
			context_name = word[3][2:-1]
		elif word[3].startswith(':+[#') and word[3].endswith(']'):
			context_name = word[3][3:-1]
		elif word_eol[3].startswith(':Deopped you on channel ') and word_eol[3].endswith(' because it is registered with channel services'):
			context_name = hexchat.strip(word[7])
		elif word_eol[3] == ':and you are not a CHANOP on its access list.':
			context_name = last_context_name
	if not context_name:
		context_name = nick
	if context_name:
		context = hexchat.find_context(server=hexchat.get_info('server'), channel=context_name)
		if not context:
			if context_name.startswith('#'):
				return hexchat.EAT_NONE
			else:
				hexchat.command('QUERY -nofocus %s' % context_name)
			context = hexchat.find_context(server=hexchat.get_info('server'), channel=context_name)
		if context:
			context.set()
			last_context_name = context_name
		else:
			last_context_name = None
Exemplo n.º 32
0
def whatabot_parser(word, word_eol, userdata):
    if hexchat.strip(word[0]) == "whatabot":
        nick = get_current_nick()
        split = word[1].split(' ')
        ohayous = split[len(split) - 3] if len(split) > 2 else ""

        if word[1].find(nick) > -1 and ohayous.isdigit():
            ohayous = int(ohayous)

            while ohayous >= 10:
                if ohayous >= 650:
                    say(".buy dragondildo", 1)
                    ohayous -= 650
                elif ohayous >= 500:
                    say(".buy catnip", 1)
                    ohayous -= 500
                elif ohayous >= 300:
                    say(".buy godzilla", 1)
                    ohayous -= 300
                elif ohayous >= 100:
                    say(".buy bag", 1)
                    ohayous -= 100
                elif ohayous >= 45:
                    say(".buy waifufig", 1)
                    ohayous -= 45
                else:
                    say(".buy cat", 1)
                    ohayous -= 10

    return hexchat.EAT_NONE
Exemplo n.º 33
0
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]
Exemplo n.º 34
0
def channel_msg(word, word_eol, userdata):
    # only show when not focused on hexchat
    # if hexchat.get_info("win_status") == "active":
    #     return None

    # get the channel info for where the message came from
    for ch in hexchat.get_list("channels"):
        # handle only channel
        if ch.type != 2:
            continue

        whitelist = hexchat.get_pluginpref('hxnotify_whitelist').split(',')

        # only show for whitelisted channels
        if word[2] in whitelist:

            # check if the chanopt is set
            if bool(ch.flags & blink_tray):
                my_nick = hexchat.get_info('nick')
                from_user = get_usrname(word[0])

                # fix getting notifcations from self when
                # a bouncer playback is running
                if hexchat.nickcmp(from_user, my_nick) != 0:
                    header = "Message ({0}/{1})".format(ch.network, ch.channel)
                    body = "{0}: {1}".format(from_user,
                                             hexchat.strip(word_eol[3][1:],
                                                           MESSAGE_LIMIT, 3))
                    # send the notification
                    notification(header, body)

            return None

    return None
Exemplo n.º 35
0
def trig_chan(word, word_eol, userdata):
    # Strip input word
    for i in range(len(word)):
        word[i] = hexchat.strip(word[i], -1, 3)
    # Telegram bridge
    IRC_to_Telegram(hexchat.get_context(), word[0], word[1])
    return hexchat.EAT_NONE
Exemplo n.º 36
0
def base_commands(word, word_eol, userdata):
   if hexchat.get_info("network") != "Twitch":
    if word[1] == "help":
        say("Valid commands: help, currenttime, eat, time, uptime, douptime, version, mail")
    elif word[1] == "time":
        say("blargcat was started at " + datetime.strftime(start_time, '%Y-%m-%d %H:%M:%S'))
    elif word[1] == "currenttime":
        say("The current time for blargcat is " + datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S'))
    elif word[1] == "uptime":
        get_uptime(word)
    elif word[1] == "eat":
        eat()
    elif word[1] == "reload":
        reload_config()
        hexchat.unhook(notify_hook)
        hexchat.hook_timer(notif_timer_value, notify)
    # elif word[1] == ".tps":
    #    say("TPS:\0033 19.97")
    # elif word[1] == ".list":
    #    say("\00312Online (2/20): \0034[Admin] \00315blargcat\0031, \0039[Member] \00315FacePolice")
    elif word[1] == "version":
        say("blargcat is running \0039" + __module_name__ + "\0031 version\0039 " + __module_version__)
    elif word[1].startswith("mail"):
        mail(word)
    elif word[1] == "douptime":
        say(".uptime")
    elif word[1].startswith("raw "):
      global authed_user
      print(authed_user)
      print(word[0])
      if authed_user == hexchat.strip(word[0], len(word[0]), 3):
        raw(word[1].replace("raw ", ""))
      else:
        say("You are not authed!")
Exemplo n.º 37
0
def chan_check_cb(word, word_eol, userdata):
    word = [(word[i] if len(word) > i else "") for i in range(4)]
    chan = hexchat.get_info("channel")
    if chan in watched_channels:
        nick = hexchat.strip(word[0], -1, 3)
        time = datetime.now().strftime("[%b %d %Y %H:%M]")
        network = hexchat.get_info("network")
        url_finder(word, nick, network, chan, time)
Exemplo n.º 38
0
def part_cb(word, word_eol, userdata):
    nick = hexchat.strip(word[0])
    if check_notify(nick):
        return hexchat.EAT_NONE
    # do not pop from tmap (in case user rejoins)
    jmap.pop(nick)

    return check_lasttalk(word[0])
Exemplo n.º 39
0
def chan_check_cb(word, word_eol, userdata):
    word = [(word[i] if len(word) > i else "") for i in range(4)]
    chan = hexchat.get_info("channel")
    if chan in watched_channels:
        nick = hexchat.strip(word[0], -1, 3)
        time = datetime.now().strftime("[%b %d %Y %H:%M]")
        network = hexchat.get_info("network")
        url_finder(word, nick, network, chan, time)
Exemplo n.º 40
0
    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
Exemplo n.º 41
0
def nick(n):
    if type(n) is twitch.user.user:
        return n.nick
    elif type(n) is twitch.channel.channel:  # each user has their own channel
        return n.name
    else:
        if len(n) < 1:
            raise ValueError("Invalid nickname")
        return hexchat.strip(n).lower()
Exemplo n.º 42
0
def check_lasttalk(nick):
    for user in hexchat.get_list('users'):
        if user.nick == hexchat.strip(nick):
            if time() - user.lasttalk > 60 * 5:
                return hexchat.EAT_HEXCHAT
            else:
                return hexchat.EAT_NONE

    return hexchat.EAT_HEXCHAT
Exemplo n.º 43
0
def nick(n):
	if type(n) is twitch.user.user:
		return n.nick
	elif type(n) is twitch.channel.channel: # each user has their own channel
		return n.name
	else:
		if len(n) < 1:
			raise ValueError("Invalid nickname")
		return hexchat.strip(n).lower()
Exemplo n.º 44
0
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
Exemplo n.º 45
0
def msg_triggers_cb(word, word_eol, userdata):

    channel = hexchat.get_info("channel")
    allowedChannels = ["#pcasb", "#prettyanon", "#tsp"]
    if channel not in allowedChannels:
        return hexchat.EAT_NONE

    wb_trigger = "!wb"
    removewb_trigger = "!rem"
    addwb_trigger = "!add"
    swapwb_trigger = "!swap"
    magicConch_trigger = "magic conch"
    semenDemon_trigger = "s***n demon"
    excuse_trigger = "!excuse"
    sp_trigger = "!SP"

    if word[1].upper().find(sp_trigger.upper()) is 0:
        help_message(sp_trigger)

    if word[1].upper().find(wb_trigger.upper()) is 0:
        decipher_wb_string(word[1])

    if word[1].upper().find(magicConch_trigger.upper()) is 0:
        hexchat.command("MSG %s %s" % (hexchat.get_info("channel"), wb_cmd()))

    if word[1].upper().find(excuse_trigger.upper()) is 0:
        decipher_excuse_string(word[1])

    if channel == "#pcasb":
        if word[1].upper().find(semenDemon_trigger.upper()) is not -1:
            hexchat.command(
                "MSG %s %s" %
                (hexchat.get_info("channel"), wb_cmd("semendemon")))

    channelList = hexchat.get_list("channels")
    prefixList = []
    for i in channelList:
        if i.channel == channel:
            prefixList = i.nickprefixes
            break

    # prefixList[:-1] to remove last ranked (+v or +) users
    user = hexchat.strip(word[0], -1, 3)
    if (len(word) > 2 and prefixList.find(word[2]) is not -1) or whitelist(
            linkcheck(user)):
        if word[1].upper().find(removewb_trigger.upper()) is 0:
            decipher_rem_string(word[1])

        if word[1].upper().find(addwb_trigger.upper()) is 0:
            decipher_add_string(word[1])

        if word[1].upper().find(swapwb_trigger.upper()) is 0:
            decipher_swap_string(word[1])

    return hexchat.EAT_NONE
Exemplo n.º 46
0
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 buffextras_msg(word, word_eol, userdata, attributes):

    # Check if the message was sent by *buffextras, then check what type of message it was
    if hexchat.strip(word[0]) == "*buffextras":
        for msg_reg, args in msg_types.items():
            match = re.match(msg_reg, word[1])
            if match:
                # Replace all numbers with their match.groups()[index]
                args = [
                    match.groups()[i] if isinstance(i, int) else
                    hexchat.get_info("channel") if i == "<channel>" else i
                    for i in args
                ]
                hexchat.emit_print(*args, time=attributes.time)
                return hexchat.EAT_HEXCHAT

        # Check if the message is a mode change
        if re.match(r"^\S+(!\S+@\S+)? set mode: ((-|\+)?\w+)+ .*$", word[1]):
            setter = word[1].split("!")[0]
            targets = word[1].split()[4:]
            minus = word[1].split()[3].startswith("-")
            for char in word[1].split()[3]:
                if char == "+":
                    minus = False

                elif char == "-":
                    minus = True

                else:
                    mode_sign = "-" if minus else "+"
                    mode_char = mode_sign + char
                    if char in "beIkloqv":
                        mode_target = targets[0]
                        del targets[0]

                    else:
                        mode_target = hexchat.get_info("channel")

                    if mode_char in modes:
                        hexchat.emit_print(modes[mode_char],
                                           setter,
                                           mode_target,
                                           time=attributes.time)

                    else:
                        hexchat.emit_print("Channel Mode Generic",
                                           setter,
                                           mode_sign,
                                           char,
                                           mode_target,
                                           time=attributes.time)

        return hexchat.EAT_HEXCHAT
Exemplo n.º 48
0
def channel(c):
    if type(c) is twitch.channel.channel:
        return c.name
    elif type(c) is twitch.user.user:
        return c.nick
    else:
        c = hexchat.strip(c).lower()
        if len(c) < 1:
            raise ValueError("Invalid channel name")
        if c[0] == '#':
            c = c[1:]
        return c
Exemplo n.º 49
0
 def __call__(self, word, word_eol, userdata):
     # word: [nick, text, modus, identifier]
     text_words = word[1].split()
     if len(text_words) > 0:
         text_word = text_words[0]
         if text_word.lower() == self.prefix.lower() + self.command.lower():
             word[0] = hexchat.strip(word[0])  # nick might be coloured
             if len(word) < 4:
                 word += [None] * (4 - len(word))
             word.append(userdata)
             return super(ChannelCommand, self).__call__(*word)
     else:
         return hexchat.EAT_NONE
Exemplo n.º 50
0
def msg_cb(word, word_eol, event, attrs):
    global edited
    if edited or len(word) < 3 or not word[2] in modes:
        return hexchat.EAT_NONE

    color = modes[word[2]]
    nick = '\003{}{}\00399'.format(color, hexchat.strip(word[0]))
    word = [(word[i] if len(word) > i else '') for i in range(4)]

    edited = True
    hexchat.emit_print(event, nick, word[1], word[2], word[3], time=attrs.time)
    edited = False

    return hexchat.EAT_ALL
Exemplo n.º 51
0
def hook_remove_user(word, word_eol, userdata):
    if len(word) < 2:
        hexchat.prnt("You must specify a user.")
        return hexchat.EAT_ALL

    user = hexchat.strip(word[1])

    if AUTOUSER.pop(
            hexchat.get_info('network') + ' ' + hexchat.get_info('channel') +
            ' ' + user.lower(), None) is not None:
        save_config('google_tr_auto_user', str(AUTOUSER))
        hexchat.prnt('User ' + user + ' has been removed from the watch list.')

    return hexchat.EAT_ALL
Exemplo n.º 52
0
def hook_remove_channel(word, word_eol, userdata):
    if len(word) > 1:
        channel = hexchat.strip(word[1])
    else:
        channel = hexchat.get_info('channel')

    if AUTOCHANNEL.pop(
            hexchat.get_info('network') + ' ' + channel.lower(),
            None) is not None:
        save_config('google_tr_auto_channel', str(AUTOCHANNEL))
        hexchat.prnt('Channel ' + channel +
                     ' has been removed from the watch list.')

    return hexchat.EAT_ALL
Exemplo n.º 53
0
    def notice_callback(word, word_eol, user_data):
        unban_result = hexchat.EAT_NONE
        nickname = hexchat.get_info('nick')

        if re.search(
                r'{0} has been unbanned from {1}\.'.format(nickname, channel),
                hexchat.strip(word[1])):
            hexchat.unhook(notice_hook)
            unban_result = hexchat.EAT_HEXCHAT
            hexchat.command('join {0}'.format(channel))

        elif word[1] == 'Permission denied.':
            hexchat.unhook(notice_hook)

        return unban_result
Exemplo n.º 54
0
def rainbow(s):

	clrs = ["04", "07", "08", "03", "02", "06", "13"]
	current_clr = 0
	rainbow_text = ""
	s = hexchat.strip(s, -1, 1)
	for letter in s:
		# Colourise that letter
		rainbow_text += "\003" + colours[current_clr].zfill(2) + letter
		# Switch to the next colour or go back to the first one
		if current_clr == len(colours) - 1:
			current_clr = 0

		else:
			current_clr += 1

	return rainbow_text
Exemplo n.º 55
0
def hook_say(word, word_eol, userdata):
    message = hexchat.strip(word_eol[0])
    channel = hexchat.get_info('channel')
    context = hexchat.get_context()

    key = hexchat.get_info('network') + ' ' + channel.lower()

    if key in AUTOCHANNEL and message[:2] == '!!':
        print(Bold + hexchat.get_info('nick') + NormalText + Color + '13 > ' +
              message[2:])
        dest_lang, src_lang = AUTOCHANNEL[key]
        threading.Thread(target=worker_hook_str,
                         args=(context, message[2:], src_lang,
                               dest_lang)).start()
        return hexchat.EAT_ALL

    return hexchat.EAT_NONE
Exemplo n.º 56
0
def adfilter_cb(word, word_eol, userdata):
    word = [(word[i] if len(word) > i else "") for i in range(4)]

    global server_nicks
    channel = hexchat.get_info("channel")
    stripped_msg = hexchat.strip(word[1], -1, 3)

    for ad in ad_lst:
        if ad.match(stripped_msg) and channel in channels:
            # Keep a list of server nicknames in case they are needed for filtering purposes
            if word[0] not in server_nicks:
                server_nicks.append(word[0])

            ad_context = find_adtab()
            ad_context.prnt("{0}\t\00318<{4}{3}{1}>\00399 {2}".format(
                channel, *word))

            return hexchat.EAT_ALL
Exemplo n.º 57
0
def textmessage(word, word_eol, userdata):
    global NICK_TIMEOUT

    ctx = hexchat.get_context()
    channel = ctx.get_info('channel').lower()

    # we need the channel object to get the flags
    chanobj = None
    for chan in hexchat.get_list('channels'):
        if hexchat.nickcmp(chan.channel, channel) == 0:
            chanobj = chan
            break

    if chanobj.flags & 0x40 == 0:
        return hexchat.EAT_NONE

    nick = hexchat.strip(word[0])
    userdata[(nick, channel)] = time.time() + NICK_TIMEOUT
    return hexchat.EAT_NONE