예제 #1
0
파일: nohide.py 프로젝트: nitori/tools
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
예제 #2
0
def responder_hook(word, word_eol, userdata):
    triggering_command = word[1]
    triggering_channel = hexchat.get_info("channel")
    responding_channel = False
    for channel in responding_channels:
        if (hexchat.nickcmp(triggering_channel, channel) == 0):
            responding_channel = True
    if responding_channel:
        triggering_user = word[0][1:].split('!', 1)[0]
        if (hexchat.nickcmp(triggering_command, "PRIVMSG") == 0
                or hexchat.nickcmp(triggering_command, "NOTICE") == 0):
            overly_happy = False
            if (word[3] == ":D" or word[3] == "::D" or word[3] == ":+:D"):
                for user in overly_happy_users:
                    if (hexchat.nickcmp(triggering_user, user) == 0):
                        overly_happy = True
                        break
                if (overly_happy):
                    print("Ignoring message from overly happy user: {}".format(
                        triggering_user))
                    return hexchat.EAT_NONE
        command = "MSG"
        if (hexchat.nickcmp(triggering_command, "NOTICE") == 0):
            command = "NOTICE"
        hexchat.command(command + " " + triggering_channel + " :D")
        if super.check_debug():
            print("This :D brought to you by: " + word_eol[0])
    return hexchat.EAT_NONE
예제 #3
0
def handle_kick(word, word_eol, userdata):
    channel = hexchat.get_info("channel")
    if (hexchat.nickcmp(channel, userdata) == 0):
        if (hexchat.nickcmp(word[3], hexchat.get_info("nick")) == 0):
            print("Kicked from {}. Rejoining in {}ms…".format(
                channel, rejoin_delay))
            rejoin_hooks[channel] = hexchat.hook_timer(rejoin_delay, rejoin,
                                                       channel)
    return hexchat.EAT_NONE
예제 #4
0
def keypress(w, we, u):
    if re.search(affected_networks, hexchat.get_info("network")):
        key, state, key_str, str_len = w
        if int(key) == 65289: # <Tab>
            inputbox = hexchat.get_info("inputbox")
            pos = hexchat.get_prefs("state_cursor")
            text, suffix = inputbox[:pos], inputbox[pos:]
            prefix, space, word = text.rpartition(" ")
            if len(word):
                prefix += space
                if word[0] == '#':
                    return hexchat.EAT_NONE # let the built-in completion handle channels
                if word[0] == '@':
                    word = word[1:]
                users = []
                for u in hexchat.get_list("users"):
                    if not hexchat.nickcmp(u.nick[:len(word)], word):
                        users.append((u.nick, u.lasttalk))
                for c in hexchat.get_list("channels"):
                    if c.context == hexchat.get_context():
                        if c.type == 3:
                            if not hexchat.nickcmp(c.channel[:len(word)], word):
                                users.append((c.channel, 0)) # if we're in a dialog, include the targer user
                if len(users):
                    if len(users) == 1:
                        completion = "@" + users[0][0] + " "
                    else:
                        if hexchat.get_prefs("completion_sort") == 1:
                            users = sorted(users, key = lambda x: -x[1])
                        else:
                            users = sorted(users, key = lambda x: x[0].lower())
                        nicks = [u[0] for u in users]
                        print(" ".join(nicks))
                        common = None # longest common prefix
                        for nick in nicks:
                            if common == None:
                                common = word + nick[len(word):] # copy the case of characters entered by the user
                            else:
                                while hexchat.nickcmp(nick[:len(common)], common):
                                    common = common[:-1]
                        for nick in nicks:
                            if not hexchat.nickcmp(nick, word):
                                common = nick # if we have an exact match, ignore the case of user's characters
                        completion = "@" + common
                    hexchat.command("settext " + prefix + completion + suffix)
                    hexchat.command("setcursor " + str(len(prefix) + len(completion)))
                return hexchat.EAT_ALL
            else:
                prevword = prefix.rpartition(" ")[2]
                if len(prevword) and prevword[0] == '@':
                    return hexchat.EAT_ALL # don't let the built-in completion kick in if we just completed a nick
                else:
                    return hexchat.EAT_NONE
        else:
            return hexchat.EAT_NONE
예제 #5
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
예제 #6
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
예제 #7
0
파일: bot.py 프로젝트: Bobrm2k3/pail
def handleKickMsg(kicker, kickee, kickChan, kickMsg):
  #if bot got kicked, try to rejoin
  if hexchat.nickcmp(kickee, hexchat.get_info("nick")) == 0:
    hexchat.command("join %s" % kickChan)
    message = random.choice(text.revenge) % kicker
    hexchat.command("ctcp %s action %s" % (kickChan, message))
    
  #if chanserv did the kicking
  elif hexchat.nickcmp(kicker, "ChanServ") == 0:
      rejoinList.append(kickee)
      if rejoinList.count(kickee) >= 3:
        # ban someone if chanserv has kicked them 3+ times
        hexchat.command("mode %s +b %s" % (kickChan, kickee))
