XChat Log Search

Search the current channels xchat log and display the results in a -[search]- tab

#!/usr/bin/env python

__module_version__ = "1.0"
__module_description__ = "Searches Channel Log"

import re, glob, xchat

def search_log(word, word_eol, userdata):
        network = xchat.get_info("network")
        channel = xchat.get_info("channel")
        directory = xchat.get_info("xchatdir")
        filename = directory + "/xchatlogs/" + network + "-" + channel + ".log"
        files = glob.glob(filename)

        search = re.compile(word[1]).search
        output = "QUERY -[search]-"
        xchat.command(output)
        for file in files:
                for index, line in enumerate(open(file)):
                        if search(line):
                                output = ":".join((channel, str(index+1), line[:-1]))
                                search_win = xchat.find_context(channel='-[search]-')
                                search_win.prnt(output)
        return xchat.EAT_NONE

xchat.hook_command("s", search_log, help="/s <search for>")
More Reading
Newer// Hugo is Fun