diff --git a/src/moolite/bot/parse.clj b/src/moolite/bot/parse.clj index 9d7a3c8..2c2b3ec 100644 --- a/src/moolite/bot/parse.clj +++ b/src/moolite/bot/parse.clj @@ -2,8 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. (ns moolite.bot.parse - (:require [instaparse.core :as insta] - [taoensso.timbre :as timbre :refer [info debug]])) + (:require [instaparse.core :as insta])) (def text-lang (insta/parser @@ -14,7 +13,7 @@ : <' '> command : <'/'> callout : <'!'> - abraxas : #'[-a-zA-Z0-9]+' + abraxas : #'[-a-zA-Z0-9]+' <('@' #'[a-zA-Z0-9-]+')?> del : <'rm'|'rem'|'del'|'rimuovi'|'cancella'|'dd'|'-'> add : <'add'|'aggiungi'|'nuovo'|'crea'|'new'|'+'> url : #'https?://[^ ]+' @@ -28,3 +27,6 @@ (if (insta/failure? results) [] results))) + +(comment + (insta/parse text-lang "/cmd@marrano-bot fooo bar"));; => [:message [:command] [:abraxas "cmd"] [:text "fooo bar"]] diff --git a/test/moolite/bot/parse_test.clj b/test/moolite/bot/parse_test.clj index 9f09e9d..ece36b7 100644 --- a/test/moolite/bot/parse_test.clj +++ b/test/moolite/bot/parse_test.clj @@ -27,6 +27,11 @@ :else (is false)) (match (#'p/text-lang "/d20 4d6k2") + [_ [:command] [:abraxas "d20"] [:text text]] + (is text "4d6k2") + :else (is false)) + + (match (#'p/text-lang "/d20@marrano-bot 4d6k2") [_ [:command] [:abraxas "d20"] [:text text]] (is text "4d6k2") :else (is false)))