Пример #1
0
    def process_cmd(self, user_id, msg):
        client_socket = self.get_user_socket(user_id)
        if client_socket is None:
            return pt.MSG_ERROR
        if not msg:
            return pt.MSG_ERROR
        res = pt.getcmd(msg)
        if res is None:
            return pt.MSG_ERROR
        cmdno = res[0]
        args = res[1]
        argss = [user_id, client_socket]

        text = pt.MAP_CMD_NO.keys()[pt.MAP_CMD_NO.values().index(cmdno)]
        for ag in args:
            argss.append(ag)
            text = text + "  " + ag
        text = '{0}:{1} | {2}'.format(user_id, self.get_user_name(user_id),
                                      text)
        print text
        if self.issupportcmd(user_id, cmdno) is not True:
            text = text + "  | no authority or no this command !"
            pt.send(client_socket, user_id, pt.SERV_USER, pt.MSG_ERROR, text)
            return pt.MSG_ERROR
        return scmap.MAP_CMD_FUN[cmdno](self, argss)
Пример #2
0
    def process_cmd(self, user_id, msg):
        client_socket = self.get_user_socket(user_id)
        if client_socket is None:
            return pt.MSG_ERROR
        if not msg:
            return pt.MSG_ERROR
        res = pt.getcmd(msg)
        if res is None:
            return pt.MSG_ERROR
        cmdno = res[0]
        args = res[1]
        argss = [user_id, client_socket]

        text = pt.MAP_CMD_NO.keys()[pt.MAP_CMD_NO.values().index(cmdno)]
        for ag in args:
            argss.append(ag)
            text = text + "  " + ag
        text = '{0}:{1} | {2}'.format(user_id,
                                      self.get_user_name(user_id),
                                      text)
        print text
        if self.issupportcmd(user_id, cmdno) is not True:
            text = text + "  | no authority or no this command !"
            pt.send(client_socket, user_id, pt.SERV_USER, pt.MSG_ERROR, text)
            return pt.MSG_ERROR
        return scmap.MAP_CMD_FUN[cmdno](self, argss)
Пример #3
0
 def process_serv_cmd(self, msg):
     if not msg:
         return pt.MSG_ERROR
     res = pt.getcmd(msg)
     if res is None:
         return pt.MSG_ERROR
     cmdno = res[0]
     args = res[1]
     argss = [pt.SERV_USER, self.get_server_socket()]
     try:
         if len(args) > 0:
             argss = [int(args[0]), self.get_server_socket()]
     except:
         return pt.MSG_ERROR
     text = pt.get_cmd_name(cmdno)
     # text = pt.MAP_CMD_NO.keys()[pt.MAP_CMD_NO.values().index(cmdno)]
     for ag in args[1:]:
         argss.append(ag)
         text = text + "  " + ag
     text = '[{0}:{1}] | {2}'.format(pt.SERV_USER, 'server', text)
     print text
     if cmdno not in pt.CMD_SET:
         text = text + "  | No this command !"
         print text
         return pt.MSG_ERROR
     return scmap.MAP_CMD_FUN[cmdno](self, argss)
Пример #4
0
 def process_serv_cmd(self, msg):
     if not msg:
         return pt.MSG_ERROR
     res = pt.getcmd(msg)
     if res is None:
         return pt.MSG_ERROR
     cmdno = res[0]
     args = res[1]
     argss = [pt.SERV_USER, self.get_server_socket()]
     try:
         if len(args) > 0:
             argss = [int(args[0]), self.get_server_socket()]
     except:
         return pt.MSG_ERROR
     text = pt.get_cmd_name(cmdno)
     # text = pt.MAP_CMD_NO.keys()[pt.MAP_CMD_NO.values().index(cmdno)]
     for ag in args[1:]:
         argss.append(ag)
         text = text + "  " + ag
     text = '[{0}:{1}] | {2}'.format(pt.SERV_USER, 'server', text)
     print text
     if cmdno not in pt.CMD_SET:
         text = text + "  | No this command !"
         print text
         return pt.MSG_ERROR
     return scmap.MAP_CMD_FUN[cmdno](self, argss)