From 2dd8bdf2e9ca381e8e81fc9d424f6505ec221a86 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Tue, 19 Nov 2013 11:38:36 +0100 Subject: [PATCH] =?UTF-8?q?Nouvelle=20regex=20:=C2=A0la=20date=20et=20le?= =?UTF-8?q?=20lieu=20peuvent=20=C3=AAtre=20invers=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/commands/parser.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm index 082d795..6baa3d0 100644 --- a/lib/commands/parser.pm +++ b/lib/commands/parser.pm @@ -42,12 +42,23 @@ sub exec { my ($kernel, $user, $chan, $msg) = @_; my ($nick, $mask) = split(/!/,$user); - if ($msg =~ m#^Sam(?:,|:) +(je +(?:vais|viens) +à +)?(.+) +le +(\d?\d)(?:/(\d?\d)(?:/((?:\d\d)?\d\d))?)?(?: +@ +([^:]+))?(?: *: +(.*))?$#i) { + $re_place_t ="\\ +@\\ +(?<place>[^:]*)"; + + if ($msg =~ m=^Sam(?:,|:) # hl + \ +(?<add_user>je\ +(vais|viens)\ +à\ +)? # add_user + (?<title>[^@]+) # title + (?<place_t>$re_place_t)? # place + \ +le\ +(?<day>\d?\d) # day + (/(?<month>\d?\d) # month + (/(?<year>(\d\d)?\d\d))?)? # year + (?(<place_t>)|($re_place_t)?) # place (only if not match the 1st time) + (\ *:\ +(?<desc>.*))? # description + =xi) { my (undef, undef, undef, undef, $current_mon, $current_year, undef, undef, undef) = localtime(time); - my ($title, $place, $desc) = ($2, $6, $7); - my ($day, $month, $year) = ($3, $4 || $current_mon, $5 || $current_year); + my ($title, $place, $desc) = ($+{'title'}, $+{'place'}, $+{'desc'}); + my ($day, $month, $year) = ($+{'day'}, $+{'month'} || $current_mon, $+{'year'} || $current_year); $place =~ s/ $//; -- GitLab