]> gitweb.factorcode.org Git - factor-unmaintained.git/blobdiff - irc-ui/commandparser/commandparser.factor
unmaintained: New home for misfit Factor vocabularies.
[factor-unmaintained.git] / irc-ui / commandparser / commandparser.factor
diff --git a/irc-ui/commandparser/commandparser.factor b/irc-ui/commandparser/commandparser.factor
new file mode 100644 (file)
index 0000000..43ea80c
--- /dev/null
@@ -0,0 +1,15 @@
+! Copyright (C) 2008 William Schlieper
+! See http://factorcode.org/license.txt for BSD license.
+
+USING: kernel vocabs.loader sequences strings splitting words irc.messages ;
+
+IN: irc.ui.commandparser
+
+: command ( string string -- string command )
+    [ "say" ] when-empty
+    dup "irc.ui.commands" lookup
+    [ nip ]
+    [ " " append prepend "quote" "irc.ui.commands" lookup ] if* ;
+
+: parse-message ( string -- )
+    "/" ?head [ " " split1 swap command ] [ "say" command ] if execute ;