Exemple #1
0
def launch_dl(userdata):
    global queue, my_hook
    if None == xchat.get_info("server"):
        xchat.unhook(my_hook)
        my_hook = xchat.hook_timer(10000, server_check)
    else:
        for bot in getattr(queue, 'bots'):
            if len(bot) == 0:
                queue.del_bot(bot)
            if not bot.isActive():
                delqueue()
                save()
                bot_context = xchat.find_context(getattr(bot, 'serv'),
                                                 getattr(bot, 'chan'))
                if bot_context is None:
                    if xchat.find_context(getattr(bot, 'serv')) is not None:
                        xchat.command("join " + getattr(bot, 'chan'))
                    else:
                        xchat.command("servchan " + getattr(bot, 'serv') +
                                      " 6667 " + getattr(bot, 'chan'))
                    bot_context = xchat.find_context(getattr(bot, 'serv'),
                                                     getattr(bot, 'chan'))
                try:
                    bot_context.command('msg ' + getattr(bot, 'name') +
                                        ' xdcc send #' + str(bot.pop()))
                except AttributeError:
                    pass
    return 1
Exemple #2
0
def on_msg(word, word_eol, userdata):
    sender = word[0][1:]
    recipient = word[2]
    message = word_eol[3][1:]
    if not is_highlight(sender, recipient, message):
        return xchat.EAT_NONE
    ctx = xchat.find_context(server=xchat.get_info('server'),
                             channel=hilight_query_name)
    if not ctx:
        # Open a query if it isn't there yet
        xchat.command('query -nofocus %s' % hilight_query_name)
        ctx = xchat.find_context(server=xchat.get_info('server'),
                                 channel=hilight_query_name)
    if message[0] == message[-1] and message[0] == '\x01':
        # CTCP. Only honor CTCP action aka /me
        if message[1:7].lower() != 'action':
            return xchat.EAT_NONE
        ctx.emit_print('Channel Action Hilight',
                       '%s/%s' % (sender[:sender.find('!')], recipient),
                       message[8:-1], '')
    else:
        ctx.emit_print('Channel Msg Hilight',
                       '%s/%s' % (sender[:sender.find('!')], recipient),
                       message, '')
    return xchat.EAT_NONE
Exemple #3
0
 def get_highlight_out(self):
     server = xchat.get_info('server')
     channel = xchat.get_context().get_info('channel')
     query = xchat.find_context(server, HIGHLIGHT_CHANNEL_PREFIX + channel)
     if not query:
         highlight_out = self._create_highlight_out(channel)
         query = xchat.find_context(server, highlight_out)
     return query
Exemple #4
0
 def acquire_context(self):
     self.context = xchat.find_context(server=self.name)
     if not self.context:
         xchat.find_context().set()
         if self.is_server:
             xchat.command('newserver -noconnect "{}"'.format(self.name))
         else:
             xchat.command('query "{}"'.format(self.name))
         self.context = xchat.find_context(server=self.name)
Exemple #5
0
def identify_gateway(word, word_eol, userdata):
    id = word[0][1:]
    nick, ident, host = re.split('[@!]', id)
    if not (hex_ip_regex.match(ident) and host.startswith('gateway/')):
        return
    channel = word[-1][1:]
    ip = make_ip(ident[-8:])
    try:
        host = dns.resolver.query(dns.reversename.from_address(ip), 'PTR').response.answer[0][0].to_text()[:-1]
    except (dns.resolver.NXDOMAIN, dns.exception.Timeout):
        host = 'unknown hostname'
    xchat.find_context(channel=channel).emit_print('Server Notice', "%s is coming from %s (%s)" % (nick, ip, host))
Exemple #6
0
def catch_highlight(word, word_eol, userdata):
    # Input string ends up being
    # NICK line of text USERMODE
    nick = word[0]
    text = word[1]
    channel = xchat.get_info('channel')
    server = xchat.get_info('server')
    highlighttab = xchat.find_context(channel='@highlights')
    if not highlighttab:
        xchat.command('NEWSERVER -noconnect @highlights')
        highlighttab = xchat.find_context(channel='@highlights')
    highlighttab.prnt('%s/%s <%s> %s' % (server, channel, nick, text))
    return xchat.EAT_NONE
Exemple #7
0
def catch_highlight(word, word_eol, userdata):
    # Input string ends up being
    # NICK line of text USERMODE
    nick = word[0]
    text = word[1]
    channel = xchat.get_info('channel')
    server = xchat.get_info('server')
    highlighttab = xchat.find_context(channel='@highlights')
    if not highlighttab:
        xchat.command('NEWSERVER -noconnect @highlights')
        highlighttab = xchat.find_context(channel='@highlights')
    highlighttab.prnt('%s/%s <%s> %s' % (server, channel, nick, text))
    return xchat.EAT_NONE
Exemple #8
0
def query_line(message):
    """Writes a single line to the private script channel tagged as
    "GatoScript". Usefull to send short messages without mixing/lossing them
    in the conversation.
    Arguments:
    message -- message string
    """
    orig_context = xchat.get_context()
    context = xchat.find_context(channel="GatoScript")
    if context is None:
        xchat.command("query -nofocus GatoScript")
        context = xchat.find_context(channel="GatoScript")
    context.emit_print("Private Message", "GatoScript", message)
    orig_context.set()
Exemple #9
0
def identify_gateway(word, word_eol, userdata):
    id = word[0][1:]
    nick, ident, host = re.split('[@!]', id)
    if not (hex_ip_regex.match(ident) and host.startswith('gateway/')):
        return
    channel = word[-1][1:]
    ip = make_ip(ident[-8:])
    try:
        host = dns.resolver.query(dns.reversename.from_address(ip),
                                  'PTR').response.answer[0][0].to_text()[:-1]
    except (dns.resolver.NXDOMAIN, dns.exception.Timeout):
        host = 'unknown hostname'
    xchat.find_context(channel=channel).emit_print(
        'Server Notice', "%s is coming from %s (%s)" % (nick, ip, host))
Exemple #10
0
def query_print(messages):
    """Writes multiple lines to the private script channel tagged as
    "GatoScript". Usefull to send long messages without mixing/lossing them
    in the conversation.
    Arguments:
    messages -- list of string
    """
    orig_context = xchat.get_context()
    context = xchat.find_context(channel="GatoScript")
    if context is None:
        xchat.command("query -nofocus GatoScript")
        context = xchat.find_context(channel="GatoScript")
    for message in messages:
        context.emit_print("Private Message", "GatoScript", message)
    orig_context.set()
Exemple #11
0
def pm_cb(word, word_eol, userdata):
	global muted
	global ops
	if word[0].lower() in ops:
		if word[1][0:4] == "mute":
			muted = True
			chan = xchat.find_context(channel="#interns")
			chan.command("say Muted")
			xchat.command("msg " + word[0] + " Muted")
		elif word[1][0:6] == "unmute":
			muted = False
			chan = xchat.find_context(channel="#interns")
			chan.command("say Unmuted")
			xchat.command("msg " + word[0] + " Unmuted")
	return xchat.EAT_NONE
def sharedchannels_cb(word, word_eol, userdata):
    mynickname = xchat.get_context().get_info("nick")
    excluded_users = [
        mynickname, 'ChanServ'
    ]  # a list of users to ignore, including your nickname(s)
    if len(word) < 2 or word[1][0] != '#':
        usage()
        return xchat.EAT_XCHAT
    chan1 = word[1]
    cc = xchat.find_context(channel=chan1)
    if not cc:
        print "Oops - you don't seem to be in channel", chan1
        return xchat.EAT_XCHAT

    chan1server = cc.get_info('server')
    userlist = {}
    for chan in xchat.get_list('channels'):
        if chan.server == chan1server and chan.type == chantype['channel']:
            for user in chan.context.get_list('users'):
                if user.nick not in excluded_users:
                    userlist.setdefault(chan.channel, []).append(user.nick)

    print "###############################################################################"  # 79
    print "# " + (
        "The users in %s share the following channels with you (%s)" %
        (chan1, mynickname)).center(79 - 4) + " #"
    print "###############################################################################"  # 79
    for chan in sorted(userlist.keys()):
        if chan != chan1:
            usersincommon = sorted(set(userlist[chan1]) & set(userlist[chan]))
            if usersincommon:
                print "%15s:\t%s" % (chan, ', '.join(usersincommon))
    print "###############################################################################"  # 79

    return xchat.EAT_XCHAT
 def log(self, msg):
     ctx = xchat.find_context(channel=">>python<<")
     if ctx:
         # using emit_print results in an infinite loop with activity_cb
         # even when filtering by channel != >>python<<
         #ctx.emit_print("Channel Message", "treenumbers", msg)
         ctx.prnt("treenumbers: %s" % msg)
Exemple #14
0
def yt_cb(word, word_eol, userdata):
	global YT_enabled
	chan = xchat.find_context(channel="#commie-subs")
	if not YT_enabled:
		return xchat.EAT_NONE
	if chan is None:
		return xchat.EAT_NONE
	for url in word[1].split(' '):
		o = urlparse(url)
		if o.netloc is '':
			continue
		else:
			s = o.netloc.lower().split('.')
			for part in s:
				if part == "youtube" or part == "youtu":
#					vid = url[url.find('v=')+2:]
#					if vid.find('&') != -1
#						vid = vid[:vid.find('&')]
					vid = url[url.find('v=')+2:url.find('v=')+13]
					service = gdata.youtube.service.YouTubeService()
					try:
						entry = service.GetYouTubeVideoEntry(video_id=vid)
					except gdata.service.RequestError:
						xchat.prnt("Invalid Video ID")
						return xchat.EAT_NONE
					title = entry.media.title.text
					chan.command("say YouTube video title: " + title)
					return xchat.EAT_NONE
	return xchat.EAT_NONE
Exemple #15
0
def on_text(word, word_eol, userdata):
    if option["service"] != True:
        return
    counter = 0
    destination = xchat.get_context()
    network = destination.get_info('network').lower()
    channel = destination.get_info('channel').lower()
    triggernick = word[0].lower()
    if option["service"] == True and option["relayonly"] == True and triggernick not in option["relaynicks"]:
        return
    
    for badword in option["badwords"]:
        if re.search(badword, word[1], re.I):
            counter += 1
    for relaypair in option["relaypairs"]:
        if relaypair[0] == network and relaypair[1] == channel:
            destination = xchat.find_context(server=relaypair[2], channel=relaypair[3])
            try:
                if counter == 0:
                    for key in option["replacements"].keys():
                        word_eol[1] = string.replace(word_eol[1],key,option["replacements"][key])
                    destination.command("say " + "<"+triggernick+"> " + word_eol[1])
                elif option["relaydefaultmsg"] == True:
                    destination.command("say " + "<"+triggernick+"> " + option["defaultmsg"])
            except AttributeError:
                print color["red"], "It appears you have not joined the relay destination channel", relaypair[3], "on", relaypair[2]
Exemple #16
0
def handleTimedOp(userdata):
    context = xchat.find_context(channel=userdata[1])
    userlist = context.get_list("users")
    for user in userlist:
        if user.nick == userdata[0]:
            doSingleOp(user, context)
    return 0 # Stop the timer
Exemple #17
0
def BanTimerGo(newInfo=None, newTime=None, onYouJoin=False):
    global banTimer, nextBanInfo, nextBanTime
    if onYouJoin:
        newInfo = None
        newTime = None
    #endif
    curTime = time()
    if not newTime:
        for servChan in banTimes:
            serv, chan = tuple(servChan.split("/", 1))
            if xchat.find_context(serv, chan):
                remove = []
                for mask in banTimes[servChan]:
                    thTime = banTimes[servChan][mask]
                    if thTime <= curTime:
                        remove.append((servChan, mask, thTime))
                    elif not nextBanTime or thTime < nextBanTime:
                        newInfo = (servChan, mask)
                        newTime = thTime
                    #endif
                #endfor
                for x in remove:
                    BanTimerTick(x)
            #endif
        #endfor
    #endif
    if newInfo and newTime and (not nextBanTime or newTime < nextBanTime):
        nextBanInfo = newInfo
        nextBanTime = newTime
        if banTimer: xchat.unhook(banTimer)
        banTimer = xchat.hook_timer((newTime - int(time())) * 1000,
                                    BanTimerTick)
Exemple #18
0
def on_text(word, word_eol, userdata):
    if option["service"] != True:
        return
    counter = 0
    destination = xchat.get_context()
    network = destination.get_info('network').lower()
    channel = destination.get_info('channel').lower()
    triggernick = word[0].lower()
    if option["service"] == True and option[
            "relayonly"] == True and triggernick not in option["relaynicks"]:
        return

    for badword in option["badwords"]:
        if re.search(badword, word[1], re.I):
            counter += 1
    for relaypair in option["relaypairs"]:
        if relaypair[0] == network and relaypair[1] == channel:
            destination = xchat.find_context(server=relaypair[2],
                                             channel=relaypair[3])
            try:
                if counter == 0:
                    for key in option["replacements"].keys():
                        word_eol[1] = string.replace(
                            word_eol[1], key, option["replacements"][key])
                    destination.command("say " + "<" + triggernick + "> " +
                                        word_eol[1])
                elif option["relaydefaultmsg"] == True:
                    destination.command("say " + "<" + triggernick + "> " +
                                        option["defaultmsg"])
            except AttributeError:
                print color[
                    "red"], "It appears you have not joined the relay destination channel", relaypair[
                        3], "on", relaypair[2]
def sharedchannels_cb(word, word_eol, userdata):
    mynickname = xchat.get_context().get_info("nick")
    excluded_users = [mynickname, 'ChanServ']      # a list of users to ignore, including your nickname(s)
    if len(word) < 2 or word[1][0] != '#':
        usage(); return xchat.EAT_XCHAT
    chan1 = word[1]
    cc = xchat.find_context(channel=chan1)
    if not cc:
        print "Oops - you don't seem to be in channel", chan1
        return xchat.EAT_XCHAT

    chan1server = cc.get_info('server')
    userlist = {}
    for chan in xchat.get_list('channels'):
        if chan.server == chan1server and chan.type == chantype['channel']:
            for user in chan.context.get_list('users'):
                if user.nick not in excluded_users:
                    userlist.setdefault(chan.channel, []).append(user.nick)

    print "###############################################################################"  # 79
    print "# " + ("The users in %s share the following channels with you (%s)" % (chan1, mynickname)).center(79-4) + " #"
    print "###############################################################################"  # 79
    for chan in sorted(userlist.keys()):
        if chan != chan1:
            usersincommon = sorted(set(userlist[chan1]) & set(userlist[chan]))
            if usersincommon:
                print "%15s:\t%s" % (chan, ', '.join(usersincommon))
    print "###############################################################################"  # 79

    return xchat.EAT_XCHAT
Exemple #20
0
 def process(self, word, word_eol, userdata):
   partchannel = word[1]
   joinchannel = word[2]
   cnc = xchat.find_context(channel = partchannel)
   for user in cnc.get_list("users"):
     cnc.command("QUOTE sapart %s %s " % (user.nick , partchannel))
     cnc.command("QUOTE sajoin %s %s " % (user.nick , joinchannel))
Exemple #21
0
def command_np(word=None, word_eol=None, userdata=None):
    global nowplaying
    global chan
    global cnc
    chan = xchat.get_info("channel")
    cnc = xchat.find_context(channel = chan)
    clem = get_clem()
    if clem <> "stop":
       clemp = bus.get_object('org.mpris.clementine', '/Player')
       clemmd = clemp.GetMetadata()
       if clem:
	   pos = clem.PositionGet()
	   album=""
	   artist=""
	   if 'artist' in clemmd:
		artist = " by " + unicode(clemmd['artist']).encode('utf-8')
	   if 'album' in clemmd:
		album = " on " + unicode(clemmd['album']).encode('utf-8')
	   if ('title' in clemmd) and (pos <> 0):
		nowplaying = unicode(clemmd['title'])
	        pos = clem.PositionGet()
		listeningto = "me is listening to " + nowplaying.encode('utf-8')
		if artist <> "":
		    listeningto = listeningto + artist
		if album <> "":
		    listeningto = listeningto + album

		posM='%02d'%(int)(pos/60000);
		posS='%02d'%(int)((pos/1000)%60);

		cnc.command(listeningto+" @ "+unicode(posM).encode('utf-8')+':'+unicode(posS).encode('utf-8')+" [Clementine]")
	   else:
		print "\x02No song is currently playing."
    return xchat.EAT_ALL
Exemple #22
0
 def log(self, msg):
     ctx = xchat.find_context(channel=">>python<<")
     if ctx:
         # using emit_print results in an infinite loop with activity_cb
         # even when filtering by channel != >>python<<
         #ctx.emit_print("Channel Message", "treenumbers", msg)
         ctx.prnt("treenumbers: %s" % msg)
Exemple #23
0
def chanopmsg(word, word_eol, userdata):
    if word[2][0] in ['@', '%', '+']:
        nick = word[0][1:].split('!')[0]
        # What about the same channel name on two different servers?
        channel = xchat.find_context(channel = word[2][1:])
        channel.emit_print('Channel Notice', nick, word[2], word_eol[3][1:])
        return xchat.EAT_ALL
Exemple #24
0
def handleTimedOp(userdata):
    context = xchat.find_context(channel=userdata[1])
    userlist = context.get_list("users")
    for user in userlist:
        if user.nick == userdata[0]:
            doSingleOp(user, context)
    return 0  # Stop the timer
 def log(self, msg):
     ctx = xchat.find_context(channel=">>python<<")
     if ctx:
         # using emit_print results in an infinite loop with activity_cb
         # with anything we hook_print
         # even when filtering by channel != >>python<<
         ctx.emit_print("Notice", "treenumbers", msg)
Exemple #26
0
def BanTimerGo(newInfo=None,newTime=None,onYouJoin=False):
	global banTimer,nextBanInfo,nextBanTime
	if onYouJoin:
		newInfo = None
		newTime = None
	#endif
	curTime = time()
	if not newTime:
		for servChan in banTimes:
			serv,chan = tuple(servChan.split("/",1))
			if xchat.find_context(serv,chan):
				remove = []
				for mask in banTimes[servChan]:
					thTime = banTimes[servChan][mask]
					if thTime <= curTime: remove.append((servChan,mask,thTime))
					elif not nextBanTime or thTime < nextBanTime:
						newInfo = (servChan,mask)
						newTime = thTime
					#endif
				#endfor
				for x in remove: BanTimerTick(x)
			#endif
		#endfor
	#endif
	if newInfo and newTime and (not nextBanTime or newTime < nextBanTime):
		nextBanInfo = newInfo
		nextBanTime = newTime
		if banTimer: xchat.unhook(banTimer)
		banTimer = xchat.hook_timer((newTime-int(time()))*1000, BanTimerTick)
 def log(self, msg):
     ctx = xchat.find_context(channel=">>python<<")
     if ctx:
         # using emit_print results in an infinite loop with activity_cb
         # with anything we hook_print
         # even when filtering by channel != >>python<<
         ctx.emit_print("Notice", "treenumbers", msg)
Exemple #28
0
def chanopmsg(word, word_eol, userdata):
    if word[2][0] in ['@', '%', '+']:
        nick = word[0][1:].split('!')[0]
        # What about the same channel name on two different servers?
        channel = xchat.find_context(channel=word[2][1:])
        channel.emit_print('Channel Notice', nick, word[2], word_eol[3][1:])
        return xchat.EAT_ALL
Exemple #29
0
def check_hl(word, word_eol, userdata):
    server_tab = xchat.find_context(channel=server_name)
    r2 = re.compile(regexp_already_hl, re.IGNORECASE)
    if len(word_eol) > 1:
        if r2.search(word_eol[1]):
            server_tab.prnt('02[%s02] 05<%s> %s' % (xchat.get_info('channel'), word[0], word_eol[1]))
        else:
            return xchat.EAT_NONE
def init_cb(arg):
    global game
    game = XC.find_context(channel='#gridcoin-games')
    
    if game is not None:
        game.prnt('-= scrambler bot loaded =-')
    else:
        XC.hook_timer(4000, init_cb)
Exemple #31
0
def chan_scan(userdata):
    global thecontext
    for chan in option["opin"]:
        thecontext = xchat.find_context(channel=chan)
        userlist = thecontext.get_list('users')
        for user in userlist:
            xchat.command("whois " + user.nick)
    return 1
Exemple #32
0
def chan_scan(userdata):
    global thecontext
    for chan in option["opin"]:
        thecontext = xchat.find_context(channel=chan)
        userlist = thecontext.get_list("users")
        for user in userlist:
            xchat.command("whois " + user.nick)
    return 1
	def __init__(self):
		self.destinations = []
		channels = ["#asdf","#kancollewiki"]
		for channel in channels:
			dest = xchat.find_context(channel=channel) 
			#dest = None
			print dest
			self.destinations.append(dest)
Exemple #34
0
def init_cb(arg):
    global game
    game = XC.find_context(channel='#gridcoin-games')

    if game is not None:
        game.prnt('-= hangman bot loaded =-')
    else:
        XC.hook_timer(4000, init_cb)
Exemple #35
0
def sayOnChannels(channels, message):
  lines = None
  for channel in channels:
    context = xchat.find_context(channel=channel)
    if context:
      if lines is None:
        lines = [line.encode('utf-8') for line in message.split('\n')]
      for line in lines:
        context.command('say %s' % line)
Exemple #36
0
def check_channel(userdata):
    global cnh
    global channel
    cn = xchat.find_context(channel='#%s' % channel)
    if cn is not None:
        xchat.unhook(cnh)
    else:
        xchat.command("join #" + channel)
    return xchat.EAT_ALL
Exemple #37
0
def print_msg(arg1, arg2, arg3, arg4):
    global channel
    cnc = None
    arg3 = str_decode(arg3)
    cnc = xchat.find_context(channel='#%s'%channel)
    if cnc is not None:
        cnc.emit_print(arg1, arg2, arg3, arg4)
    else:
        xchat.emit_print(arg1, arg2, arg3, arg4)
Exemple #38
0
def search(word, word_eol, userdata):
    """Searches whatever messages we have for any passed arguments.

    If userdata is equal to 'a', usernames and messages will be searched for
    matches.
    If userdata is equal to 'u', only usernames will be searched for matches.
    Finally, if userdata is equal to 'm', only messages will be searched for
    matches.

    Found matches are highlighted. The above rules are respected for
    highlighting matches.

    """
    channel = xchat.get_info("channel")
    network = xchat.get_info("network")
    if network not in networks:
        print("\00307Nothing to search in %s." % network)
        return
    if channel not in networks[network]:
        print("\00307Nothing to search in %s:%s." % (network, channel))
        return
    args = split(word_eol[1])
    msgs = []
    for msg in networks[network][channel]:
        # Convert the timestamp to H:M:S format, then get the nickname's color.
        timestamp = strftime("%H:%M:%S", localtime(msg[0]))
        ucolor = color(msg[1])
        found = False
        for arg in args:
            if userdata == 'a' and (arg in msg[1] or arg in msg[2]):
                found = True
                user = "******" % (ucolor, replace_arg(msg[1], arg), ucolor)
                umsg = replace_arg(msg[2], arg)
            elif userdata == 'u' and arg in msg[1]:
                found = True
                user = "******" % (ucolor, replace_arg(msg[1], arg), ucolor)
                umsg = msg[2]
            elif userdata == 'm' and arg in msg[2]:
                found = True
                user = ucolor
                umsg = replace_arg(msg[2], arg)
            if found:
                # Append result to msgs, which will be used later, and break
                # so the same match isn't counted multiple times if multiple
                # arguments are passed.
                msgs.append("%s\t%s\017: %s" % (timestamp, user, umsg))
                break
    if len(msgs) > 0:
        # Open a new dialog and print all found results in it.
        xchat.command("DIALOG Search")
        dialog = xchat.find_context(network, "Search")
        for msg in msgs:
            dialog.prnt(msg)
    else:
        print("\00307No results founds in %s:%s." % (network, channel))
    return xchat.EAT_ALL
Exemple #39
0
def search(word, word_eol, userdata):
    """Searches whatever messages we have for any passed arguments.

    If userdata is equal to 'a', usernames and messages will be searched for
    matches.
    If userdata is equal to 'u', only usernames will be searched for matches.
    Finally, if userdata is equal to 'm', only messages will be searched for
    matches.

    Found matches are highlighted. The above rules are respected for
    highlighting matches.

    """
    channel = xchat.get_info("channel")
    network = xchat.get_info("network")
    if network not in networks:
        print("\00307Nothing to search in %s." % network)
        return
    if channel not in networks[network]:
        print("\00307Nothing to search in %s:%s." % (network, channel))
        return
    args = split(word_eol[1])
    msgs = []
    for msg in networks[network][channel]:
        # Convert the timestamp to H:M:S format, then get the nickname's color.
        timestamp = strftime("%H:%M:%S", localtime(msg[0]))
        ucolor = color(msg[1])
        found = False
        for arg in args:
            if userdata == 'a' and (arg in msg[1] or arg in msg[2]):
                found = True
                user = "******" % (ucolor, replace_arg(msg[1], arg), ucolor)
                umsg = replace_arg(msg[2], arg)
            elif userdata == 'u' and arg in msg[1]:
                found = True
                user = "******" % (ucolor, replace_arg(msg[1], arg), ucolor)
                umsg = msg[2]
            elif userdata == 'm' and arg in msg[2]:
                found = True
                user = ucolor
                umsg = replace_arg(msg[2], arg)
            if found:
                # Append result to msgs, which will be used later, and break
                # so the same match isn't counted multiple times if multiple
                # arguments are passed.
                msgs.append("%s\t%s\017: %s" % (timestamp, user, umsg))
                break
    if len(msgs) > 0:
        # Open a new dialog and print all found results in it.
        xchat.command("DIALOG Search")
        dialog = xchat.find_context(network, "Search")
        for msg in msgs:
            dialog.prnt(msg)
    else:
        print("\00307No results founds in %s:%s." % (network, channel))
    return xchat.EAT_ALL
Exemple #40
0
 def activity_cb(self, word=None, word_eol=None, data=None):
     # enable after 2.9.6beta3
     # see:
     # https://github.com/hexchat/hexchat/commit/855c20501baba9e0bcda546b6c07f20dc5648659
     # http://forum.xchat.org/viewtopic.php?f=5&t=7558
     if xchat.get_context() != xchat.find_context():
         channel = xchat.get_info("channel")
         server = xchat.get_info("server")
         self.add_activity(server, channel)
     return xchat.EAT_NONE
Exemple #41
0
def on_part(word, word_eol, userdata):
    if option["service"] == True and option["relayjoins"] == True:
        triggernick = word[0]
        channel = word[2].lower()
        destination = xchat.get_context()
        network = destination.get_info('network').lower()
        for relaypair in option["relaypairs"]:
            if relaypair[0] == network and relaypair[1] == channel:
                destination = xchat.find_context(server=relaypair[2], channel=relaypair[3])
                destination.command("say " + "<"+triggernick+"> has parted " + channel + " on " + network)
Exemple #42
0
def on_msg(word, word_eol, userdata):
    sender=word[0][1:]
    recipient=word[2]
    message=word_eol[3][1:]
    if not is_highlight(sender, recipient, message):
        return xchat.EAT_NONE
    ctx = xchat.find_context(server=xchat.get_info('server'),channel=hilight_query_name)
    if not ctx:
        # Open a query if it isn't there yet
        xchat.command('query -nofocus %s' % hilight_query_name)
        ctx = xchat.find_context(server=xchat.get_info('server'),channel=hilight_query_name)
    if message[0] == message[-1] and message[0] == '\x01':
        # CTCP. Only honor CTCP action aka /me
        if message[1:7].lower() != 'action':
            return xchat.EAT_NONE
        ctx.emit_print('Channel Action Hilight', '%s/%s' % (sender[:sender.find('!')], recipient), message[8:-1], '')
    else: 
        ctx.emit_print('Channel Msg Hilight', '%s/%s' % (sender[:sender.find('!')], recipient), message, '')
    return xchat.EAT_NONE
Exemple #43
0
def on_part(word, word_eol, userdata):
    global jointimer
    if jointimer:
        xchat.unhook(jointimer)
        jointimer = None
    triggerchannel = word[2].lower()
    thecontext = xchat.find_context(channel=triggerchannel)
    if triggerchannel in option["opin"]:
        if triggerchannel in option["limitchannels"] and option["limitjoins"] == True:
            jointimer = xchat.hook_timer(option["limittime"], part_limit, userdata=thecontext)
 def activity_cb(self, word=None, word_eol=None, data=None):
     # enable after 2.9.6beta3
     # see:
     # https://github.com/hexchat/hexchat/commit/855c20501baba9e0bcda546b6c07f20dc5648659
     # http://forum.xchat.org/viewtopic.php?f=5&t=7558
     if xchat.get_context() != xchat.find_context():
         channel = xchat.get_info("channel")
         server = xchat.get_info("server")
         self.add_activity(server, channel)
     return xchat.EAT_NONE
Exemple #45
0
def on_deop(word, word_eol, userdata):
    if option["service"] == True and option["relayops"] == True:
        operator = word[0]
        triggernick = word[1]
        destination = xchat.get_context()
        channel = destination.get_info('channel').lower()
        network = destination.get_info('network').lower()
        for relaypair in option["relaypairs"]:
            if relaypair[0] == network and relaypair[1] == channel:
                destination = xchat.find_context(server=relaypair[2], channel=relaypair[3])
                destination.command("say " + "<"+triggernick+"> was deoped by " + operator + " in " + channel + " on " + network)
Exemple #46
0
def active(chan):
    # Checks to see if chat is active to reduce annoying notifications
    try:
        chat = xchat.find_context()
        currentchat = chat.get_info("channel")
        status = xchat.get_info("win_status")
        if currentchat == chan and status == "active":
            return True
        else:
            return False
    except:
        return False
def highlight(word, word_eol, userdata):
    context = xchat.get_context()
    context.command('query -nofocus @highlight')

    nick = word[0]
    message = word_eol[1]
    channel = context.get_info("channel")
    server = context.get_info('server')

    query = xchat.find_context(server, '@highlight')
    query.prnt('[' + channel + '] <' + nick + '> ' + message[:-2])
    query.command("GUI COLOR 3")
Exemple #48
0
def local_google(word, word_eol, userdata):
    if option["resultsintab"] == True:
        xchat.command("query " + xchat.get_info("nick"))
        destination = xchat.find_context(channel=xchat.get_info("nick"))
        destination.command("settab >>Google<<")
    else:
        destination = xchat.get_context()
    if word[1] == 'query':
        threading.Thread(target=google_query, args=(word_eol[2], option["locallimit"], destination)).start()
    if word[1] == 'spell' or word[1] == 'spelling':
        threading.Thread(target=google_spelling, args=(word_eol[2], destination)).start()
        
    return xchat.EAT_ALL
Exemple #49
0
def on_part(word, word_eol, userdata):
    if option["service"] == True and option["relayjoins"] == True:
        triggernick = word[0]
        channel = word[2].lower()
        destination = xchat.get_context()
        network = destination.get_info('network').lower()
        for relaypair in option["relaypairs"]:
            if relaypair[0] == network and relaypair[1] == channel:
                destination = xchat.find_context(server=relaypair[2],
                                                 channel=relaypair[3])
                destination.command("say " + "<" + triggernick +
                                    "> has parted " + channel + " on " +
                                    network)
Exemple #50
0
def on_part(word, word_eol, userdata):
    global jointimer
    if jointimer:
        xchat.unhook(jointimer)
        jointimer = None
    triggerchannel = word[2].lower()
    thecontext = xchat.find_context(channel=triggerchannel)
    if triggerchannel in option["opin"]:
        if triggerchannel in option["limitchannels"] and option[
                "limitjoins"] == True:
            jointimer = xchat.hook_timer(option["limittime"],
                                         part_limit,
                                         userdata=thecontext)
