Le mirroring des dépôts vers Github est maintenant natif dans Gitlab (et donc Framagit). Merci de passer à la fonction native pour que nous puissions couper notre solution maison. Détails sur https://docs.gitlab.com/ee/workflow/repository_mirroring.html#pushing-to-a-remote-repository (pensez à supprimer le webhook de notre solution maison).

Commit 311f5423 by Luc Didry Committed by Luc Didry

Add Cat as a service bonus

This commit is dedicated to MaelPhi, who is supporting me on Tipeee. Many thanks :-)
parent 2190ddba
......@@ -102,4 +102,6 @@ Une commande slash vers https://giphy.example.org/money/ vous donnera ce gif:
![Edgar de la cambriole riant sous une pluie de billets](https://media0.giphy.com/media/2mXJvHKUYL9n2/giphy.gif)
Une commande slash vers https://giphy.example.org/steven ajoutera "Steven Univers" au début du texte recherché.
Une commande slash vers https://giphy.example.org/steven ajoutera "Steven Universe" au début du texte recherché.
Une commande slash vers https://giphy.example.org/cat/, vous donnera un gif de [Cat as a service](http://cataas.com/). Si vous ajoutez du texte à cette commande, le texte sera ajouté au gif.
......@@ -104,3 +104,5 @@ Point a slash command to https://giphy.example.org/money/, you'll get this gif:
![Man laughing under a banknotes rain](https://media0.giphy.com/media/2mXJvHKUYL9n2/giphy.gif)
Point a slash command to https://giphy.example.org/steven and the research will be prepended with "Steven Universe".
Point a slash command to https://giphy.example.org/cat/, you'll get a gif of a cat from [Cat as a service](http://cataas.com/). If you send text with that command, the text will be added the gif.
......@@ -175,6 +175,49 @@ sub startup {
$r->any('/cat' => sub {
my $c = shift;
my $text = $c->param('text');
if ($c->req->method eq 'GET') {
my @params = split('&', $c->req->content->asset->slurp);
for my $param (@params) {
my @h = split('=', $param);
$c->param($h[0] => $h[1]);
$text = $h[1] if ($h[0] eq 'text');
my ($token, $channel_id, $channel_name, $command, $team_domain, $team_id, $user_id, $user_name, $response_url) =
($c->param('token'), $c->param('channel_id'), $c->param('channel_name'), $c->param('command'), $c->param('team_domain'), $c->param('team_id'), $c->param('user_id'), $c->param('user_name'), $c->param('response_url'));
if ((!defined($c->config('token')) &&
defined($token) &&
defined($channel_id) &&
defined($channel_name) &&
defined($command) &&
defined($team_domain) &&
defined($team_id) &&
defined($user_id) &&
defined($user_name) &&
|| (defined $c->config('token') && $token eq $c->config('token'))
) {
my $url = Mojo::URL->new('http://cataas.com/cat/gif');
my $alt = 'Gif de chat';
if ($text) {
$alt = $text;
$alt =~ s/([\[\]\(\)])/\\$1/g;
$text =~ s/'/%27/g;
json => {
"response_type" => "in_channel",
"text" => "![$alt]($url)"
} else {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment