diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm index 082d795f3a3990de01fe00f357aea8deb5f8f77b..6baa3d0f5d103a57ab4068068e2482f73b8e67ee 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/ $//;