Exemple #51
0
def update_peons():
    global troll_master, peons

    context = xchat.find_context(channel='#newvce')

    # xchat bugz
    context.get_info('channel')

    # user list
    user_list = map(lambda x: x.nick, context.get_list('users'))

    # remove any bad ones
    peons = filter(lambda x: x in user_list, peons)
Exemple #52
0
def on_deop(word, word_eol, userdata):
    if option["service"] == True and option["relayops"] == True:
        operator = word[0]
        triggernick = word[1]
        destination = xchat.get_context()
        channel = destination.get_info('channel').lower()
        network = destination.get_info('network').lower()
        for relaypair in option["relaypairs"]:
            if relaypair[0] == network and relaypair[1] == channel:
                destination = xchat.find_context(server=relaypair[2],
                                                 channel=relaypair[3])
                destination.command("say " + "<" + triggernick +
                                    "> was deoped by " + operator + " in " +
                                    channel + " on " + network)
Exemple #53
0
 def on_send_notice(self, word, word_eol, userdata):
     context = xchat.find_context(channel=word[1])
     if context:
         nick = self.get_nick(word[1])
         msg = word_eol[2]
         with suppress(ValueError, KeyError):
             msg_ = self.encrypt(nick, msg)
             self.emit_print('Notice Send', nick.split('@')[0], msg)
             with hexfish_hook.raw_command(
                     xchat.EAT_NONE), hexfish_hook.skip_print(
                         'Notice Send'):
                 xchat.command('NOTICE {} {}'.format(
                     nick.split('@')[0], msg_))
             return xchat.EAT_XCHAT
     return xchat.EAT_NONE
Exemple #54
0
 def on_send_msg(self, word, word_eol, userdata):
     context = xchat.find_context(channel=word[1])
     if context:
         nick = self.get_nick(word[1])
         msg = word_eol[2]
         with suppress(ValueError, KeyError):
             msg_ = self.encrypt(nick, msg)
             self.emit_print('Your Message',
                             xchat.get_info('nick'),
                             msg,
                             context=context)
             with hexfish_hook.raw_command(
                     xchat.EAT_NONE), hexfish_hook.skip_print(
                         'Your Message'):
                 xchat.command('MSG {} {}'.format(nick.split('@')[0], msg_))
             return xchat.EAT_XCHAT
     return xchat.EAT_NONE
Exemple #55
0
def on_target_message(word, word_eol, userdata):
    global TARGET_HOST, TARGET_CHAN
    if TARGET_HOST and TARGET_CHAN:
        ctx = xchat.find_context(channel=TARGET_CHAN)
        if ctx:
            nick = word[0]
            host = [
                user.host for user in ctx.get_list("users")
                if xchat.nickcmp(user.nick, nick) != 0
            ]
            if host:
                if host[0] == TARGET_HOST:
                    message = word[1]
                    ctx.command("say %s" % message)
        else:
            error("Missing context for %s" % TARGET_CHAN)
    return xchat.EAT_NONE
Exemple #56
0
def BanTimerTick(userdata=None):
    global banTimer, banTimes, nextBanInfo, nextBanTime
    if banTimer:
        xchat.unhook(banTimer)
        banTimer = None
    #endif
    banTime = nextBanTime
    if userdata: servChan, mask, banTime = userdata
    else: servChan, mask = nextBanInfo
    serv, chan = tuple(servChan.split("/", 1))
    context = xchat.find_context(serv, chan)
    if context:
        context.command("mode %s -b %s" % (chan, mask))
        try:
            del banTimes[servChan][mask]
        except KeyError:
            pass
    #endif
    if not userdata: nextBanInfo = nextBanTime = None
    BanTimerGo()
Exemple #57
0
def clonescan_local(word, word_eol, userdata):
    thecontext = xchat.find_context()
    checklist = {}
    clones = []
    userlist = thecontext.get_list('users')
    for user in userlist:
        checklist[user.nick] = re.split('@', user.host)[1]
    for user in checklist:
        if checklist.values().count(checklist[user]) > 1:
            clones.append((checklist[user], user))
    if clones:
        clones.sort()
        print color["red"] + "The following clones were found in " + \
        thecontext.get_info('channel') + ":"
        for clone in clones:
            print color["blue"] + clone[1] + " " + clone[0]
    else:
        print color["blue"] + "No clones found"

    return xchat.EAT_ALL
Exemple #58
0
def presence_notification_dispatch(userdata=None):
    global ignore_services, last_title

    aud = get_aud()

    ignore_services = 1
    if aud:
        pos = aud.Position()

        title = aud.SongTitle(pos).encode("utf8")

        if title != last_title:
            slist = get_servers()
            for i in slist:
                ctx = xchat.find_context(i)

                ctx.command("nickserv set qproperty np %s" % (title))

            last_title = title

    return 1