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 { ...@@ -134,10 +134,12 @@ sub exec {
sub tag { sub tag {
my ($msg, $chan) = @_; 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); my $id = utils::id::get($chan);
commands::tag::exec($id, "@tags"); commands::tag::exec($id, "@tags");
return @tags;
} }
1; 1;
...@@ -257,11 +257,17 @@ sub on_speak ...@@ -257,11 +257,17 @@ sub on_speak
my ($nick,$mask) = split(/!/,$user); my ($nick,$mask) = split(/!/,$user);
my %content; my %content;
# first we test if it's a command # first we check for url
if (!commands::parser::exec(@args)) { my @processed_str = sites::parser::parse(@args);
# if not, maybe there is an url we can parse
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; 1;
...@@ -52,6 +52,9 @@ sub parse { ...@@ -52,6 +52,9 @@ sub parse {
$content{'url'} = 'https://www.dailymotion.com/video/' . $1; $content{'url'} = 'https://www.dailymotion.com/video/' . $1;
} }
my $matching_url = $&;
my @matching_tags;
# something goes wrong ? # something goes wrong ?
if ($@) { if ($@) {
$log->warning ($@); $log->warning ($@);
...@@ -104,7 +107,7 @@ sub parse { ...@@ -104,7 +107,7 @@ sub parse {
$dbh->commit; $dbh->commit;
commands::parser::tag($msg, $chan); @matching_tags = commands::parser::tag($msg, $chan);
my @tags; my @tags;
# get tags # get tags
...@@ -133,7 +136,10 @@ sub parse { ...@@ -133,7 +136,10 @@ sub parse {
$irc->yield(privmsg => $chan => utils::print::print(\%content)); $irc->yield(privmsg => $chan => utils::print::print(\%content));
} }
return $id; return (
$matching_url,
@matching_tags
);
} }
1; 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