Created
July 7, 2010 15:30
-
-
Save wrboyce/466835 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warnings; | |
use strict; | |
use vars qw($VERSION %IRSSI); | |
use Irssi; | |
$VERSION = '1.0'; | |
%IRSSI = ( | |
authors => 'Will Boyce', | |
contact => '[email protected]', | |
name => '/brb', | |
description => 'Generates a random reason for being afk. Based on http://hentan.eu/adium/brb', | |
license => 'BSD', | |
); | |
Irssi::command_bind("brb", "cmd_brb"); | |
sub cmd_brb { | |
my ($argv, $server, $witem) = @_; | |
if (!$server || !$server->{connected}) { | |
Irssi::print("Not connected to server"); | |
return; | |
} | |
my $reason = getreason(); | |
$server->command("MSG $witem->{name} brb - $reason"); | |
} | |
sub getreason { | |
srand; | |
my $line; | |
my $filename = Irssi::get_irssi_dir()."/brb_reasons.txt"; | |
open FILE, "<$filename" or Irssi::print("Could not open $filename: $!"); | |
rand($.) <1 and ($line=$_) while <FILE>; | |
close FILE; | |
chomp($line); | |
return $line; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment