XChat offers great support for scripts in Perl and Python, and even C plugins, making adding features or additional functionality very easy, with minimum programming knowledge.
In this tutorial I will show how to make a very basic, functional Amarok now playing announcer for it.
Open your text editor of choice and put the following code in it:
Next, save the file, say as amarok_np.pl into your ~/.xchat2/ directory, where ~ is your home directory. This way, it will be loaded by default when XChat starts. If you type /ANP in a channel or query while Amarok is playing a song, you'll see a message similar to:
Xchat::register ("Amarok NP", "0.1.0", "Amarok NP for XChat");
Xchat::hook_command ("ANP", cmd_anp);
Xchat::print ("Amarok NP loaded. Type /ANP to use.");
$isPlaying = `dcop amarok default isPlaying`;
if ($isPlaying eq "true")
$nowPlaying = `dcop amarok default nowPlaying`;
Xchat::command ("ME listening to: $nowPlaying");
if ($isPlaying eq "false")
Xchat::print ("Amarok is either stopped or paused");
if ($isPlaying eq "")
Xchat::print ("Amarok is not running");
[18:46] * Embryo Listening to: ABBA - Happy New Year
How does it work?
The first line provides XChat information about the script itself, like the name, version number and a brief description. This information will appear in the Window -> Plugins and Scripts... dialogue.
The next line tells XChat that a new command was created, and the code below should be executed when this command is ran.
Xchat::print ("Amarok NP loaded. Type /ANP to use.");This is what will appear when the script is loaded. You can enter anything here.
Here you can find several now playing scripts and plugins for XChat.
XChat Perl Interface - Very useful documentation on the official website on how to use Perl for scripting XChat
Updated: Jun 15, 2008 (Created: Jun 15, 2008)