예제 #8
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
예제 #9
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
예제 #10
0
 def filt(p):
     if hexchat.nickcmp(p.nick, whois.nick) == 0 and netId(p.ctx) == id:
         log(0, "[" + str(id) + "] Received WHOIS for " + p.nick)
         p.fulfill(whois)
         return False
     else:
         return True
예제 #11
0
파일: HexStats.py 프로젝트: Vlek/plugins
def check_opped(ctx, nickprefixes):
    op_idx = nickprefixes.index('@')
    nick = ctx.get_info('nick')
    me = [user for user in ctx.get_list('users') if hexchat.nickcmp(user.nick, nick) == 0][0]
    if me.prefix and nickprefixes.index(me.prefix[0]) <= op_idx:
        return True
    return False
예제 #12
0
 def filt(p):
     if hexchat.nickcmp(p.channel, channel) == 0 and netId(
             p.ctx) == id:
         p.fulfill(True)
         return False
     else:
         return True
예제 #13
0
 def filt(p):
     if hexchat.nickcmp(p.nick, whois.nick) == 0 and netId(p.ctx) == id:
         log(0, "[" + str(id) + "] Received WHOIS for " + p.nick)
         p.fulfill(whois)
         return False
     else:
         return True
예제 #14
0
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
예제 #15
0
파일: nohide.py 프로젝트: nitori/tools
 def in_channel_list(chan):
     if channel_list is None:
         return True
     else:
         for c in channel_list:
             if hexchat.nickcmp(c, chan) == 0:
                 return True
         return False
예제 #16
0
파일: nohide.py 프로젝트: nitori/tools
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
예제 #17
0
 def ignoreIfQueued(w, we, u):
     id = netId()
     if id in WhoisPromise.lastWhois:
         whois = WhoisPromise.lastWhois[id]
         for p in WhoisPromise.promises:
             if hexchat.nickcmp(p.nick, whois.nick) == 0 and netId(p.ctx) == id:
                 log(0, "[" + str(id) + "] " + " ".join(w))
                 return hexchat.EAT_ALL
     return hexchat.EAT_NONE
예제 #18
0
파일: greyignore.py 프로젝트: Vlek/plugins
def check_ignore(word, word_to_eol, userdata):
    ignoretarget = word[0]
    for user in _ignorelist:
        if hexchat.nickcmp(user, ignoretarget) == 0:
            context = hexchat.get_context()
            if len(word) == 2:
                word.append("")
            context.prnt("\x0314{}{} {}".format(word[2], ignoretarget, word[1]))
            return hexchat.EAT_ALL
예제 #19
0
 def ignoreIfQueued(w, we, u):
     id = netId()
     if id in WhoisPromise.lastWhois:
         whois = WhoisPromise.lastWhois[id]
         for p in WhoisPromise.promises:
             if hexchat.nickcmp(p.nick, whois.nick) == 0 and netId(p.ctx) == id:
                 log(0, "[" + str(id) + "] " + " ".join(w))
                 return hexchat.EAT_ALL
     return hexchat.EAT_NONE
예제 #20
0
def modes(w, we, udata):
    global modes
    if active:
        if "s" in w[4]:
            hexchat.prnt("\x0302Channel %s is +s, report may be incomplete" % (w[3]))
        if hexchat.nickcmp(w[3], channel) == 0:
            modes = w[4]
            if lists_left == 0 and whois:
                analyze()
        return hexchat.EAT_ALL
예제 #21
0
def modes(w, we, udata):
    global modes
    if active:
        if "s" in w[4]:
            hexchat.prnt("\x0302Channel %s is +s, report may be incomplete" % (w[3]))
        if hexchat.nickcmp(w[3], channel) == 0:
            modes = w[4]
            if lists_left == 0 and whois:
                analyze()
        return hexchat.EAT_ALL
예제 #22
0
파일: greyignore.py 프로젝트: Vlek/plugins
def ignore(word, word_to_eol, userdata):
    ignoretarget = word[1]
    for user in _ignorelist:
        if hexchat.nickcmp(user, ignoretarget) == 0:
            print("User {} already in ignore list".format(ignoretarget))
            return hexchat.EAT_ALL
    print("Ignoring {}".format(ignoretarget))
    _ignorelist.append(ignoretarget)
    hexchat.set_pluginpref("greyignore", ",".join(_ignorelist))
    return hexchat.EAT_ALL
예제 #23
0
def msg_event(w, we, event):
    global recursion
    if recursion:
        return hexchat.EAT_NONE
    source = w[0]
    target = hexchat.get_info("channel")
    if hexchat.nickcmp(source, lastSource) == 0:
        if hexchat.nickcmp(target, lastTarget[-len(target) :]) == 0:
            status = lastTarget[: -len(target)]
            if len(status):
                if not any(c.isalpha() or c.isdigit() for c in status):
                    if len(w) > 2:
                        w[2] = "[" + status + "]" + w[2]
                    else:
                        w.append("[" + status + "]")
                    recursion = True
                    hexchat.emit_print(event, *w)
                    recursion = False
                    return hexchat.EAT_ALL
    return hexchat.EAT_NONE
