Skip to content

Instantly share code, notes, and snippets.

@mattbailey
Last active December 10, 2015 16:08
Show Gist options
  • Save mattbailey/4458721 to your computer and use it in GitHub Desktop.
Save mattbailey/4458721 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
#use strict;
$flood = 0;
use Irssi;
use DBI;
use warnings;
use vars qw($flood $VERSION %IRSSI);
use WebService::EveOnline;
$VERSION = '1.00';
%IRSSI = (
authors => 'Matt Bailey',
contact => 'ribo [at] system42.net',
name => 'evescript',
description => 'EVE API in irssi',
license => 'Public Domain',
);
Irssi::signal_add_last "message public" => sub {
my ($server, $msg, $nick, $address, $target) = @_;
my $floodDelta = time() - $flood;
if ($msg =~ /^\.eve/i && $floodDelta > 5) {
my $in_name = $msg;
$in_name =~ s/\.eve //;
my $comment = eve($in_name);
$server->command("/MSG $target $comment");
$flood = time();
}
};
Irssi::signal_add "message own_public" => sub {
my ($server, $msg, $target) = @_;
if ($msg =~ /^\.eve/i) {
my $in_name = $msg;
$in_name =~ s/\.eve //;
my $comment = eve($in_name);
$server->command("/MSG $target $comment");
$flood = time();
}
};
sub eve {
our ($name) = @_;
our $nouser = "no";
our $out = "";
<KEYS REDACTED>
} else {
$nouser = "yes";
#return("no such wang!");
}
if ( $nouser =~ "no" ) {
my $eve = WebService::EveOnline->new( { user_id => $USER_ID, api_key => $API_KEY } );
my $character = $eve->character($name);
my $mem = $character->attributes->memory;
my $int = $character->attributes->intelligence;
my $per = $character->attributes->perception;
my $wil = $character->attributes->willpower;
my $chr = $character->attributes->charisma;
my $skill = $character->skill->in_training;
my $skillname = $skill->name;
my $timeleft = $character->skill->in_training->time_remaining;
my $tolevel = $skill->level;
my @accounts = $character->accounts();
my $monies = $accounts[0]->balance;
#my $corpmonies = $accounts[1]->balance;
my $API_KEY_CEO = "REDACTED";
my $USER_ID_CEO = "REDACTED";
my $eve_ceo = WebService::EveOnline->new( { user_id => $USER_ID_CEO, api_key => $API_KEY_CEO } );
my $ceo = $eve_ceo->character('ribo');
my @members = $ceo->corporation->members;
our $loc;
our $ship;
foreach my $member (@members) {
if ( $member->name =~ $name ) {
$loc = $member->location;
$ship = $member->ship_type;
}
}
$out = "$name: [m$mem i$int p$per w$wil c$chr] $skillname $tolevel Finishes in $timeleft, Sitting in $loc in a $ship with $monies monies";
} else {
my $API_KEY_CEO = "REDACTED";
my $USER_ID_CEO = "REDACTED";
my $eve_ceo = WebService::EveOnline->new( { user_id => $USER_ID_CEO, api_key => $API_KEY_CEO } );
my $ceo = $eve_ceo->character('ribo');
my @members = $ceo->corporation->members;
our $loc;
our $ship;
foreach my $member (@members) {
if ( $member->name =~ $name ) {
$loc = $member->location;
$ship = $member->ship_type;
}
}
$out = "No APIKEY for $name, but he's in $loc, chillin in a $ship";
}
return($out);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment