Example #1
0
 def handle(self, q):
     if "msg" in q and q["msg"]:
         msg = q["msg"]
         if msg.startswith("/w "):
             msg = msg[3:].split(':', 2)
             if len(msg) >= 2:
                 message = Chat.validate(unicode(msg[1]).lstrip())
                 self.current_user.private_message(u"{to:}" + message, {"to": u'<span class="chat_line_channel channel_private" style="cursor:pointer" onclick="chat.insert_func(\'/w {0}: \')();">[Для {0}] </span>'.format(msg[0])})
                 Chat.add(self.current_user.name, message, Chat.private_channel(msg[0]))
         elif self.current_user.is_admin and msg.startswith("/"):
             log_warning('!ADMIN! ' + msg)
             msg = msg[1:].split()
             AdminAction(self.current_user, {"action": msg[0], "params": msg[1:]})
         else:
             message = Chat.validate(unicode(msg))
             Chat.add(self.current_user.name, message)
     from_time = q.get("_t", 0)
     res = {"chat": Chat.js(self.current_user.name, from_time)}
     if self.current_user.need_update():
         res["user"] = self.current_user.js()
     self.save_users()
     return res
Example #2
0
 def js_all(self, max_time=0):
     """ Описание пользователя и сообщения чата.
     """
     return {"user": self.js(), "chat": Chat.js(self.name, max_time)}