Skip to content

Instantly share code, notes, and snippets.

@wrboyce
Created July 7, 2010 15:30
Show Gist options
  • Save wrboyce/466835 to your computer and use it in GitHub Desktop.
Save wrboyce/466835 to your computer and use it in GitHub Desktop.
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