예제 #24
0
def list_entry(w, we, udata):
    global lists_left
    if active:
        if udata == "+q":
            del w[4]
        if w[4][:3] == "$j:":
            if hexchat.nickcmp(w[3], channel) == 0:
                query_list(w[4][3:].split("$", 1)[0], "b")
        else:
            bans.append((w[4], udata, w[3], w[5], w[6]))
        return hexchat.EAT_ALL
예제 #25
0
def statusReturn(nick, level, db):
  temp = []
  for action in adminActions:
    if hexchat.nickcmp(action[0], nick) == 0:
      if int(level) == 3:
        exec(action[1])
      temp.append(action)
      
  # remove all actions relating to the nick
  for item in temp:
    adminActions.remove(item)
예제 #26
0
def list_entry(w, we, udata):
    global lists_left
    if active:
        if udata == "+q":
            del w[4]
        if w[4][:3] == "$j:":
            if hexchat.nickcmp(w[3], channel) == 0:
                query_list(w[4][3:].split("$", 1)[0], "b")
        else:
            bans.append((w[4], udata, w[3], w[5], w[6]))
        return hexchat.EAT_ALL
예제 #27
0
def msg_event(w, we, event):
    global recursion
    if recursion:
        return hexchat.EAT_NONE
    source = hexchat.strip(w[0])
    target = hexchat.get_info("channel")
    if hexchat.nickcmp(source, lastSource) == 0:
        if hexchat.nickcmp(target, lastTarget[-len(target):]) == 0:
            status = lastTarget[:-len(target)]
            if len(status):
                if not any(c.isalpha() or c.isdigit() for c in status):
                    if len(w) > 2:
                        w[2] = "[" + status + "]" + w[2]
                    else:
                        w.append("[" + status + "]")
                    recursion = True
                    hexchat.emit_print(event, *w)
                    recursion = False
                    return hexchat.EAT_ALL
    return hexchat.EAT_NONE
예제 #28
0
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
예제 #29
0
 def joinHook(self, word, word_eol, userdata):
     nick = word[0][1:].split('!')[0]
     if hexchat.nickcmp(nick, hexchat.get_info("nick")) == 0:
         self.SendMessage(
             BOLD + COLORDEFAULT + 'Chargement du quizzbot ' +
             COLORSPECIAL + __module_name__ + COLORDEFAULT + ' version ' +
             COLORSPECIAL + __module_version__ + COLORDEFAULT +
             ' ! Envoyez ' + COLORSPECIAL + '!quizz' + COLORDEFAULT +
             ' pour lancer le jeu. ' + COLORSPECIAL + '!quizzhelp' +
             COLORDEFAULT + ' pour connaître les commandes. ' +
             COLORSPECIAL + HELP_URL + COLORDEFAULT +
             ' pour l\'aide en ligne.', word[2][1:])
     return hexchat.EAT_NONE
예제 #30
0
def no_list(w, we, udata):
    global lists_left, modes
    if active:
        if hexchat.nickcmp(w[3], channel) == 0 and not modes:
            hexchat.prnt("\x0304Could not obtain modes for %s, report may be incomplete" % (w[3]))
            modes = "+"
            if lists_left == 0 and whois:
                analyze()
        else:
            hexchat.prnt("\x0304Could not obtain list for %s, report may be incomplete" % (w[3]))
            lists_left -= 1
            if lists_left == 0 and whois and modes:
                analyze()
            return hexchat.EAT_ALL
예제 #31
0
def no_list(w, we, udata):
    global lists_left, modes
    if active:
        if hexchat.nickcmp(w[3], channel) == 0 and not modes:
            hexchat.prnt("\x0304Could not obtain modes for %s, report may be incomplete" % (w[3]))
            modes = "+"
            if lists_left == 0 and whois:
                analyze()
        else:
            hexchat.prnt("\x0304Could not obtain list for %s, report may be incomplete" % (w[3]))
            lists_left -= 1
            if lists_left == 0 and whois and modes:
                analyze()
            return hexchat.EAT_ALL
예제 #32
0
def nwo_unquiet(word, word_eol, userdata):
    users = hexchat.get_list('users')
    chan = hexchat.get_info('channel')
    nick = hexchat.get_info('nick')
    if len(word) >= 2:
        for user in users:
            if hexchat.nickcmp(user.nick, word[1]) == 0:
                host = user.host.split('@')[1]
                hexchat.command('RAW PRIVMSG ChanServ :op %s' % chan)
                hexchat.command('timer 1 RAW MODE %s -q *!*@%s *!*@%s' %
                                (chan, host, host))
                hexchat.command('timer 2 RAW MODE %s -o %s' % (chan, nick))
                break
    return hexchat.EAT_ALL
예제 #33
0
파일: mymsg.py 프로젝트: BFCatalin/plugins
def privmsg_cb(word, word_eol, userdata, attrs):
	# We only care about private messages, HexChat handles the rest now.
	if word[2][0] == '#':
		return

	mynick = hexchat.get_info('nick')
	sender = word[0].split('!')[0][1:]
	recipient = word[2]
	network = hexchat.get_info('network')
	msg = word_eol[3][1:]

	if hexchat.nickcmp(sender, mynick) == 0 and hexchat.nickcmp(recipient, mynick) != 0:
		hexchat.command('query -nofocus {}'.format(recipient))
		ctx = hexchat.find_context(network, recipient)

		if '\001ACTION' in msg:
			for repl in ('\001ACTION', '\001'):
				msg = msg.replace(repl, '')
			ctx.emit_print('Your Action', mynick, msg.strip(), time=attrs.time)
		else:
			ctx.emit_print('Your Message', mynick, msg, time=attrs.time)

		return hexchat.EAT_ALL
예제 #34
0
파일: mymsg.py 프로젝트: scottwashi/plugins
def privmsg_cb(word, word_eol, userdata, attrs):
    # We only care about private messages, HexChat handles the rest now.
    if word[2][0] == '#':
        return

    mynick = hexchat.get_info('nick')
    sender = word[0].split('!')[0][1:]
    recipient = word[2]
    network = hexchat.get_info('network')
    msg = word_eol[3][1:]

    if hexchat.nickcmp(
            sender, mynick) == 0 and hexchat.nickcmp(recipient, mynick) != 0:
        hexchat.command('query -nofocus {}'.format(recipient))
        ctx = hexchat.find_context(network, recipient)

        if '\001ACTION' in msg:
            for repl in ('\001ACTION', '\001'):
                msg = msg.replace(repl, '')
            ctx.emit_print('Your Action', mynick, msg.strip(), time=attrs.time)
        else:
            ctx.emit_print('Your Message', mynick, msg, time=attrs.time)

        return hexchat.EAT_ALL
예제 #35
0
def get_mask(nick):
    invalid_chars = ("*", "?", "!", "@", "$")
    if any(char in nick for char in invalid_chars):
        return nick  # It's already a mask.

    for user in hexchat.get_list("users"):
        if hexchat.nickcmp(user.nick, nick) == 0:
            if user.account:
                return "$a:{}".format(user.account)
            elif user.host:
                host = user.host.split("@")[1]
                return "*!*@{}".format(host)
            else:
                hexchat.command("whois {}".format(nick))
                print("BH: User info not found, enable irc_who_join or try again.")
                return None
예제 #36
0
 def handlerMODE(w, we, u):
     source = w[0][1:].split("!", 1)[0]
     if source == "ChanServ":
         mode = w[3]
         if mode == "+o":
             nick = w[4]
             if hexchat.nickcmp(nick, hexchat.get_info("nick")) == 0:
                 channel = w[2]
                 id = netId()
                 def filt(p):
                     if hexchat.nickcmp(p.channel, channel) == 0 and netId(p.ctx) == id:
                         p.fulfill(True)
                         return False
                     else:
                         return True
                 ChanServPromise.promises = list(filter(filt, ChanServPromise.promises))
예제 #37
0
 def handlerMODE(w, we, u):
     source = w[0][1:].split("!", 1)[0]
     if source == "ChanServ":
         mode = w[3]
         if mode == "+o":
             nick = w[4]
             if hexchat.nickcmp(nick, hexchat.get_info("nick")) == 0:
                 channel = w[2]
                 id = netId()
                 def filt(p):
                     if hexchat.nickcmp(p.channel, channel) == 0 and netId(p.ctx) == id:
                         p.fulfill(True)
                         return False
                     else:
                         return True
                 ChanServPromise.promises = list(filter(filt, ChanServPromise.promises))
예제 #38
0
def get_mask(nick):
	invalid_chars = ('*', '?', '!', '@', '$')
	if any(char in nick for char in invalid_chars):
		return nick # It's already a mask.

	for user in hexchat.get_list('users'):
		if hexchat.nickcmp(user.nick, nick) == 0:
			if user.account:
				return '$a:{}'.format(user.account)
			elif user.host:
				host = user.host.split('@')[1]
				return '*!*@{}'.format(host)
			else:
				hexchat.command('whois {}'.format(nick))
				print('BH: User info not found, enable irc_who_join or try again.')
				return None
예제 #39
0
def freedom_alert_cb(word, word_eol, userdata):
    global fda_status
    if fda_status == False:
        return hexchat.EAT_NONE

    #optimize, if there is no f nor F no need to compute lower case
    if 0 == word_eol[1].find('f') and 0 == word_eol[1].find('F'):
        return hexchat.EAT_NONE

    internal = word_eol[1].lower()
    if "freedom" in internal:
        nickname = hexchat.get_info("nick")
        channel = hexchat.get_info("channel")
        if hexchat.nickcmp(nickname, word[0]) != 0:
            hexchat.hook_timer(1, fda_print, channel)

    return hexchat.EAT_NONE
예제 #40
0
def get_mask(nick):
    invalid_chars = ('*', '?', '!', '@', '$')
    if any(char in nick for char in invalid_chars):
        return nick  # It's already a mask.

    for user in hexchat.get_list('users'):
        if hexchat.nickcmp(user.nick, nick) == 0:
            if user.account:
                return '$a:{}'.format(user.account)
            elif user.host:
                host = user.host.split('@')[1]
                return '*!*@{}'.format(host)
            else:
                hexchat.command('whois {}'.format(nick))
                print(
                    'BH: User info not found, enable irc_who_join or try again.'
                )
                return None
예제 #41
0
def xchat_chanmsg_cb(word, word_eol, userdata):
    nick = FMT_REGEX.sub('', word[0])
    if nick.lower() not in set(OPTIONS['relay_bots']):
        return xchat.EAT_NONE
    mtype, mask, text = parse_relay_msg('{}!.@.'.format(nick), word[1])
    if mtype == -1:
        return xchat.EAT_NONE
    elif mtype == 2:
        for string in text:
            xchat.emit_print('Channel Action', '***', string)
        return xchat.EAT_ALL
    nick = mask.split('!', 1)[0]
    if userdata and xchat.nickcmp(word[0], xchat.get_info('nick')) != 0:
        event = 'Action Hilight' if mtype == 1 else 'Msg Hilight'
    else:
        event = 'Action' if mtype == 1 else 'Message'
    event = ' '.join(('Channel', event))
    xchat.emit_print(event, nick, text, '*')
    return xchat.EAT_ALL
예제 #42
0
파일: nohide.py 프로젝트: nitori/tools
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
예제 #43
0
def on_common(word, word_eol, userdata):
	if len(word) < 2:
		print ("Second arg must be a nick")
	else :
		target = word[1]
		common_channels = list();
		#Get list of channels we are in
		for chan in hexchat.get_list('channels'):
		
			#Check each user in that channel and see if it matches the target
			for user in chan.context.get_list('users'):
				if(hexchat.nickcmp(user.nick, target) == 0):
				
					#If nicks match, ad the channel to the list
					common_channels.append(chan.channel)
			
		#Print out the list of common channels
		hexchat.prnt("Channels in common with " + target + ":")
		for chan in common_channels:
			hexchat.prnt(chan + " ")
			
	return hexchat.EAT_ALL
예제 #44
0
	def joinHook(self, word, word_eol, userdata):
		nick = word[0][1:].split('!')[0]
		if hexchat.nickcmp(nick, hexchat.get_info("nick")) == 0:
			self.SendMessage(BOLD + COLORDEFAULT + 'Chargement du quizzbot ' + COLORSPECIAL + __module_name__ + COLORDEFAULT + ' version ' + COLORSPECIAL + __module_version__ + COLORDEFAULT + ' ! Envoyez ' + COLORSPECIAL + '!quizz' + COLORDEFAULT + ' pour lancer le jeu. ' + COLORSPECIAL + '!quizzhelp' + COLORDEFAULT + ' pour connaître les commandes. ' + COLORSPECIAL + HELP_URL + COLORDEFAULT + ' pour l\'aide en ligne.', word[2][1:])
		return hexchat.EAT_NONE
예제 #45
0
def check_you(nick):
    return not hexchat.nickcmp(hexchat.get_info('nick'), nick)
