Nerds on Linux

November 4, 2010

XChat Log Search

Filed under: — karl @ 6:36 pm

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__module_name__ = "Log Search"
__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>")

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress