Skip to content

Commit

Permalink
Ajout de !link
Browse files Browse the repository at this point in the history
  • Loading branch information
matael committed Jul 21, 2012
1 parent 94b278a commit c6109b6
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions teuse.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use 5.010;
use Bot::BasicBot;
use LWP::Simple;
use LWP::UserAgent;
use JSON;

package Teuse;
Expand Down Expand Up @@ -126,6 +127,49 @@ sub said {
);
}
}
# links
elsif ($a->{body} =~ /^!link\s(.*)$/) {
if ($1 =~ /([^\s]*)(\s.*)?$/) {
# request to links.matael.org
my $ua = LWP::UserAgent->new():
my $url = $1;
if ($2) {
my $title = $2;
} else {
my $title = $url;
}

my $response = $ua->post("http://links.matael.org",
[
url => $url,
title => $title,
poster => $a->{who}
]
);
if ($response->is_success) {
my $msg = "Grand succès !";
} else {
my $msg = "Arf... il semblerait que ça bloque ! $master ? Un coup de main ?";
}

$self->say(
who => $a->{who},
channel => $a->{channel},
body => $msg
);
} else {
$self->say(
who => $a->{who},
channel => $a->{channel},
body => "Normalement c'est comme ça :"
);
$self->say(
channel => $a->{channel},
body => "!link URL [titre]"
);
}
}


#############################
# pelle teuse
Expand Down

0 comments on commit c6109b6

Please sign in to comment.