예제 #46
0
def analyze():
    global active
    active = False
    nick, ident, host, gecos, account, ssl = whois
    found_modes = []
    hostile_modes = []
    for c in modes:
        if orig_list == "b":
            if c == "i" or c == "k" or (c == "r" and not account) or (c == "S" and not ssl):
                hostile_modes.append(c)
        elif orig_list == "q":
            if c == "m" or (c == "r" and not account):
                hostile_modes.append(c)
    if len(hostile_modes):
        found_modes.append("\x0302+%s\x0F in \x0306%s\x0F" % ("".join(hostile_modes), channel))
    def add_ban(b):
        found_modes.append("\x0302%s %s\x0F in \x0306%s\x0F set by \x0310%s\x0F on \x0308%s\x0F" % (b[1], b[0], b[2], b[3], time.ctime(int(b[4]))))
    for b in bans:
        ban = b[0][0] + b[0][1:].split("$", 1)[0]
        if ban[0] == "$":
            if ban == "$a":
                if account:
                    add_ban(b)
            elif ban == "$~a":
                if not account:
                    add_ban(b)
            elif ban[:3] == "$a:":
                if account and hexchat.nickcmp(account, ban[3:]) == 0:
                    add_ban(b)
            elif ban[:4] == "$~a:":
                if not account or hexchat.nickcmp(account, ban[4:]) != 0:
                    add_ban(b)
            elif ban[:4] == "$~j:":
                add_ban(b)
            elif ban[:3] == "$r:":
                if match_pattern(gecos, ban[3:]):
                    add_ban(b)
            elif ban[:4] == "$~r:":
                if not match_pattern(gecos, ban[4:]):
                    add_ban(b)
            elif ban[:3] == "$x:":
                for h in host:
                    if match_pattern("%s!%s@%s#%s" % (nick, ident, h, gecos), ban[3:]):
                        add_ban(b)
                        break;
            elif ban[:4] == "$~x:":
                found = False
                for h in host:
                    if match_pattern("%s!%s@%s#%s" % (nick, ident, h, gecos), ban[4:]):
                        found = True
                        break
                if not found:
                    add_ban(b)
            elif ban == "$z":
                if ssl:
                    add_ban(b)
            elif ban == "$~z":
                if not ssl:
                    add_ban(b)
            else:
                hexchat.prnt("\x0304Unknown extban: " + b[0])
        else:
            v = ban.split("@", 1)
            bhost = v[1] if len(v) == 2 else ""
            v = v[0].split("!", 1)
            bident = v[1] if len(v) == 2 else ""
            bnick = v[0]
            if match_pattern(nick, bnick) and match_pattern(ident, bident):
                found = False
                for h in host:
                    if match_pattern(h, bhost):
                        found = True
                        add_ban(b)
                        break
                if not found:
                    try:
                        ip, width = bhost.rsplit("/", 1)
                        width = int("0" + re.match("[0-9]*", width).group(0))
                        if width > 0:
                            is_v4 = ip.find(":") == -1
                            width = max((32 if is_v4 else 128) - width, 0)
                            ip = parse_ip(ip)
                            for h in host:
                                if (h.find(":") == -1) == is_v4:
                                    try:
                                        h = parse_ip(h, strict = True)
                                    except ValueError:
                                        continue
                                    if ip >> width == h >> width:
                                        add_ban(b)
                                        break
                    except ValueError:
                        pass
    if len(found_modes):
        if orig_list == "b":
            hexchat.prnt("The following are preventing \x0310%s\x0F from joining \x0306%s\x0F:" % (user, channel))
        elif orig_list == "q":
            hexchat.prnt("The following are preventing \x0310%s\x0F from speaking in \x0306%s\x0F:" % (user, channel))
        else:
            hexchat.prnt("The following \x0302+%s\x0F modes affect \x0310%s\x0F in \x0306%s\x0F:" % (orig_list, user, channel))
        for m in found_modes:
            hexchat.prnt(m)
    else:
        if orig_list == "b":
            hexchat.prnt("Nothing is preventing \x0310%s\x0F from joining \x0306%s\x0F" % (user, channel))
        elif orig_list == "q":
            hexchat.prnt("Nothing is preventing \x0310%s\x0F from speaking in \x0306%s\x0F" % (user, channel))
        else:
            hexchat.prnt("No \x0302+%s\x0F modes affect \x0310%s\x0F in \x0306%s\x0F" % (orig_list, user, channel))
예제 #47
0
def modifyRawData(word,word_eol,userdata):
	try:
		nick = hexchat.strip(word[0].split(':')[1].split('!')[0])
	except:
		nick = ''
	if nick in OMNOMIRCNICK:
		try:
			msg = ' '.join(word[3:])[1:]
			chan = word[2]
		except:
			return hexchat.EAT_NONE
		if hexchat.nickcmp(chan,hexchat.get_info('nick'))==0:
			cmd = msg.split(' ')
			try:
				if cmd[0] == 'OIRCUSERS':
					chan = cmd[1]
					for nick in json.loads(' '.join(cmd[2:])):
						if hexchat.nickcmp(nick,hexchat.get_info('nick'))!=0:
							hexchat.command('RECV :'+hexchat.strip(nick).replace(' ','\xA0')+'!()\xA0'+nick.replace(' ','\xA0')+'@'+OMNOMJOINIGNORE+' JOIN :'+chan)
			except Exception as inst:
				print(__module_name__,': something unexpected happend, please report the following')
				print('Oirc PM exeption')
				print(inst)
			return hexchat.EAT_ALL
		res = re.match(r'^((\x03[0-9]{1,2}|\x02)?\([a-zA-Z0-9#!]+\)[\x0F\x02]?)',msg)
		if res:
			nick_prefix = res.group(1)
			nick = ''
			msg = msg[len(res.group(1)):]
			cmd = ''
			textEvent = ''
			args = []
			
			while True:
				res = re.match(r'<([^>]+)> (.*)',msg)
				if res: # normal msg
					if doHighlight(res.group(2)):
						textEvent = 'Channel Msg Hilight'
					else:
						textEvent = 'Channel Message'
					args = [res.group(2)]
					cmd = 'PRIVMSG '+chan+' :'+res.group(2)
					nick = res.group(1)
					break
				res = re.match(r'^\x036\* ([^ ]+) (.*)',msg)
				if res: # action
					if doHighlight(res.group(2)):
						textEvent = 'Channel Action Hilight'
					else:
						textEvent = 'Channel Action'
					args = [res.group(2)]
					cmd = 'PRIVMSG '+chan+' :\x01ACTION '+res.group(2)+'\x01'
					nick = res.group(1)
					break
				res = re.match(r'^\x032\* ([^ ]+) has left ([^ ]*) \((.*)\)',msg)
				if res: # part
					if res.group(3)!='':
						textEvent = 'Part with Reason'
					else:
						textEvent = 'Part'
					args = [res.group(1)+'@OmnomIRC',res.group(2),res.group(3)]
					cmd = 'PART '+chan+' :'+res.group(3)
					nick = res.group(1)
					break
				res = re.match(r'^\x033\* ([^ ]+) has joined ([^ ]*)',msg)
				if res: # join
					textEvent = 'Join'
					args = [res.group(2),res.group(1)+'@'+OMNOMIDENTSTR,'']
					cmd = 'JOIN :'+chan
					nick = res.group(1)
					break
				res = re.match(r'^\x032\* ([^ ]+) has quit [^ ]* \((.*)\)',msg)
				if res: # quit
					textEvent = 'Quit'
					args = [res.group(2)]
					cmd = 'QUIT :'+res.group(2)
					nick = res.group(1)
					break
				res = re.match(r'^\x033\* ([^ ]+) set ([^ ]*) mode (.*)',msg)
				if res: # mode
					textEvent = 'Channel Mode Generic'
					args = ['',res.group(3),res.group(2)]
					cmd = 'MODE '+chan+' '+res.group(3)
					nick = res.group(1)
					break
				res = re.match(r'^\x034\* ([^ ]+) has kicked ([^ ]*) from ([^ ]*) \((.*)\)',msg)
				if res: # kick
					textEvent = 'Kick'
					args = [res.group(2)+'@'+OMNOMIDENTSTR,res.group(3),res.group(4)]
					cmd = 'KICK '+chan+' '+hexchat.strip(res.group(2))+'\xA0 :'+res.group(4)
					nick = res.group(1)
					break
				res = re.match(r'^\x033\* ([^ ]+) has changed the topic to (.*)',msg)
				if res: # topic
					textEvent = 'Topic Change'
					args = [res.group(2)]
					cmd = 'TOPIC '+chan+' :'+res.group(2)
					nick = res.group(1)
					break
				res = re.match(r'^\x033\* (.+) has changed nicks to (.*)',msg)
				if res: # nick
					textEvent = 'Change Nick'
					args = [getNick(nick_prefix,res.group(2))]
					cmd = res.group(2)
					nick = res.group(1)
					break
				
				break
			
			
			if textEvent!='':
				if(len(word)>2):
					args.append(word[2])
				else:
					args.append('')
				nick_notext = nick = hexchat.strip(nick.replace(' ','\xA0'))
				if not (textEvent in ['Part','Part with Reason','Quit','Join']):
					if '!' in nick_prefix:
						nick = '\x02'+nick+'\x02'
					else:
						nick = getNick(nick_prefix,nick)
				if hexchat.nickcmp(nick_notext,hexchat.get_info('nick'))==0 and textEvent in ['Part','Part with Reason','Quit','Join','Kick']:
					hexchat.emit_print(textEvent,getNick(nick_prefix,nick_notext),*args)
					if textEvent=='Kick':
						kicknick = hexchat.strip(args[0][:-len('@'+OMNOMIDENTSTR)].replace(' ','\xA0'))
						if hexchat.nickcmp(kicknick,hexchat.get_info('nick'))!=0:
							hexchat.command('RECV :'+kicknick+'!'+getNick(nick_prefix,kicknick)+'@'+OMNOMJOINIGNORE+' PART '+chan)
					return hexchat.EAT_ALL
				if textEvent=='Change Nick':
					hexchat.emit_print(textEvent,getNick(nick_prefix,nick_notext),*args)
					hexchat.command('RECV :'+nick_notext+'!'+getNick(nick_prefix,nick_notext)+'@'+OMNOMJOINIGNORE+' PART '+chan)
					cmd = cmd.replace(' ','\xA0')
					hexchat.command('RECV :'+hexchat.strip(cmd)+'!'+getNick(nick_prefix,cmd)+'@'+OMNOMJOINIGNORE+' JOIN :'+chan)
				elif textEvent=='Quit':
					hexchat.emit_print(textEvent,getNick(nick_prefix,nick_notext),*args)
					hexchat.command('RECV :'+nick_notext+'!'+getNick(nick_prefix,nick_notext)+'@'+OMNOMJOINIGNORE+' PART '+chan)
				else:
					hexchat.command('RECV :'+nick+'!'+getNick(nick_prefix,nick_notext)+'@'+OMNOMIDENTSTR+' '+cmd)
				return hexchat.EAT_ALL
		
		
		print(__module_name__,': something unexpected happend, please report the following')
		print(word)
		return hexchat.EAT_NONE
	elif hexchat.strip(word[0]) in TOPICBOTNICK:
		return hexchat.EAT_ALL
	return hexchat.EAT_NONE
