4/Nov 2010
By karl
1 min. read
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 = ":".
4/Nov 2010
By karl
2 min. read
XChat MPD (Music Player Daemon) Song Display for Xchat,
python script to display song information in channel.
Dependencies: python-mpd – Python MPD client library
Ubuntu: sudo apt-get install python-mpd
__module_version__ = "2.0" __module_description__ = "MPD Xchat Plugin" import xchat import mpd import os import time HOSTNAME = "localhost" PORT = "6600" client = mpd.MPDClient() def mpd_connect(): try: client.connect(HOSTNAME,PORT) except: print "Failed to connect to MPD: %s:%s" % (HOSTNAME,PORT) return client def mpd_disconnect(client): client.
4/Nov 2010
By karl
1 min. read
Grabs data using google’s gdata api and displays information about You tube links
Dependencies: python-gdata – Google Data Python client library
Ubuntu: sudo apt-get install python-gdata
import re import gdata.youtube import gdata.youtube.service __module_name__ = "YouTube Links Info" __module_version__ = "1.0" __module_description__ = "Displays information about a youtube link" def parse_youtube(link): validate = re.compile(r'((?:http://)?(?:\w+\.)?youtube\.com/(?:(?:v/)|(?:(?:watch(?:\.php)?)?\?(?:.+&)?v=)))?([0-9A-Za-z_-]+)(?(1).+)?$') valid = validate.search(link) if valid is None: return [None] yt_service = gdata.youtube.service.YouTubeService() youtube_id = valid.group(2) try: entry = yt_service.
11/Mar 2006
By karl
3 min. read
A little script written in perl, which displays the current cpu usage in a bar graph format
#!/usr/bin/perl -w ################################################################################################# # CPU Status Graph # # ------------------------------------------------ # # DESCRIPTION: Shows current cpu loads in percent for user, system, nice, and idle # # also shows a colored bar graph. See screenshots or try it :) # # # ################################################################################################# IRC::register("CPU Status Plugin", "1.0.0", "", "by: Jaguar"); IRC::add_command_handler("cpustat", "cpu_info"); $cL = "\00300"; # Letter $cI = "\00307"; # Information $cS = "\00314"; # Separator $cT = "\00304"; # Title $SEP = "|"; # Seperator $c[0] = "\00300"; $c[1] = "\00301"; $c[2] = "\00302"; $c[3] = "\00303"; $c[4] = "\00304"; $c[5] = "\00305"; $c[6] = "\00306"; $c[7] = "\00307"; $c[8] = "\00308"; $c[9] = "\00309"; $c[10] = "\00310"; $c[11] = "\00311"; $c[12] = "\00312"; $c[13] = "\00313"; $c[14] = "\00314"; $c[15] = "\00315"; sub cpu_info { # Calculate cpu usage percentage from /proc/stat open(STAT, "</proc/stat"); my ($junk, $cpu_user1, $cpu_nice1, $cpu_sys1, $cpu_idle1) = split(/\s+/, <STAT>); close(STAT); my $cpu_total1 = $cpu_user1 + $cpu_nice1 + $cpu_sys1 + $cpu_idle1; my $cpu_load1 = $cpu_user1 + $cpu_nice1 + $cpu_sys1; sleep 2; open(STAT, "</proc/stat"); ($junk, $cpu_user2, $cpu_nice2, $cpu_sys2, $cpu_idle2) = split(/\s+/, <STAT>); close(STAT); my $cpu_total2 = $cpu_user2 + $cpu_nice2 + $cpu_sys2 + $cpu_idle2; my $cpu_load2 = $cpu_user2 + $cpu_nice2 + $cpu_sys2; $CPU_USAGE = int((1000 * ($cpu_load2 - $cpu_load1)) / ($cpu_total2 - $cpu_total1))/10; $CPU_USER = int((1000 * ($cpu_user2 - $cpu_user1)) / ($cpu_total2 - $cpu_total1))/10; $CPU_NICE = int((1000 * ($cpu_nice2 - $cpu_nice1)) / ($cpu_total2 - $cpu_total1))/10; $CPU_SYS = int((1000 * ($cpu_sys2 - $cpu_sys1)) / ($cpu_total2 - $cpu_total1))/10; $CPU_IDLE = int((1000 * ($cpu_idle2 - $cpu_idle1)) / ($cpu_total2 - $cpu_total1))/10; %CPU = ("USER", $CPU_USER, "NICE", $CPU_NICE, "SYS", $CPU_SYS, "IDLE", $CPU_IDLE); # Sorted associative array (sorted by value) @CPU_VALS = sort by_values (keys (%CPU)); # Split array into seperate words ($one, $two, $three, $four) = @CPU_VALS; ($one_txt, $two_txt, $three_txt, $four_txt) = @CPU_VALS; # Determine value from key eg.
11/Mar 2006
By karl
1 min. read
X-Chat Log Search
X-Chat Youtube link information
X-Chat MPD Song Display