home · contact · privacy
Minor client improvements.
[plomrogue2-experiments] / new2 / rogue_chat_curses.py
index 6f27256a728e3a8f56db9c5d171173ff03e14036..e272fb2efb2cc53ef5796d8fa2064ee268565518 100755 (executable)
@@ -330,15 +330,32 @@ class TUI:
                     self.input_ = self.input_[:max_length]
             elif self.mode == self.mode_login and key == '\n':
                 self.socket.send('LOGIN ' + quote(self.input_))
+                self.input_ = ""
             elif self.mode == self.mode_chat and key == '\n':
                 # TODO: query, nick, help, reconnect, unknown command
-                if self.input_ == ':p':
-                    self.switch_mode('play')
-                elif self.input_ == ':?':
-                    self.switch_mode('study')
+                if self.input_[0] == ':':
+                    if self.input_ in {':p', ':play'}:
+                        self.switch_mode('play')
+                    elif self.input_ in {':?', ':study'}:
+                        self.switch_mode('study')
+                    elif self.input_.startswith(':nick'):
+                        tokens = self.input_.split(maxsplit=1)
+                        if len(tokens) == 2:
+                            self.socket.send('LOGIN ' + quote(tokens[1]))
+                        else:
+                            self.log_msg('? need login name')
+                    elif self.input_.startswith(':msg'):
+                        tokens = self.input_.split(maxsplit=2)
+                        if len(tokens) == 3:
+                            self.socket.send('QUERY %s %s' % (quote(tokens[1]),
+                                                              quote(tokens[2])))
+                        else:
+                            self.log_msg('? need message target and message')
+                    else:
+                        self.log_msg('? unknown command')
                 else:
                     self.socket.send('ALL ' + quote(self.input_))
-                    self.input_ = ""
+                self.input_ = ""
             elif self.mode == self.mode_annotate and key == '\n':
                 if (self.input_ == ''):
                     self.input_ = ' '