예제 #48
0
def check_you(nick):
    return not hexchat.nickcmp(hexchat.get_info("nick"), nick)
예제 #49
0
def analyze():
    global active
    active = False
    nick, ident, host, gecos, account, ssl = whois
    found_modes = []
    hostile_modes = []
    for c in modes:
        if orig_list == "b":
            if c == "i" or c == "k" or (c == "r" and not account) or (c == "S" and not ssl):
                hostile_modes.append(c)
        elif orig_list == "q":
            if c == "m" or (c == "r" and not account):
                hostile_modes.append(c)
    if len(hostile_modes):
        found_modes.append("\x0302+%s\x0F in \x0306%s\x0F" % ("".join(hostile_modes), channel))
    def add_ban(b):
        found_modes.append("\x0302%s %s\x0F in \x0306%s\x0F set by \x0310%s\x0F on \x0308%s\x0F" % (b[1], b[0], b[2], b[3], time.ctime(int(b[4]))))
    for b in bans:
        ban = b[0][0] + b[0][1:].split("$", 1)[0]
        if ban[0] == "$":
            if ban == "$a":
                if account:
                    add_ban(b)
            elif ban == "$~a":
                if not account:
                    add_ban(b)
            elif ban[:3] == "$a:":
                if account and hexchat.nickcmp(account, ban[3:]) == 0:
                    add_ban(b)
            elif ban[:4] == "$~a:":
                if not account or hexchat.nickcmp(account, ban[4:]) != 0:
                    add_ban(b)
            elif ban[:4] == "$~j:":
                add_ban(b)
            elif ban[:3] == "$r:":
                if match_pattern(gecos, ban[3:]):
                    add_ban(b)
            elif ban[:4] == "$~r:":
                if not match_pattern(gecos, ban[4:]):
                    add_ban(b)
            elif ban[:3] == "$x:":
                for h in host:
                    if match_pattern("%s!%s@%s#%s" % (nick, ident, h, gecos), ban[3:]):
                        add_ban(b)
                        break;
            elif ban[:4] == "$~x:":
                found = False
                for h in host:
                    if match_pattern("%s!%s@%s#%s" % (nick, ident, h, gecos), ban[4:]):
                        found = True
                        break
                if not found:
                    add_ban(b)
            elif ban == "$z":
                if ssl:
                    add_ban(b)
            elif ban == "$~z":
                if not ssl:
                    add_ban(b)
            else:
                hexchat.prnt("\x0304Unknown extban: " + b[0])
        else:
            v = ban.split("@", 1)
            bhost = v[1] if len(v) == 2 else ""
            v = v[0].split("!", 1)
            bident = v[1] if len(v) == 2 else ""
            bnick = v[0]
            if match_pattern(nick, bnick) and match_pattern(ident, bident):
                found = False
                for h in host:
                    if match_pattern(h, bhost):
                        found = True
                        add_ban(b)
                        break
                if not found:
                    try:
                        ip, width = bhost.rsplit("/", 1)
                        width = int(re.match("-[0-9]*", width).group(0) or "0")
                        if width > 0:
                            is_v4 = ip.find(":") == -1
                            width = max((32 if is_v4 else 128) - width, 0)
                            ip = parse_ip(ip)
                            for h in host:
                                if (h.find(":") == -1) == is_v4:
                                    try:
                                        h = parse_ip(h, strict = True)
                                    except ValueError:
                                        continue
                                    if ip >> width == h >> width:
                                        add_ban(b)
                                        break
                    except ValueError:
                        pass
    if len(found_modes):
        if orig_list == "b":
            hexchat.prnt("The following are preventing \x0310%s\x0F from joining \x0306%s\x0F:" % (user, channel))
        elif orig_list == "q":
            hexchat.prnt("The following are preventing \x0310%s\x0F from speaking in \x0306%s\x0F:" % (user, channel))
        else:
            hexchat.prnt("The following \x0302+%s\x0F modes affect \x0310%s\x0F in \x0306%s\x0F:" % (orig_list, user, channel))
        for m in found_modes:
            hexchat.prnt(m)
    else:
        if orig_list == "b":
            hexchat.prnt("Nothing is preventing \x0310%s\x0F from joining \x0306%s\x0F" % (user, channel))
        elif orig_list == "q":
            hexchat.prnt("Nothing is preventing \x0310%s\x0F from speaking in \x0306%s\x0F" % (user, channel))
        else:
            hexchat.prnt("No \x0302+%s\x0F modes affect \x0310%s\x0F in \x0306%s\x0F" % (orig_list, user, channel))