Support Forums
Some simple Perl script snipets for xChat by B22stard - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Perl Programming Support (https://www.supportforums.net/forumdisplay.php?fid=31)
+---- Thread: Some simple Perl script snipets for xChat by B22stard (/showthread.php?tid=669)

Pages: 1 2


Some simple Perl script snipets for xChat by B22stard - jolttz - 10-08-2009

Just place the scripts in the xChat directory and make sure there's the Perl extension ".pl".

Auto ReJoin when kicked:
Code:
#!/usr/bin/perl

my $version = "0.1";
Xchat::register("ReJoin", $version, "Re-join when kicked", "");
Xchat::print("Loaded: Perl AutoReJoin script by B22stard");
Xchat::hook_print("You Kicked", "kicked");

sub kicked {
  my $channel = Xchat::get_info( "channel");
  Xchat::command("j $channel");
  return Xchat::EAT_NONE;
}

Hop script. I wrote this script because there's not "/hop" command for xChat like there is with mIRC. It leaves and rejoins the channel when the command is given.
Code:
#!/usr/bin/perl

my $version = "0.1";
Xchat::register("HopScript", $version, "Leave and Rejoin the channel", "");
Xchat::print('Loaded: Perl Hop script by B22stard. Type "/rejoin" to leave and rejoin the channel.');
Xchat::hook_command("rejoin","rejoin");

sub rejoin {
  my $channel = Xchat::get_info( "channel");
  Xchat::command("part $channel hopping");
  Xchat::command("join $channel");
}

Rhythmbox NowPlaying script. Displays the currently playing song to the channel.
Code:
#!/usr/bin/perl

my $version = "0.3";
Xchat::register("NowPlaying", $version, "Displays currently playing song from Rhythmbox", "");
Xchat::hook_command("np", "nowPlaying");
Xchat::print('Loaded: Perl NowPlaying script by B22stard. Type "/np".');

sub nowPlaying {
    if (`ps -C rhythmbox` =~ /rhythmbox/) {
    $title = `rhythmbox-client --print-playing-format %st`;
    if (length $title > 1) {
        $title = `rhythmbox-client --print-playing-format %st\\ -\\ %tt`;
    } else {
        $title = `rhythmbox-client --print-playing-format %ta\\ -\\ %at\\ -\\ %tt\\ -\\ "(%te/%td)"`;
    }
    chop $title;
    Xchat::command("me is listening to: " . $title);
    } else {
    Xchat::print("Rhythmbox is not running.");
    }
}



RE: Some simple Perl script snipets for xChat by B22stard - x0re - 10-11-2009

Not bad, thanks for the share...keep em comming


RE: Some simple Perl script snipets for xChat by B22stard - Extasey - 10-11-2009

Awesome, I like the music box one!

Good work!


RE: Some simple Perl script snipets for xChat by B22stard - Akshay* - 10-12-2009

@ B22stard

These are good.Post Like this to get +rep


RE: Some simple Perl script snipets for xChat by B22stard - rated - 10-12-2009

thanks,would rep you but, i need 100 posts


RE: Some simple Perl script snipets for xChat by B22stard - chinaman7x7 - 10-15-2009

worth getting, nice!


RE: Some simple Perl script snipets for xChat by B22stard - manipulate - 10-20-2009

Very good.
1. You can turn autojoin oni (/set)
2. You can just alias /cycle to /hop ;)


RE: Some simple Perl script snipets for xChat by B22stard - bsdpunk - 10-21-2009

Sweet Rythmbox, script......Hmmm maybe I should switch permanently to rythmbox


RE: Some simple Perl script snipets for xChat by B22stard - manipulate - 10-22-2009

Oh that's a stupid idea bsdpunk.


RE: Some simple Perl script snipets for xChat by B22stard - bsdpunk - 10-23-2009

Heh, took me a little bit to get the aac files to work, But at home I'm completely switched over Smile