Skip to content
Extraits de code Groupes Projets
Valider 3391f9aa rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

post an url and a command: ommand get executed after url processing

parent 47ce4e49
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -134,10 +134,12 @@ sub exec {
sub tag {
my ($msg, $chan) = @_;
my @tags = ($msg =~ /(?:^| )#([a-zA-Z0-9_]+)/g);
my @tags = ($msg =~ /(?:^| )(#[a-zA-Z0-9_]+)/g);
my $id = utils::id::get($chan);
commands::tag::exec($id, "@tags");
return @tags;
}
1;
......@@ -257,11 +257,17 @@ sub on_speak
my ($nick,$mask) = split(/!/,$user);
my %content;
# first we test if it's a command
if (!commands::parser::exec(@args)) {
# if not, maybe there is an url we can parse
sites::parser::parse(@args);
# first we check for url
my @processed_str = sites::parser::parse(@args);
# we remove any part processed (url and tags)
foreach (@processed_str) {
$msg =~ s/\Q$_\E//;
}
# and we check for command
@args = ($kernel, $user, lc $chan->[0], $msg);
commands::parser::exec(@args);
}
1;
......@@ -52,6 +52,9 @@ sub parse {
$content{'url'} = 'https://www.dailymotion.com/video/' . $1;
}
my $matching_url = $&;
my @matching_tags;
# something goes wrong ?
if ($@) {
$log->warning ($@);
......@@ -104,7 +107,7 @@ sub parse {
$dbh->commit;
commands::parser::tag($msg, $chan);
@matching_tags = commands::parser::tag($msg, $chan);
my @tags;
# get tags
......@@ -133,7 +136,10 @@ sub parse {
$irc->yield(privmsg => $chan => utils::print::print(\%content));
}
return $id;
return (
$matching_url,
@matching_tags
);
}
1;
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter