diff options
Diffstat (limited to 'asciifarm/client/inputhandling.hy')
| -rw-r--r-- | asciifarm/client/inputhandling.hy | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/asciifarm/client/inputhandling.hy b/asciifarm/client/inputhandling.hy deleted file mode 100644 index 9c3e254..0000000 --- a/asciifarm/client/inputhandling.hy +++ /dev/null @@ -1,48 +0,0 @@ - -(require [asciifarm.client.keymacros [*]]) -(import [asciifarm.client.keynames [nameFromKey]]) - -(defclass InputHandler [] - - (defn --init-- [self client display connection] - (setv self.client client) - (setv self.display display) - (setv self.connection connection) - (setv self.commands None)) - - (defn readCommands [self commandsstring] (do - (setv self.commands - (dict-comp - (str key) - ( - (eval `(do - (require [asciifarm.client.keymacros [*]]) - (fn [handler] - (fn [] ~value)))) - self) - [[key value] (.items (read-str commandsstring))])) - ((.get self.commands "init" (fn []))))) - - (defn runCommand [self commandstring] - (try - (eval (read-str (+ "(" commandstring ")"))) - (except [e Exception] - (self.client.log (repr e))))) - - (defn parseMessage [self message] - (if message - (if (= (first message) "/") - (do - (setv msg (.join "" (drop 1 message))) - (if (= (first msg) "/") - (send ["chat" msg]) - (self.runCommand msg))) - (send ["chat" message])))) - - (defn getDocs [self] - (if (in "help" self.commands) ((get self.commands "help")) "")) - - (defn onKey [self key] (do - (setv keyname (nameFromKey key)) - (if (in keyname self.commands) ((get self.commands keyname))))) -) |
